Skip to main content

Distributed Hyperparameter Optimization on SageMaker

Project description

Syne Tune: Large-Scale and Reproducible Hyperparameter Optimization

Release Python Version License Downloads

Alt Text

This package provides state-of-the-art distributed hyperparameter optimizers (HPO) with the following key features:

  • wide coverage (>20) of different HPO methods for asynchronous optimization with multiple workers, including:
    • advanced multi-fidelity methods supporting model-based decisions (BOHB and MOBSTER)
    • transfer-learning optimizers that achieve better and better performance when used repeatedly
    • multi-objective optimizers that can tune multiple objectives simultaneously (such as accuracy and latency)
  • you can run HPO in different environments (locally, AWS, simulation) by changing one line of code
  • out-of-the-box tabulated benchmarks available for several domains with efficient simulations that allows you to get results in seconds while preserving the real dynamics of asynchronous or synchronous HPO with any number of workers

Installing

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

pip install 'syne-tune[extra]==0.3.0'

or to get the latest version from git:

pip install --upgrade pip
git clone https://github.com/awslabs/syne-tune.git
cd syne-tune
pip install -e '.[extra]'

You can see the FAQ What are the different installations options supported? for more install options.

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

# train_height.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('--steps', 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.steps):
        dummy_score = (0.1 + args.width * step / 100) ** (-1) + args.height * 0.1
        # Feed the score back to Syne Tune.
        report(step=step, mean_loss=dummy_score, epoch=step + 1)
        time.sleep(0.1)

Once you have a script reporting metric, you can launch a tuning as-follow:

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 = {
    'steps': 100,
    'width': randint(1, 20),
    'height': randint(1, 20),
}

tuner = Tuner(
    trial_backend=LocalBackend(entry_point='train_height.py'),
    scheduler=ASHA(
        config_space, metric='mean_loss', resource_attr='epoch', max_t=100,
        search_options={'debug_log': False},
    ),
    stop_criterion=StoppingCriterion(max_wallclock_time=15),
    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.

Examples

You will find the following examples in examples/ folder illustrating different functionalities provided by Syne Tune:

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.

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={First Conference on Automated Machine Learning (Main Track)},
  year={2022},
  url={https://openreview.net/forum?id=BVeGJ-THIg9}
}

License

This project is licensed under the Apache-2.0 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

syne_tune-0.3.2.tar.gz (361.8 kB view hashes)

Uploaded Source

Built Distribution

syne_tune-0.3.2-py3-none-any.whl (537.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page