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

Add a pruner based on ASHA #236

Merged
merged 18 commits into from Dec 26, 2018
Merged

Add a pruner based on ASHA #236

merged 18 commits into from Dec 26, 2018

Conversation

sile
Copy link
Member

@sile sile commented Nov 27, 2018

This PR contains the following changes (mainly):

  • Created optuna/pruners/ directory and split pruners.py into pruners/base.py and pruners/median.py
  • Added SuccessiveHalvingPruner class
  • Added test cases for SuccessiveHalvingPruner

optuna/pruners/asha.py Outdated Show resolved Hide resolved
optuna/pruners/asha.py Outdated Show resolved Hide resolved
optuna/pruners/asha.py Outdated Show resolved Hide resolved
@toshihikoyanase toshihikoyanase added the feature Change that does not break compatibility, but affects the public interfaces. label Dec 12, 2018
@sile
Copy link
Member Author

sile commented Dec 17, 2018

@g-votte @toshihikoyanase @iwiwi

I updated documentation of SuccessiveHalvingPruner. So it is ready to be reviewed.

Copy link
Contributor

@iwiwi iwiwi left a comment

Choose a reason for hiding this comment

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

LGTM around the points that I mentioned above

@sile
Copy link
Member Author

sile commented Dec 19, 2018

@g-votte @toshihikoyanase
I updated documents. Please tell me if there are some points to improve.

optuna/pruners/successive_halving.py Outdated Show resolved Hide resolved
optuna/pruners/successive_halving.py Outdated Show resolved Hide resolved
optuna/pruners/successive_halving.py Outdated Show resolved Hide resolved
optuna/pruners/successive_halving.py Outdated Show resolved Hide resolved
optuna/pruners/successive_halving.py Outdated Show resolved Hide resolved
optuna/pruners/successive_halving.py Outdated Show resolved Hide resolved
optuna/pruners/successive_halving.py Outdated Show resolved Hide resolved
@sile
Copy link
Member Author

sile commented Dec 20, 2018

@g-votte @toshihikoyanase
Thank you for your careful review. I updated documentation and some functions to reflect your comments.

@sile sile added this to the v0.6.0 milestone Dec 21, 2018
assert 'completed_rung_1' not in trial.system_attrs


def test_successive_halving_pruner_reduction_factor_parameter():
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 type hint.

assert 'completed_rung_2' not in trial.system_attrs


def test_successive_halving_pruner_min_early_stopping_rate_parameter():
Copy link
Member

Choose a reason for hiding this comment

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

ditto.


study = optuna.study.create_study()

# min_resource=1: The rung 0 ends at step 1.
Copy link
Member

Choose a reason for hiding this comment

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

I think we can add an edge case where min_resource < 1 to confirm SuccessiveHalvingPruner.__init__() raises an appropriate exception. Also, please take care of the cases where reduction_factor < 2 and min_early_stopping_rate < 0 in test_successive_halving_pruner_reduction_factor_parameter and test_successive_halving_pruner_min_early_stopping_rate_parameter, respectively.

min_resource=1, reduction_factor=2, min_early_stopping_rate=0)

# A pruner is not activated at a first trial.
assert not pruner.prune(study.storage, study.study_id, trial.trial_id, step=1)
Copy link
Member

Choose a reason for hiding this comment

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

I could not find the case where the target value of the pruner is NaN. Please add a test function like test_successive_halving_pruner_with_nan to confirm trials with NaN values are pruned without any exceptions.

assert 'completed_rung_3' not in trial.system_attrs


def test_successive_halving_pruner_first_trial_always_wins():
Copy link
Member

Choose a reason for hiding this comment

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

Because of "wins", I think this method name is a bit misleading. As there's no competition among trials in this test scenario, how about test_successive_halving_pruner_first_trial_is_not_pruned?

assert pruner.prune(study.storage, study.study_id, trial.trial_id, step=1)


def test_successive_halving_pruner_up_to_third_rung():
Copy link
Member

Choose a reason for hiding this comment

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

With this method name, I feel as if third were a boundary value. How about renaming this method to test_successive_halving_pruner_rung_check?

@sile
Copy link
Member Author

sile commented Dec 25, 2018

@toshihikoyanase @g-votte I updated test_successive_halving.py for reflecting your review comments.

Copy link
Member

@toshihikoyanase toshihikoyanase left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@g-votte g-votte left a comment

Choose a reason for hiding this comment

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

LGTM

@g-votte g-votte merged commit 1d90822 into master Dec 26, 2018
@g-votte g-votte deleted the asha branch December 26, 2018 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Change that does not break compatibility, but affects the public interfaces.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants