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.8 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! If you'd like to know how Optuna-distributed works, then check out this article on Optuna blog.
What's missing?
- Support for callbacks and Optuna integration modules.
- Study APIs such as
study.stopcan't be called from trial at the moment. - Local asynchronous optimization on Windows machines. Distributed mode is still available.
- Support for
optuna.terminator.
Metadata
Release files for optuna-distributed 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| optuna_distributed-0.7.0.tar.gz | 31.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| optuna_distributed-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.2 kB
Release files / optuna_distributed-0.7.0.tar.gz
| Download URL | optuna_distributed-0.7.0.tar.gz |
|---|---|
| Size | 31.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c89af5811787eaf649bb9fb9eea6fe3325e8e5ead4dc2435e58d8d3c90888e4
|
|
BLAKE2b-256 checksum How to use checksums |
8482fe8a2a4ea234d09e8fe0e819d2c8ebe5cffb8412c5655dba108f40fd964f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|
Release files / optuna_distributed-0.7.0-py3-none-any.whl
| Download URL | optuna_distributed-0.7.0-py3-none-any.whl |
|---|---|
| Size | 30.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7165b79fbd353c61424565d381d0e8cee3dab0fe9a32f3b40704da7fdafeb102
|
|
BLAKE2b-256 checksum How to use checksums |
f1241f7abf13947fe5db9e077a2054f827028262866ae76e26f79055dbe64e17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|
Security for optuna-distributed 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.