-
-
Notifications
You must be signed in to change notification settings - Fork 971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use shallow copy in _get_latest_trial
#4774
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## master #4774 +/- ##
=======================================
Coverage 90.81% 90.81%
=======================================
Files 189 189
Lines 14416 14416
=======================================
Hits 13092 13092
Misses 1324 1324
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@toshihikoyanase @HideakiImamura Could you review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I'm sorry for the delayed response.
Let me check the implementation of the built-in samplers/pruners. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The trial objects returned by _get_latest_trial
are used in the following methods:
BaseSampler.sample_independent
BasePruner._filter_study
sampler | check | comment |
---|---|---|
BoTorchSampler | OK | pass to independent sampler |
PyCmaSampler | OK | pass to independent sampler |
SkoptSampler | OK | pass to independent sampler |
BruteForceSampler | OK | read trial.number |
CmaEsSampler | OK | pass to independent sampler |
GridSampler | OK | read trial.system_attrs |
NSGAIIISampler | OK | pass to independent sampler |
PartialFixedSampler | OK | pass to independent sampler |
QMCSampler | OK | pass to independent sampler |
RandomSampler | OK | not used |
TPESampler | OK | pass to independent sampler. not used in _sample ? |
NSGAIISampler | OK | pass to random sampler |
DeterministicSampler | OK | not used |
FirstTrialOnlyRandomSampler | OK | not used |
(tests) FixedSampler | OK | not used |
(tests) SamplerStubForTestRelativeParameters | OK | not used |
(tutorial) SimulatedAnnealingSampler | OK | pass to independent sampler |
pruner | check | comment |
---|---|---|
HyperbandPruner | OK | read trial.number in _get_bracket_id |
Motivation
The deep copy in
_get_latest_trial
takes a long time when the parameters are many. This PR changes it to the shallow copy.The returned
FrozenTrial
is passed to samplers and pruners, but they must not modify the trial object. This behavior is described in the base classes.optuna/optuna/samplers/_base.py
Lines 136 to 138 in b00caef
benchmark
Description of the changes
_get_latest_trial