2019-09-04 12:44:42 -07:00
Tune: A Scalable Hyperparameter Tuning Library
==============================================
.. important :: Take the 3 minute `2019 Ray Tune User Survey <https://forms.gle/7u5eH1avbTfpZ3dE6> `_ !
2017-11-23 11:31:59 -08:00
2018-08-19 11:00:55 -07:00
.. image :: images/tune.png
:scale: 30%
:align: center
2018-04-17 09:57:35 -07:00
2019-09-04 12:44:42 -07:00
Tune is a Python library for hyperparameter tuning at any scale. Core features:
2018-02-02 23:03:12 -08:00
2019-08-28 17:54:15 -07:00
* Launch a multi-node distributed hyperparameter sweep in less than 10 lines of code.
2019-09-04 12:44:42 -07:00
* Supports any machine learning framework, including PyTorch, XGBoost, MXNet, and Keras.
2019-08-02 09:17:20 -07:00
* Visualize results with `TensorBoard <https://www.tensorflow.org/get_started/summaries_and_tensorboard> `__ .
* Choose among scalable SOTA algorithms such as `Population Based Training (PBT)`_ , `Vizier's Median Stopping Rule`_ , `HyperBand/ASHA`_ .
2019-08-28 17:54:15 -07:00
* Tune integrates with many optimization libraries such as `Facebook Ax <http://ax.dev> `_ , `HyperOpt <https://github.com/hyperopt/hyperopt> `_ , and `Bayesian Optimization <https://github.com/fmfn/BayesianOptimization> `_ and enables you to scale them transparently.
2018-11-08 23:45:05 -08:00
2019-08-02 09:17:20 -07:00
.. _`Population Based Training (PBT)`: tune-schedulers.html#population-based-training-pbt
.. _`Vizier's Median Stopping Rule`: tune-schedulers.html#median-stopping-rule
.. _`HyperBand/ASHA`: tune-schedulers.html#asynchronous-hyperband
2018-11-08 23:45:05 -08:00
2019-09-04 12:44:42 -07:00
2019-08-02 09:17:20 -07:00
Quick Start
-----------
2018-04-17 09:57:35 -07:00
2019-08-02 09:17:20 -07:00
.. note ::
2018-03-19 12:55:10 -07:00
2019-08-02 09:17:20 -07:00
To run this example, you will need to install the following:
2018-03-19 12:55:10 -07:00
2019-08-02 09:17:20 -07:00
.. code-block :: bash
2018-03-19 12:55:10 -07:00
2019-08-02 09:17:20 -07:00
$ pip install ray torch torchvision filelock
2018-03-19 12:55:10 -07:00
2019-08-02 09:17:20 -07:00
This example runs a small grid search to train a CNN using PyTorch and Tune.
2018-03-19 12:55:10 -07:00
2019-08-02 09:17:20 -07:00
.. literalinclude :: ../../python/ray/tune/tests/example.py
:language: python
:start-after: __quick_start_begin__
:end-before: __quick_start_end__
2018-03-19 12:55:10 -07:00
2019-08-02 09:17:20 -07:00
If TensorBoard is installed, automatically visualize all trial results:
2018-03-19 12:55:10 -07:00
2019-08-02 09:17:20 -07:00
.. code-block :: bash
2018-03-19 12:55:10 -07:00
2019-08-02 09:17:20 -07:00
tensorboard --logdir ~/ray_results
2018-03-19 12:55:10 -07:00
2017-11-23 11:31:59 -08:00
2019-08-02 09:17:20 -07:00
.. image :: images/tune-start-tb.png
2017-11-23 11:31:59 -08:00
2019-08-02 09:17:20 -07:00
Distributed Quick Start
-----------------------
2018-08-04 21:27:39 -07:00
2019-08-02 09:17:20 -07:00
1. Import and initialize Ray by appending the following to your example script.
2018-04-17 09:57:35 -07:00
.. code-block :: python
2019-08-02 09:17:20 -07:00
# Append to top of your script
2018-04-17 09:57:35 -07:00
import ray
2019-08-02 09:17:20 -07:00
import argparse
2018-04-17 09:57:35 -07:00
2019-08-02 09:17:20 -07:00
parser = argparse.ArgumentParser()
2019-09-01 16:53:02 -07:00
parser.add_argument("--ray-address")
2019-08-02 09:17:20 -07:00
args = parser.parse_args()
2019-09-01 16:53:02 -07:00
ray.init(address=args.ray_address)
2018-04-17 09:57:35 -07:00
2019-08-02 09:17:20 -07:00
Alternatively, download a full example script here: :download: `mnist_pytorch.py <../../python/ray/tune/examples/mnist_pytorch.py>`
2018-01-25 16:39:00 -08:00
2019-08-08 00:59:23 -07:00
2. Download the following example Ray cluster configuration as `` tune-local-default.yaml `` and replace the appropriate fields:
.. literalinclude :: ../../python/ray/tune/examples/tune-local-default.yaml
:language: yaml
Alternatively, download it here: :download: `tune-local-default.yaml <../../python/ray/tune/examples/tune-local-default.yaml>` . See `Ray cluster docs here <autoscaling.html> `_ .
2019-08-02 09:17:20 -07:00
3. Run `` ray submit `` like the following.
2018-03-03 13:01:49 -08:00
2019-08-02 09:17:20 -07:00
.. code-block :: bash
2018-03-03 13:01:49 -08:00
2019-09-01 16:53:02 -07:00
ray submit tune-local-default.yaml mnist_pytorch.py --args="--ray-address=localhost:6379" --start
2018-03-03 13:01:49 -08:00
2019-08-08 00:59:23 -07:00
This will start Ray on all of your machines and run a distributed hyperparameter search across them.
2018-03-03 13:01:49 -08:00
2019-08-02 09:17:20 -07:00
To summarize, here are the full set of commands:
2018-02-12 14:01:19 -08:00
2019-08-02 09:17:20 -07:00
.. code-block :: bash
wget https://raw.githubusercontent.com/ray-project/ray/master/python/ray/tune/examples/mnist_pytorch.py
2019-08-08 00:59:23 -07:00
wget https://raw.githubusercontent.com/ray-project/ray/master/python/ray/tune/tune-local-default.yaml
2019-09-01 16:53:02 -07:00
ray submit tune-local-default.yaml mnist_pytorch.py --args="--ray-address=localhost:6379" --start
2019-08-08 00:59:23 -07:00
2018-02-12 14:01:19 -08:00
2019-08-08 00:59:23 -07:00
Take a look at the `Distributed Experiments <tune-distributed.html> `_ documentation for more details, including:
2018-02-12 14:01:19 -08:00
2019-08-08 00:59:23 -07:00
1. Setting up distributed experiments on your local cluster
2. Using AWS and GCP
3. Spot instance usage/pre-emptible instances, and more.
2019-08-02 09:17:20 -07:00
Getting Started
---------------
* `Code <https://github.com/ray-project/ray/tree/master/python/ray/tune> `__ : GitHub repository for Tune.
* `User Guide <tune-usage.html> `__ : A comprehensive overview on how to use Tune's features.
* `Tutorial Notebook <https://github.com/ray-project/tutorial/blob/master/tune_exercises/> `__ : Our tutorial notebooks of using Tune with Keras or PyTorch.
2018-01-24 13:45:10 -08:00
2019-05-05 00:04:13 -07:00
Contribute to Tune
------------------
Take a look at our `Contributor Guide <tune-contrib.html> `__ for guidelines on contributing.
2018-08-19 11:00:55 -07:00
Citing Tune
-----------
2018-01-24 13:45:10 -08:00
2018-08-19 11:00:55 -07:00
If Tune helps you in your academic research, you are encouraged to cite `our paper <https://arxiv.org/abs/1807.05118> `__ . Here is an example bibtex:
2018-01-24 13:45:10 -08:00
2018-08-19 11:00:55 -07:00
.. code-block :: tex
2018-01-24 13:45:10 -08:00
2018-08-19 11:00:55 -07:00
@article{liaw2018tune,
title={Tune: A Research Platform for Distributed Model Selection and Training},
author={Liaw, Richard and Liang, Eric and Nishihara, Robert
and Moritz, Philipp and Gonzalez, Joseph E and Stoica, Ion},
journal={arXiv preprint arXiv:1807.05118},
year={2018}
}
2018-01-24 13:45:10 -08:00
2018-04-17 09:57:35 -07:00
2018-08-19 11:00:55 -07:00
.. _HyperOpt with HyperBand: https://github.com/ray-project/ray/blob/master/python/ray/tune/examples/hyperopt_example.py
2019-02-12 11:00:04 -08:00
.. _Nevergrad with HyperBand: https://github.com/ray-project/ray/blob/master/python/ray/tune/examples/nevergrad_example.py