Support multiple studies in InMemoryStorage.#1228
Conversation
| if isinstance(storage, InMemoryStorage): | ||
| with pytest.raises(ValueError): | ||
| # InMemoryStorage shares the same study if create_new_study is additionally invoked. | ||
| # Thus, the following line should fail due to distribution incompatibility. | ||
| storage.set_trial_param(trial_id_3, "y", 1, distribution_y_2) | ||
| pass |
There was a problem hiding this comment.
These "tests" will be completely removed by #1191.
|
|
||
| with pytest.raises(ValueError): | ||
| ChainerMNStudy(study, comm) | ||
| pass |
|
@ytsmiling Thank you for your PR. I'll review this PR today. |
|
Result of the same benchmark with #1135: (1000 trials 30 params) So, rewriting the in-memory db codes resulted in over 30% speedup. |
|
Oh, great! Honestly, I was a bit concern that this PR might introduce some overhead. |
|
I guess that the speed up comes from rewriting the |
hvy
left a comment
There was a problem hiding this comment.
Thanks for the PR. I'm also concerned about the locking but left some minor comments and questions from my side.
optuna/storages/in_memory.py
Outdated
| self._check_study_id(study_id) | ||
| with self._lock: | ||
| return copy.deepcopy(self.study_user_attrs) | ||
| return self._studies[study_id].user_attrs |
There was a problem hiding this comment.
Please correct me if I'm wrong but changing the copy behavior seems to go a bit beyond the scope of this PR (ditto for get_study_system_attrs and get_trial).
There was a problem hiding this comment.
Yes, it can be addressed in another PR.
However, the current implementation of this PR relies on this copying behavior of get_trial, and modifying the line requires a large change of codes.
I'll create another PR to change the copying behavior and I'd like to merge it before this PR.
There was a problem hiding this comment.
After examining the code, I decided not to create separate PR and keep the original copying behavior in this PR.
|
#1228 (comment) |
|
After reverting the deep-copy behavior in #1228 (comment), the benchmark became as follows: This is almost the same as the current master implementation. |
hvy
left a comment
There was a problem hiding this comment.
Thanks for your quick fixes. I left some additional comments related to your latest changes.
sile
left a comment
There was a problem hiding this comment.
LGTM.
I'm looking forward to merging this PR as the inconsistent behavior of InMemoryStrage was a concern for a long time.
Motivation
This PR adds multi-study support to in-memory storage.
This partially addresses #1170 and relates to #1191.
Description of the changes
Add multi-study support to in-memory db.
Other notes
I checked that this passes tests in #1191 in python3.5.
Update: