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

[tune] Implement BOHB #5382

Merged
merged 34 commits into from
Aug 13, 2019
Merged

[tune] Implement BOHB #5382

merged 34 commits into from
Aug 13, 2019

Conversation

lisadunlap
Copy link
Contributor

What do these changes do?

Added TuneBOHB (search), HyperBandForBOHB (early stopping), and an example.

Related issue number

Closes #5100

Linter

  • I've run scripts/format.sh to lint the changes in this PR.

@richardliaw richardliaw changed the title Bohb [tune] Implement BOHB Aug 6, 2019
@richardliaw richardliaw self-assigned this Aug 6, 2019

import ray
from ray.tune import Trainable, run, sample_from
from ray.tune.schedulers import TuneBOHB, HyperBandForBOHB
Copy link
Contributor

Choose a reason for hiding this comment

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

TuneBOHB should go to ray.tune.suggest

config_space,
max_concurrent=4,
# num_concurrent=100,
reward_attr="episode_reward_mean",
Copy link
Contributor

Choose a reason for hiding this comment

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

reward_attr => metric

@@ -0,0 +1,62 @@
import ray
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move this file to tune/suggest?

and add the three __future__ imports to the top?

self.paused = set()
self.reward_attr = reward_attr
bohb_config = bohb_config or {}
self.bohber = BOHB(space, **bohb_config)
Copy link
Contributor

Choose a reason for hiding this comment

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

oh, we need to import BOHB from HpBandSter

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16023/
Test PASSed.

@meyerzinn
Copy link

How much more needs to be done before this can be merged? Seems almost complete and it's a major feature to be missing. I'm willing to help if needed. @lisadunlap


.. code-block:: python

tune.run(... , search_alg=TuneBOHB(config_space, ... ))
Copy link
Contributor

Choose a reason for hiding this comment

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

you also need HyperBand right?

from ray.tune.suggest import SuggestionAlgorithm


class BOHB(base_config_generator):
Copy link
Contributor

Choose a reason for hiding this comment

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

ah sorry, I meant “importing BOHB from hpbandster” is ideal

@@ -181,6 +182,30 @@ An example of this can be found in `ax_example.py <https://github.com/ray-projec
:show-inheritance:
:noindex:

BOHB (Bayesian optimization and Hyperband)
---------------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

should align with the above string

from __future__ import division
from __future__ import print_function

from hpbandster import BOHB
Copy link
Contributor

Choose a reason for hiding this comment

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

can you do a soft import here? like in suggest/ax.py; and correspondingly raise an error in init if not found?

self.running.add(trial_id)
if "budget" in result.get("hyperband_info", {}):
hbs_wrapper = self.to_wrapper(trial_id, result)
print("adding new result", vars(hbs_wrapper))
Copy link
Contributor

Choose a reason for hiding this comment

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

can you remove this?

elif trial_id in self.running:
self.running.remove(trial_id)
else:
import ipdb; ipdb.set_trace()
Copy link
Contributor

Choose a reason for hiding this comment

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

can you remove this?

class HyperBandForBOHB(HyperBandScheduler):
"""Implements the HyperBand early stopping algorithm.

@!!!!!!!!!!!!!! Key changes:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@!!!!!!!!!!!!!! Key changes:
Key changes:



class HyperBandForBOHB(HyperBandScheduler):
"""Implements the HyperBand early stopping algorithm.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Implements the HyperBand early stopping algorithm.
"""Extends HyperBand early stopping algorithm for BOHB.

print(Counter([status for _, status in statuses]))
trial_runner._search_alg.on_pause(trial.trial_id)
return TrialScheduler.PAUSE
# import ipdb; ipdb.set_trace()
Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

if not bracket.filled() or any(
status != Trial.PAUSED for t, status in statuses
if t is not trial):
print(Counter([status for _, status in statuses]))
Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

bracket.cleanup_full(trial_runner)
return TrialScheduler.STOP

good, bad = bracket.successive_halving(self._reward_attr)
Copy link
Contributor

Choose a reason for hiding this comment

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

there's no more _reward_attr, so this should be _metric. HyperBand also takes in a mode from its superclass, so I think we just need to do the negation here or something.

Copy link
Contributor

@richardliaw richardliaw left a comment

Choose a reason for hiding this comment

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

Nice! Two last things (in addition to above comments):

Can you add bohb_example as a line in ray/ci/jenkins_tests/run_tune_tests.sh with --smoke-test?

Can you run scripts/format.sh? You'll need flake8 and yapf==0.23.0 and flake8-quotes. This will run formatting.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16219/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16222/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16225/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16229/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16231/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16230/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16232/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16233/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16235/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16238/
Test FAILed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16247/
Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16254/
Test PASSed.

@richardliaw richardliaw merged commit b7d0733 into ray-project:master Aug 13, 2019
@richardliaw
Copy link
Contributor

@20zinnm thanks for offering! This is now merged. Could you try it out and let us know how it goes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[tune] Implement BOHB
4 participants