-
-
Notifications
You must be signed in to change notification settings - Fork 976
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
Cache the latest result of HSSP for speedup of MOTPE #5454
Conversation
It seems that the change of this PR includes not only the cache on results of HSSP but also that on the split of TPE. Could you separate the change for the cache on the split into another PR? It would be great to discuss each item. |
FYI: How about utilizing |
@eukaryo thank you for the suggestion! |
@nabenabe0928 Thank you for your rapid reply! |
@eukaryo I got your point and tried lru_cache, but it seems lru_cache takes only hashable as arguments and neither list not Array can be hashed, so it didn't work. |
I see, that's unfortunate. I really appreciate your effort! |
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.
Could you add unit tests to validate the cases in which the cache hit/doesn't hit?
I added a unittest! |
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.
Thank you for the update. I have a comment for the test. PTAL.
"storage", | ||
(optuna.storages.RDBStorage("sqlite:///:memory:"), optuna.storages.InMemoryStorage()), | ||
) | ||
def test_solve_hssp_with_cache(storage: optuna.storages.BaseStorage) -> None: |
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.
At first glance, it seems that this test includes too many preparations and logics. How about pre-determining the arguments of _solve_hssp_and_check_cache
?
We discussed internally and decided to close this PR. |
Motivation
As the speed bottleneck of MOTPE comes from the HSSP calculation at each iteration, I introduce the caching for HSSP.
This is very important especially for
n_objectives > 2
.Note that the split cache relates to the following PR:
_get_observation_pairs
for conditional parameters. #1166It is algorithmically wrong to consider different splits for different dimensions.
Description of the changes
I added a cache of the latest HSSP result to
study.system_attrs
.Benchmarking Results
I did a benchmarking using a 2-dimensional 3-objective function with
n_trials=1000
.My PR enables MOTPE to finish the optimization on this problem four times quicker with the identical optimization result.
Code