[tune] Search alg checkpointing during training (#9803)

Co-authored-by: krfricke <krfricke@users.noreply.github.com>
This commit is contained in:
Richard Liaw
2020-08-03 15:07:31 -07:00
committed by GitHub
co-authored by krfricke
parent db09f70315
commit c6404e8cf6
11 changed files with 320 additions and 45 deletions
+56 -2
View File
@@ -72,6 +72,54 @@ Tune also provides helpful utilities to use with Search Algorithms:
* :ref:`repeater`: Support for running each *sampled hyperparameter* with multiple random seeds.
* :ref:`limiter`: Limits the amount of concurrent trials when running optimization.
Saving and Restoring
--------------------
Certain search algorithms have ``save/restore`` implemented,
allowing reuse of learnings across multiple tuning runs.
.. code-block:: python
search_alg = HyperOptSearch()
experiment_1 = tune.run(
trainable,
search_alg=search_alg)
search_alg.save("./my-checkpoint.pkl")
# Restore the saved state onto another search algorithm
search_alg2 = HyperOptSearch()
search_alg2.restore("./my-checkpoint.pkl")
experiment_2 = tune.run(
trainable,
search_alg=search_alg2)
Further, Tune automatically saves its state inside the current experiment folder ("Result Dir") during tuning.
Note that if you have two Tune runs with the same experiment folder,
the previous state checkpoint will be overwritten. You can
avoid this by making sure ``tune.run(name=...)`` is set to a unique
identifier.
.. code-block:: python
search_alg = HyperOptSearch()
experiment_1 = tune.run(
cost,
num_samples=5,
search_alg=search_alg,
verbose=0,
name="my-experiment-1",
local_dir="~/my_results")
search_alg2 = HyperOptSearch()
search_alg2.restore_from_dir(
os.path.join("~/my_results", "my-experiment-1"))
.. note:: This is currently not implemented for: AxSearch, TuneBOHB, SigOptSearch, and DragonflySearch.
.. _tune-ax:
@@ -87,6 +135,7 @@ Bayesian Optimization (tune.suggest.bayesopt.BayesOptSearch)
.. autoclass:: ray.tune.suggest.bayesopt.BayesOptSearch
:members: save, restore
.. _`BayesianOptimization search space specification`: https://github.com/fmfn/BayesianOptimization/blob/master/examples/advanced-tour.ipynb
@@ -115,6 +164,7 @@ Dragonfly (tune.suggest.dragonfly.DragonflySearch)
--------------------------------------------------
.. autoclass:: ray.tune.suggest.dragonfly.DragonflySearch
:members: save, restore
.. _tune-hyperopt:
@@ -122,6 +172,7 @@ HyperOpt (tune.suggest.hyperopt.HyperOptSearch)
-----------------------------------------------
.. autoclass:: ray.tune.suggest.hyperopt.HyperOptSearch
:members: save, restore
.. _nevergrad:
@@ -129,6 +180,7 @@ Nevergrad (tune.suggest.nevergrad.NevergradSearch)
--------------------------------------------------
.. autoclass:: ray.tune.suggest.nevergrad.NevergradSearch
:members: save, restore
.. _`Nevergrad README's Optimization section`: https://github.com/facebookresearch/nevergrad/blob/master/docs/optimization.rst#choosing-an-optimizer
@@ -147,6 +199,7 @@ Scikit-Optimize (tune.suggest.skopt.SkOptSearch)
------------------------------------------------
.. autoclass:: ray.tune.suggest.skopt.SkOptSearch
:members: save, restore
.. _`skopt Optimizer object`: https://scikit-optimize.github.io/#skopt.Optimizer
@@ -156,6 +209,7 @@ ZOOpt (tune.suggest.zoopt.ZOOptSearch)
--------------------------------------
.. autoclass:: ray.tune.suggest.zoopt.ZOOptSearch
:members: save, restore
.. _repeater:
@@ -188,8 +242,8 @@ Use ``ray.tune.suggest.ConcurrencyLimiter`` to limit the amount of concurrency w
.. _byo-algo:
Implementing your own Search Algorithm
--------------------------------------
Custom Search Algorithms (tune.suggest.Searcher)
------------------------------------------------
If you are interested in implementing or contributing a new Search Algorithm, provide the following interface: