-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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] [PBT] [Doc] Add example PBT notebook #28519
Conversation
Signed-off-by: Justin Yu <justinvyu@berkeley.edu> Add missing logging logic from previous commit Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu> Add missing resample operation log Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
…example_notebook
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
…ons` Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
…example_notebook
94c5388
to
d5f6357
Compare
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
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.
Thanks so much!
This looks great! Only some nits..
python/ray/tune/schedulers/pbt.py
Outdated
custom_explore_fn: Optional[Callable], | ||
) -> Dict: | ||
) -> Tuple[Dict, Dict]: | ||
"""Return a config perturbed as specified. |
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.
update?
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.
What should be updated? The return type should be updated already.
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.
there is also operations
returned.
Example of using a Trainable function with HyperBandScheduler. | ||
Also uses the AsyncHyperBandScheduler. | ||
- :doc:`/tune/examples/pbt_visualization/pbt_visualization`: | ||
Configuring and running PBT and understanding the underlying algorithm behavior with a simple example. |
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.
mention this is to illustrate synchronous pbt?
…nd make runnable via colab Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
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.
Amazing tutorial and changes! Just two minor nits.
cc @maxpumperla for docs approval (incl. structure)
new_config[key] = distribution[ | ||
min(len(distribution) - 1, distribution.index(config[key]) + 1) | ||
] | ||
shift = random.choice([-1, 1]) |
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.
Can we add a comment here that explains what we're doing?
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.
Generally, let's add a few comments for this whole exploration block
python/ray/tune/schedulers/pbt.py
Outdated
new_idx = distribution.index(config[key]) + shift | ||
new_idx = min(max(new_idx, 0), len(distribution) - 1) | ||
new_config[key] = distribution[new_idx] | ||
operations[key] = f"shift {'left' if shift == -1 else 'right'}" |
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.
Should this be "shift left (noop)" or similar if old_idx == new_idx? E.g. when we select shift = -1 when we're already at the first item
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.
Right, this should include some indicator that we've hit the end of the list.
A few thoughts on this actually:
- We might want to just wrap around from the end if trying to shift left at the first item. The fact that we don't wrap implies some kind of ordering to the items, but there is no guarantee there. Example:
"a": [100, 1, 50, 75]
75 <- (shift left & wrap around) -- 100 -- (shift right) -> 1
- Seems arbitrary why 100 can only be perturbed to the right.
- Should a
noop
be an option here rather than always shifting left and right? SHERPA's implementation includes a "no shift" option.
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.
Hm what does the original paper say?
Everything else seems to have an option not to shift, so I actually believe just going with [-1, 0, 1] should be fine.
For wrapping around, basically a matter of preference. Best would be to distinguish between ordinal and categorical, but since we don't have this, I'd say let's assume ordinal and leave the logic as is
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.
-
The original paper doesn't really mention specifics on perturb, so I think adding the no-shift makes sense to align with other implementations.
-
I see, can leave this for a PR in the future.
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Signed-off-by: Justin Yu <justinvyu@berkeley.edu>
Follow-up to #28519, fixing the hierarchy to match the hierarchy contained within the pages. Also moved MLFlow from ML Framework Examples to Experiment Tracking Examples Signed-off-by: Matthew Deng <matt@anyscale.com>
See [here](https://colab.research.google.com/github/justinvyu/ray/blob/pbt_example_notebook/doc/source/tune/examples/pbt_visualization/pbt_visualization.ipynb) for a Colab version of the notebook! Some images are missing that would show up in the Ray docs once merged. The purpose of the example is to help new users understand what PBT is doing under the hood, and provide an example of using PBT with a function trainable. The notebook gives recommendations on how to set PBT-specific parameters such as `perturbation_interval` and how to perform checkpointing alongside PBT. The example notebook replicates an experiment found in the [original PBT paper](https://arxiv.org/pdf/1711.09846.pdf). The toy example in the paper is a good way of verifying that PBT behavior is correct (trials are being correctly exploited and the correct checkpoints are being used). Signed-off-by: Justin Yu <justinvyu@berkeley.edu> Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Follow-up to ray-project#28519, fixing the hierarchy to match the hierarchy contained within the pages. Also moved MLFlow from ML Framework Examples to Experiment Tracking Examples Signed-off-by: Matthew Deng <matt@anyscale.com> Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Summary
Example notebook
See here for a Colab version of the notebook! Some images are missing that would show up in the Ray docs once merged.
The purpose of the example is to help new users understand what PBT is doing under the hood, and provide an example of using PBT with a function trainable. The notebook gives recommendations on how to set PBT-specific parameters such as
perturbation_interval
and how to perform checkpointing alongside PBT.The example notebook replicates an experiment found in the original PBT paper. The toy example in the paper is a good way of verifying that PBT behavior is correct (trials are being correctly exploited and the correct checkpoints are being used).
Notebook plots
Figure in paper
PBT logging enhancements
This PR also includes some quality of life improvements to PBT logging that makes it easier to understand what is happening.
Example:
The above hyperparameter mutations config results in the following log after the PBT explore step:
Some docs restructuring
I also took the chance to nest some Tune examples in sub-sections, since there were a lot of frameworks specific examples that were overloading the table of contents.
Related PRs
This test helped uncover some bugs fixed in the following PRs:
Trial
/TrialRunner
state when pausing and resuming trial #28511Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.