Skip to main content

Distributed hyperparameter optimization made easy

Project description

optuna-distributed

An extension to Optuna which makes distributed hyperparameter optimization easy, and keeps all of the original Optuna semantics. Optuna-distributed can run locally, by default utilising all CPU cores, or can easily scale to many machines in Dask cluster.

Note

Optuna-distributed is still in the early stages of development. While core Optuna functionality is supported, few missing APIs (especially around Optuna integrations) might prevent this extension from being entirely plug-and-play for some users. Bug reports, feature requests and PRs are more than welcome.

Features

  • Asynchronous optimization by default. Scales from single machine to many machines in cluster.
  • Distributed study walks and quacks just like regular Optuna study, making it plug-and-play.
  • Compatible with all standard Optuna storages, samplers and pruners.
  • No need to modify existing objective functions.

Installation

pip install optuna-distributed

Optuna-distributed requires Python 3.7 or newer.

Basic example

Optuna-distributed wraps standard Optuna study. The resulting object behaves just like regular study, but optimization process is asynchronous. Depending on setup of Dask client, each trial is scheduled to run on available CPU core on local machine, or physical worker in cluster.

Note

Running distributed optimization requires a Dask cluster with environment closely matching one on the client machine. For more information on cluster setup and configuration, please refer to https://docs.dask.org/en/stable/deploying.html.

import random
import time

import optuna
import optuna_distributed
from dask.distributed import Client


def objective(trial):
    x = trial.suggest_float("x", -100, 100)
    y = trial.suggest_categorical("y", [-1, 0, 1])
    # Some expensive model fit happens here...
    time.sleep(random.uniform(1.0, 2.0))
    return x**2 + y


if __name__ == "__main__":
    # client = Client("<your.cluster.scheduler.address>")  # Enables distributed optimization.
    client = None  # Enables local asynchronous optimization.
    study = optuna_distributed.from_study(optuna.create_study(), client=client)
    study.optimize(objective, n_trials=10)
    print(study.best_value)

But there's more! All of the core Optuna APIs, including storages, samplers and pruners are supported!

What's missing?

  • Support for callbacks and Optuna integration modules.
  • Study APIs such as study.stop can't be called from trial at the moment.

Download files

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

Source Distribution

optuna-distributed-0.2.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

optuna_distributed-0.2.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file optuna-distributed-0.2.0.tar.gz.

File metadata

  • Download URL: optuna-distributed-0.2.0.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for optuna-distributed-0.2.0.tar.gz
Algorithm Hash digest
SHA256 83fc2a6406508b2ef5e6aa48238cf6d60979caf55ee87113e0500d177bb7f92a
MD5 9eb3a25f710e394e7a1418528a2eb9fb
BLAKE2b-256 e47991f6eba9e1b58141bec75c2ac312dae6c4ead6e26084313a03e33b495793

See more details on using hashes here.

File details

Details for the file optuna_distributed-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for optuna_distributed-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 982e84f242c008688dffaf687cd9348fbc43d47cf8a634cced81fcda01454333
MD5 8b74c5c9304bf7d31a66f342a0dcbce6
BLAKE2b-256 a1f8bb87e7fb110cf98740dbedfd43fb5a26dff8ea365b775e244e85103b80a8

See more details on using hashes here.

Supported by

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