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

[air] add tuner user guide #26837

Merged
merged 30 commits into from
Aug 3, 2022
Merged

Conversation

xwjiang2010
Copy link
Contributor

@xwjiang2010 xwjiang2010 commented Jul 21, 2022

Why are these changes needed?

User guide for Tuner on the Ray AIR docs.

Related issue number

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 :(

Signed-off-by: Xiaowei Jiang <xwjiang2010@gmail.com>
Signed-off-by: Xiaowei Jiang <xwjiang2010@gmail.com>
Signed-off-by: Xiaowei Jiang <xwjiang2010@gmail.com>
Signed-off-by: Xiaowei Jiang <xwjiang2010@gmail.com>
Signed-off-by: Xiaowei Jiang <xwjiang2010@gmail.com>
Signed-off-by: Xiaowei Jiang <xwjiang2010@gmail.com>

Hyperparameter Tuning
=====================
Tuner API is the recommended way of launching hyperparameter tuning jobs with Ray Tune.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add "what is a tuner and what does it do"?

doc/source/ray-air/user-guides.rst Outdated Show resolved Hide resolved
doc/source/_toc.yml Outdated Show resolved Hide resolved
@richardliaw richardliaw added this to the AIR 2.0 docs milestone Jul 27, 2022
Kai Fricke added 4 commits July 29, 2022 12:41
# Conflicts:
#	doc/source/_toc.yml
Signed-off-by: Kai Fricke <kai@anyscale.com>
Signed-off-by: Kai Fricke <kai@anyscale.com>
Signed-off-by: Kai Fricke <kai@anyscale.com>
Copy link
Contributor

@krfricke krfricke left a comment

Choose a reason for hiding this comment

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

LGTM let's follow up with the restore docs soon.

Also cc @richardliaw for review

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.

looking good; just a couple comments.

doc/source/ray-air/doc_code/tuner.py Outdated Show resolved Hide resolved

# Create Tuner
tuner = tune.Tuner(
my_trainer,
Copy link
Contributor

Choose a reason for hiding this comment

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

how about lets use a real trainer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's covered in the following torch/xgboost sessions.

doc/source/ray-air/tuner.rst Outdated Show resolved Hide resolved
doc/source/ray-air/tuner.rst Outdated Show resolved Hide resolved
doc/source/ray-air/tuner.rst Outdated Show resolved Hide resolved
doc/source/ray-air/tuner.rst Outdated Show resolved Hide resolved
doc/source/ray-air/tuner.rst Outdated Show resolved Hide resolved
doc/source/ray-air/tuner.rst Outdated Show resolved Hide resolved
``num_samples=2`` here will be applied to the whole suite of grid search. In other words,
we will generate 4 trials.

For a more end-to-end example, checkout our :doc:`/ray-air/examples/analyze_tuning_results` guide.
Copy link
Contributor

Choose a reason for hiding this comment

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

This guide only for analysis right?

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to link out to Ray Tune user guide instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is actually an end to end example of Tuner. The title is a bit misleading.

doc/source/ray-air/tuner.rst Outdated Show resolved Hide resolved
Signed-off-by: xwjiang2010 <xwjiang2010@gmail.com>
There are a couple gotchas about parameter specification when using Tuners with Trainers:

- By default, configuration dictionaries and config objects will be deep-merged
- Parameters that are duplicated in the Trainer and Tuner will be overwritten by the Tuner ``param_space``
Copy link
Contributor

Choose a reason for hiding this comment

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

param-space.

- **Exception:** all arguments of the :class:`RunConfig <ray.air.config.RunConfig>` and :class:`TuneConfig <ray.tune.tune_config.TuneConfig>` are inherently un-tunable.


How to configure a Tuner
Copy link
Contributor

Choose a reason for hiding this comment

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

How to configure a Tuner?

- custom callbacks
- integration with cloud storage

The following we showcase some common configuration of :class:`RunConfig <ray.air.config.RunConfig>`.
Copy link
Contributor

Choose a reason for hiding this comment

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

In the following section, we cover and showcase some common ...

:end-before: __basic_end__


How do I configure a search space?
Copy link
Contributor

Choose a reason for hiding this comment

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

How to configure a search space?

I would leave out first person I here.

See the :class:`RunConfig API reference <ray.air.config.RunConfig>` for more details.


How do I specify parallelism?
Copy link
Contributor

Choose a reason for hiding this comment

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

How to configure parallelism?

Read more about this in :ref:`tune-parallelism` section.


How do I specify an optimization algorithm?
Copy link
Contributor

Choose a reason for hiding this comment

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

How to specify an optimization algorithm?

How to analyze results?
-----------------------

``Tuner.fit()`` generates a ResultGrid object. This object contains metrics, results, and checkpoints
Copy link
Contributor

Choose a reason for hiding this comment

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

ResultGrid

-----------------------

``Tuner.fit()`` generates a ResultGrid object. This object contains metrics, results, and checkpoints
of each trial. Below is a simple usage example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Below is a simple example:

Advanced Tuning
---------------

Tuners also offer the possibility to apply different data preprocessing steps, as shown in the following snippet.
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be the "capability" instead of "possibility"?

:start-after: __tune_preprocess_start__
:end-before: __tune_preprocess_end__

You can also sample different train/validation datasets:
Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, you sample different ...

Additionally, if trials fail during a tuning run, they can be retried - either from scratch or
from the latest available checkpoint.

To restore the Tuner state, you just pass the path to the experiment directory to ``Tuner.restore()``.
Copy link
Contributor

Choose a reason for hiding this comment

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

To restore the Tuner state, pass the path to the experiment directory as an argument to Tuner.restore(...)


To restore the Tuner state, you just pass the path to the experiment directory to ``Tuner.restore()``.

This path can be obtained e.g. from the output of a tuning run (it's called "Result logdir"). If you
Copy link
Contributor

Choose a reason for hiding this comment

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

This path is obtained from the output of a tuning run, namely "Result logdir." However, if you specify a name in the :class:RunConfig <ray.air.config.RunConfig>, then it is located under ~/ray_results/<name>.

Copy link
Contributor

@dmatrix dmatrix left a comment

Choose a reason for hiding this comment

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

I'm bit confused about the diagram. Why it has Two boxes named "Trainer." We may want to clarify that in the caption.

Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
@richardliaw
Copy link
Contributor

@dmatrix addressed comments!

Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
@krfricke krfricke self-assigned this Aug 3, 2022
@richardliaw richardliaw changed the title [air] add tuner user guide. [air] add tuner user guide Aug 3, 2022
@richardliaw richardliaw merged commit ff2b728 into ray-project:master Aug 3, 2022
xwjiang2010 added a commit to xwjiang2010/ray that referenced this pull request Aug 3, 2022
Co-authored-by: Kai Fricke <kai@anyscale.com>
Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
scv119 pushed a commit that referenced this pull request Aug 4, 2022
Co-authored-by: Kai Fricke <kai@anyscale.com>
Co-authored-by: Richard Liaw <rliaw@berkeley.edu>

Co-authored-by: Kai Fricke <kai@anyscale.com>
Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 2022
Co-authored-by: Kai Fricke <kai@anyscale.com>
Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Stefan van der Kleij <s.vanderkleij@viroteq.com>
@xwjiang2010 xwjiang2010 deleted the tune-doc branch July 26, 2023 19:55
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.

6 participants