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] Enable list of tuning hyperparameters in BOHB #14487

Merged
merged 6 commits into from Mar 12, 2021
Merged

[tune] Enable list of tuning hyperparameters in BOHB #14487

merged 6 commits into from Mar 12, 2021

Conversation

ghost
Copy link

@ghost ghost commented Mar 4, 2021

Why are these changes needed?

BOHB can now deal with list (and dict) of hyperparameters.

Related issue number

Closes #14472

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Copy link
Member

@sumanthratna sumanthratna left a comment

Choose a reason for hiding this comment

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

Looks good! @richardliaw does this need a test?

python/ray/tune/suggest/bohb.py Outdated Show resolved Hide resolved
python/ray/tune/utils/util.py Show resolved Hide resolved
python/ray/tune/suggest/bohb.py Outdated Show resolved Hide resolved
python/ray/tune/utils/util.py Show resolved Hide resolved
@@ -298,6 +298,32 @@ def unflatten_dict(dt, delimiter="/"):
return out


def unflatten_list_dict(dt, delimiter="/"):
"""Unflatten nested dict and list."""
out_type = list if list(dt)[0].split(delimiter, 1)[0].isdigit() else dict
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 a comment explaining what this does and why we need it?

also, I think this will raise an error if dt is {3: "is an int"} because list(dt)[0] is an int, which doesn't have split

Copy link
Author

Choose a reason for hiding this comment

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

You are right! This will raise an error in your example.

But I think this function now is only for one purpose: correctly unflatten config. And as far as I know all the flattened config is a dict, and its keys are all str.
Therefore, your example may not appear. This will be confirmed (or not) by unit test.

Actually I think writing such a function with strong robustness isn't that easy. So I agree with adding a comment explaining what this does, especially its limitation. And perhaps we need to add more test?

Copy link
Author

Choose a reason for hiding this comment

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

I've added a comment in the latest commit :)

Raphael CHEN and others added 2 commits March 5, 2021 16:27
Co-authored-by: Sumanth Ratna <sumanthratna@gmail.com>
@ghost ghost requested a review from sumanthratna March 5, 2021 09:31
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.

Hi @RaphaelCS , thank you for this contribution! Could you add a couple unit tests in tune/tests/test_trainable_util::UnflattenDictTest ?

@ghost
Copy link
Author

ghost commented Mar 6, 2021

Hi @RaphaelCS , thank you for this contribution! Could you add a couple unit tests in tune/tests/test_trainable_util::UnflattenDictTest ?

Yes, I can try.

But I notice that Travis CI failed. We need to fix it first, right?
If it is, could anyone help me locate which test failed? (I'm not familiar with Travis CI 😢 ) I can also try to fix it if I know which test failed.

@richardliaw
Copy link
Contributor

richardliaw commented Mar 6, 2021 via email

@ghost
Copy link
Author

ghost commented Mar 6, 2021

Don’t worry, it’s an unrelated issue!

Ah, OK. So I'll try to add some unit tests in a few days 😄

@ghost ghost requested a review from richardliaw March 12, 2021 14:02
@richardliaw richardliaw merged commit c93961e into ray-project:master Mar 12, 2021
@ghost ghost deleted the bohb_config_list branch June 26, 2021 15:20
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] BOHB fails with list of tuning hyperparameters
2 participants