Cache distributions to skip consistency check#6301
Conversation
|
The improvement from this PR is proportional to the number of times import optuna
def objective(trial: optuna.Trial) -> float:
return sum(trial.suggest_float(f"x{i}", -100, 100) ** 2 for i in range(10))
sampler = optuna.samplers.RandomSampler(seed=42)
study = optuna.create_study(sampler=sampler, storage="sqlite:///tmp.db")
study.optimize(objective, n_trials=1000)
|
|
@sawa3030 @kAIto47802 Could you review this PR? |
sawa3030
left a comment
There was a problem hiding this comment.
Thank you for the additional benchmarking. I have reviewed and confirmed the changes. Since the caching algorithm is relatively simple here, I am in favor of merging this PR.
optuna/storages/_rdb/storage.py
Outdated
| @@ -587,25 +587,60 @@ def set_trial_param( | |||
| session, trial_id, param_name, param_value_internal, distribution | |||
| ) | |||
There was a problem hiding this comment.
How about using _set_trial_params here, since set_trial_params performs the same operation while just hiding the previous_distribution argument from the user?
return self._set_trial_param(trial_id, param_name, param_value_internal, distribution)There was a problem hiding this comment.
Thank you. I've updated as suggested. PTAL.
kAIto47802
left a comment
There was a problem hiding this comment.
Thank you for the update! LGTM
Motivation
RDBStorageperforms consistency checks with past distributions inset_trial_param, but it can be skipped by caching past distributions in_CachedStorage.In the original
_CachedStorage(#1140), it was implemented, but lost that feature in #4631 and removed in #5978. This PR reintroduces that functionality.Description of the changes
_CachedStorageto skip consistency checkBenchmark