Refactor tell_with_warning to avoid unnecessary get_trial call#6133
Conversation
Performance ImprovementThe runtime of
|
Are the results written on the table reversed? |
optuna/study/_tell.py
Outdated
| frozen_trial = study._storage.get_trial(frozen_trial._trial_id) | ||
|
|
||
| return frozen_trial, values_conversion_failure_message | ||
| return state, values, frozen_trial.params, values_conversion_failure_message |
There was a problem hiding this comment.
Do we need to return params? _run_trial stores them in the trial.
|
@kAIto47802 Could you review this PR? |
Thank you for pointing that out — the results were indeed reversed. I've corrected the comment accordingly. |
4be65ae to
01a1f95
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6133 +/- ##
==========================================
- Coverage 88.39% 88.30% -0.09%
==========================================
Files 207 207
Lines 14036 14027 -9
==========================================
- Hits 12407 12387 -20
- Misses 1629 1640 +11 ☔ View full report in Codecov by Sentry. |
| skip_if_finished=skip_if_finished, | ||
| ) | ||
| return copy.deepcopy(frozen_trial) | ||
| return copy.deepcopy(_get_frozen_trial(self, trial)) |
There was a problem hiding this comment.
How about use self._storage.get_trial?
There was a problem hiding this comment.
I've made the updates. PTAL!
There was a problem hiding this comment.
Since the argument is the trial number, we should use get_trial_id_from_study_id_trial_number. After reconsideration, this solution turns out to be more complex than I expected, so reverting to using _get_frozen_trial may be good. 🙇
kAIto47802
left a comment
There was a problem hiding this comment.
Thank you for the PR. LGTM!
Motivation
Remove unnecessary calls to
storage.get_trialto improve efficiency.Description of the changes
storage.get_trialcall intell_with_warning.FrozenTrial,tell_with_warningnow returnsstate,values,params, andvalues_conversion_failure_message, which are required for subsequent log output.