Home

Awesome

Syne Tune: Large-Scale and Reproducible Hyperparameter Optimization

release License Downloads Documentation Python Version codecov.io

Syne Tune

Documentation | Tutorials | API Reference | PyPI | Latest Blog Post | Discord

Syne Tune provides state-of-the-art algorithms for hyperparameter optimization (HPO) with the following key features:

Syne Tune is developed in collaboration with the team behind the Automatic Model Tuning service.

Installing

To install Syne Tune from pip, you can simply do:

pip install 'syne-tune[basic]'

or to install the latest version from source:

git clone https://github.com/awslabs/syne-tune.git
cd syne-tune
python3 -m venv st_venv
. st_venv/bin/activate
pip install --upgrade pip
pip install -e '.[basic]'

This installs everything in a virtual environment st_venv. Remember to activate this environment before working with Syne Tune. We also recommend building the virtual environment from scratch now and then, in particular when you pull a new release, as dependencies may have changed.

See our change log to see what changed in the latest version.

Getting started

To enable tuning, you have to report metrics from a training script so that they can be communicated later to Syne Tune, this can be accomplished by just calling report(epoch=epoch, loss=loss) as shown in the example below:

# train_height_simple.py
import logging
import time

from syne_tune import Reporter
from argparse import ArgumentParser

if __name__ == '__main__':
    root = logging.getLogger()
    root.setLevel(logging.INFO)
    parser = ArgumentParser()
    parser.add_argument('--epochs', type=int)
    parser.add_argument('--width', type=float)
    parser.add_argument('--height', type=float)
    args, _ = parser.parse_known_args()
    report = Reporter()
    for step in range(args.epochs):
        time.sleep(0.1)
        dummy_score = 1.0 / (0.1 + args.width * step / 100) + args.height * 0.1
        # Feed the score back to Syne Tune.
        report(epoch=step + 1, mean_loss=dummy_score)

Once you have a training script reporting a metric, you can launch a tuning as follows:

# launch_height_simple.py
from syne_tune import Tuner, StoppingCriterion
from syne_tune.backend import LocalBackend
from syne_tune.config_space import randint
from syne_tune.optimizer.baselines import ASHA

# hyperparameter search space to consider
config_space = {
    'width': randint(1, 20),
    'height': randint(1, 20),
    'epochs': 100,
}

tuner = Tuner(
    trial_backend=LocalBackend(entry_point='train_height_simple.py'),
    scheduler=ASHA(
        config_space,
        metric='mean_loss',
        resource_attr='epoch',
        max_resource_attr="epochs",
        search_options={'debug_log': False},
    ),
    stop_criterion=StoppingCriterion(max_wallclock_time=30),
    n_workers=4,  # how many trials are evaluated in parallel
)
tuner.run()

The above example runs ASHA with 4 asynchronous workers on a local machine.

Experimentation with Syne Tune

If you plan to use advanced features of Syne Tune, such as different execution backends or running experiments remotely, writing launcher scripts like examples/launch_height_simple.py can become tedious. Syne Tune provides an advanced experimentation framework, which you can learn about in this tutorial or also in this one.

Supported HPO methods

The following hyperparameter optimization (HPO) methods are available in Syne Tune:

MethodReferenceSearcherAsynchronous?Multi-fidelity?Transfer?
Grid Searchdeterministicyesnono
Random SearchBergstra, et al. (2011)randomyesnono
Bayesian OptimizationSnoek, et al. (2012)model-basedyesnono
BORETiao, et al. (2021)model-basedyesnono
CQRSalinas, et al. (2023)model-basedyesnono
MedianStoppingRuleGolovin, et al. (2017)anyyesyesno
SyncHyperbandLi, et al. (2018)randomnoyesno
SyncBOHBFalkner, et al. (2018)model-basednoyesno
SyncMOBSTERKlein, et al. (2020)model-basednoyesno
ASHALi, et al. (2019)randomyesyesno
BOHBFalkner, et al. (2018)model-basedyesyesno
MOBSTERKlein, et al. (2020)model-basedyesyesno
DEHBAwad, et al. (2021)evolutionarynoyesno
HyperTuneLi, et al. (2022)model-basedyesyesno
DyHPO<sup>*</sup>Wistuba, et al. (2022)model-basedyesyesno
ASHABORETiao, et al. (2021)model-basedyesyesno
ASHACQRSalinas, et al. (2023)model-basedyesyesno
PASHABohdal, et al. (2022)random or model-basedyesyesno
REAReal, et al. (2019)evolutionaryyesnono
KDEFalkner, et al. (2018)model-basedyesnono
PBTJaderberg, et al. (2017)evolutionarynoyesno
ZeroShotTransferWistuba, et al. (2015)deterministicyesnoyes
ASHA-CTSSalinas, et al. (2021)randomyesyesyes
RUSHZappella, et al. (2021)randomyesyesyes
BoundingBoxPerrone, et al. (2019)anyyesyesyes

<sup>*</sup>: We implement the model-based scheduling logic of DyHPO, but use the same Gaussian process surrogate models as MOBSTER and HyperTune. The original source code for the paper is here.

The searchers fall into four broad categories, deterministic, random, evolutionary and model-based. The random searchers sample candidate hyperparameter configurations uniformly at random, while the model-based searchers sample them non-uniformly at random, according to a model (e.g., Gaussian process, density ration estimator, etc.) and an acquisition function. The evolutionary searchers make use of an evolutionary algorithm.

Syne Tune also supports BoTorch searchers.

Supported multi-objective optimization methods

MethodReferenceSearcherAsynchronous?Multi-fidelity?Transfer?
Constrained Bayesian OptimizationGardner, et al. (2014)model-basedyesnono
MOASHASchmucker, et al. (2021)randomyesyesno
NSGA-2Deb, et al. (2002)evolutionarynonono
Multi Objective Multi Surrogate (MSMOS)Guerrero-Viu, et al. (2021)model-basednonono
MSMOS with random scalarizationParia, et al. (2018)model-basednonono

HPO methods listed can be used in a multi-objective setting by scalarization or non-dominated sorting. See multiobjective_priority.py for details.

Examples

You will find many examples in the examples/ folder illustrating different functionalities provided by Syne Tune. For example:

Examples for Experimentation and Benchmarking

You will find many examples for experimentation and benchmarking in benchmarking/examples/ and in benchmarking/nursery/.

FAQ and Tutorials

You can check our FAQ, to learn more about Syne Tune functionalities.

Do you want to know more? Here are a number of tutorials.

Blog Posts

Videos

Security

See CONTRIBUTING for more information.

Citing Syne Tune

If you use Syne Tune in a scientific publication, please cite the following paper:

"Syne Tune: A Library for Large Scale Hyperparameter Tuning and Reproducible Research" First Conference on Automated Machine Learning, 2022.

@inproceedings{
  salinas2022syne,
  title={Syne Tune: A Library for Large Scale Hyperparameter Tuning and Reproducible Research},
  author={David Salinas and Matthias Seeger and Aaron Klein and Valerio Perrone and Martin Wistuba and Cedric Archambeau},
  booktitle={International Conference on Automated Machine Learning, AutoML 2022},
  year={2022},
  url={https://proceedings.mlr.press/v188/salinas22a.html}
}

License

This project is licensed under the Apache-2.0 License.