Skip to content
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 all trials in TPESampler even when multivariate=True #4079

Merged
merged 7 commits into from
Nov 7, 2022

Conversation

knshnb
Copy link
Member

@knshnb knshnb commented Oct 14, 2022

Motivation

In the current TPE, the trials without parameters that we want to sample are skipped when multivatiate=True (link). However, when multivariate=False, those trials are used effectively in the following two steps.

  • Split the whole trials into below and above.
  • Hypervolume calculation for multi-objective optimization.

This PR fixes the behavior of multivariate=True and makes it consistent with multivariate=False.

Description of the changes

  • Use all trials when multivariate=False.
  • Remove the multivariate argument from _get_observation_pairs.

[Note] This PR slightly changes the current behavior of TPESampler in the following points.

  • When multivariate=True and group=True, the trials that do not include suggesting parameters are also used. (When multivariate=True and group=False, this does not change the behavior because parameters in the intersection search space are included in all trials)
  • Compare n_startup_trials with only the number of trials that include suggesting parameters.

@github-actions github-actions bot added the optuna.samplers Related to the `optuna.samplers` submodule. This is automatically labeled by github-actions. label Oct 14, 2022
@knshnb knshnb added the compatibility Change that breaks compatibility. label Oct 17, 2022
@knshnb knshnb marked this pull request as ready for review October 18, 2022 05:35
@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2022

Codecov Report

Merging #4079 (2251454) into master (bccb63d) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4079      +/-   ##
==========================================
- Coverage   90.10%   90.10%   -0.01%     
==========================================
  Files         161      161              
  Lines       12655    12652       -3     
==========================================
- Hits        11403    11400       -3     
  Misses       1252     1252              
Impacted Files Coverage Δ
optuna/samplers/_tpe/sampler.py 96.93% <100.00%> (-0.03%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@c-bata
Copy link
Member

c-bata commented Oct 19, 2022

@not522 @HideakiImamura Could you review this PR?

Copy link
Member

@HideakiImamura HideakiImamura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great simplification of TPESampler. I have a comment. PTAL.

tests/samplers_tests/tpe_tests/test_sampler.py Outdated Show resolved Hide resolved
Copy link
Member

@HideakiImamura HideakiImamura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your swift actions! LGTM!

@HideakiImamura HideakiImamura removed their assignment Oct 23, 2022
@knshnb
Copy link
Member Author

knshnb commented Oct 25, 2022

I resolved the conflict with #4073. PTAL 🙏

Copy link
Member

@not522 not522 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the document of n_startup_trials? It does not match the current behavior.

Comment on lines 396 to 399
n_sampled = sum(
step < float("inf") and param is not None
for (step, _), param in zip(scores, list(values.values())[0])
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment for this counting. It is a bit complicated to understand the behavior.

@knshnb
Copy link
Member Author

knshnb commented Nov 4, 2022

@not522 Thanks for the comments. As discussed privately, I decided to keep the original behavior of n_startup_trials and focus only on the change of _get_observation_pairs in this PR.

Copy link
Member

@not522 not522 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@not522 not522 merged commit e7dbd13 into optuna:master Nov 7, 2022
@not522 not522 changed the title Use all trials in TPESampler even when multivariate=True Use all trials in TPESampler even when multivariate=True Nov 7, 2022
@not522 not522 added this to the v3.1.0 milestone Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Change that breaks compatibility. optuna.samplers Related to the `optuna.samplers` submodule. This is automatically labeled by github-actions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants