This is the release note of v4.1.0. Highlights of this release include:
- 🤖 AutoSampler: Automatic Selection of Optimization Algorithms
- 🚀 More scalable RDB Storage Backend
- 🧑💻 Five New Algorithms in OptunaHub (MO-CMA-ES, MOEA/D, etc.)
- 🐍 Support Python 3.13
The updated list of tested and supported Python releases is as follows:
- Optuna 4.1: supported by Python 3.8 - 3.13
- Optuna Integration 4.1: supported by Python 3.8 - 3.12
- Optuna Dashboard 0.17.0: supported by Python 3.8 - 3.13
Highlights
AutoSampler: Automatic Selection of Optimization Algorithms
AutoSampler automatically selects a sampler from those implemented in Optuna, depending on the situation. Using AutoSampler, as in the code example below, users can achieve optimization performance equal to or better than Optuna's default without being aware of which optimization algorithm to use.
$ pip install optunahub cmaes torch scipy
import optuna
import optunahub
auto_sampler_module = optunahub.load_module("samplers/auto_sampler")
study = optuna.create_study(sampler=auto_sampler_module.AutoSampler())
See the Medium blog post for details.
Enhanced RDB Storage Backend
This release incorporates comprehensive performance tuning on Optuna’s RDBStorage, leading to significant performance improvements. The table below shows the comparison results of execution times between versions 4.0 and 4.1.
# trials | v4.0.0 | v4.1.0 | Diff |
---|---|---|---|
1000 | 72.461 sec (±1.026) | 59.706 sec (±1.216) | -17.60% |
10000 | 1153.690 sec (±91.311) | 664.830 sec (±9.951) | -42.37% |
50000 | 12118.413 sec (±254.870) | 4435.961 sec (±190.582) | -63.39% |
For fair comparison, all experiments were repeated 10 times, and the mean execution time was compared. Additional detailed benchmark settings include the following:
- Objective Function: Each trial consists of 10 parameters and 10 user attributes
- Storage: MySQL 8.0 (with PyMySQL)
- Sampler: RandomSampler
- Execution Environment: Kubernetes Pod with 5 cpus and 8Gi RAM
Please note, due to extensive execution time, the figure for v4.0.0 with 50,000 trials represents the average of 7 runs instead of 10.
Benchmark Script
import optuna
import time
import os
import numpy as np
optuna.logging.set_verbosity(optuna.logging.ERROR)
storage_url = "mysql+pymysql://user:password@<ipaddr>:<port>/<dbname>"
n_repeat = 10
def objective(trial: optuna.Trial) -> float:
s = 0
for i in range(10):
trial.set_user_attr(f"attr{i}", "dummy user attribute")
s += trial.suggest_float(f"x{i}", -10, 10) ** 2
return s
def bench(n_trials):
elapsed = []
for i in range(n_repeat):
start = time.time()
study = optuna.create_study(
storage=storage_url,
sampler=optuna.samplers.RandomSampler()
)
study.optimize(objective, n_trials=n_trials, n_jobs=10)
elapsed.append(time.time() - start)
optuna.delete_study(study_name=study.study_name, storage=storage_url)
print(f"{np.mean(elapsed)=} {np.std(elapsed)=}")
for n_trials in [1000, 10000, 50000]:
bench(n_trials)
Five New Algorithms in OptunaHub (MO-CMA-ES, MOEA/D, etc.)
The following five new algorithms were added to OptunaHub!
- Multi-objective CMA-ES (MO-CMA-ES)by @y0z
- MOEA/D sampler by @hrntsm
- MAB Epsilon-Greedy Sampler by @ryota717
- NSGAII sampler with Initial Trials by @hrntsm
- CMA-ES with User Prior by @nabenabe0928
MO-CMA-ES is an extension of CMA-ES for multi-objective optimization. Its search mechanism is based on multiple (1+1)-CMA-ES and inherits good invariance properties from CMA-ES, such as invariance against rotation of the search space.
MOEA/D solves a multi-objective optimization problem by decomposing it into multiple single-objective problems. It allows for the maintenance of a good diversity of solutions during optimization. Please take a look at the article from Hiroaki NATSUME(@hrntsm) for more details.
Enhancements
- Update sklearn.py by addind catch to OptunaSearchCV (optuna/optuna-integration#163, thanks @muhlbach!)
- Reduce
SELECT
statements by passingstudy_id
tocheck_and_add
inTrialParamModel
(#5702) - Introduce
UPSERT
inset_trial_user_attr
(#5703) - Reduce
SELECT
statements of_CachedStorage.get_all_trials
by fixing filtering conditions (#5704) - Reduce
SELECT
statements by removing unnecessary distribution compatibility check inset_trial_param()
(#5709) - Introduce
UPSERT
inset_trial_system_attr
(#5741)
Bug Fixes
- Accept
Mapping
asparam_distributions
inOptunaSearchCV
(optuna/optuna-integration#172, thanks @yu9824!) - Allow use of
OptunaSearchCV
withcross_val_predict
(optuna/optuna-integration#174, thanks @yu9824!) - Fix
GPSampler
's suggestion failure withintorch.no_grad()
context manager (#5671, thanks @kAIto47802!) - Fix a concurrency issue in
GPSampler
(#5737) - Fix a concurrency issue in
QMCSampler
(#5740)
Installation
- Drop the support for Python 3.7 and update package metadata for Python 3.13 support (#5727)
- Remove dependency specifier for installing SciPy (#5736)
Documentation
- Add badges of PyPI and Conda Forge (optuna/optuna-integration#167)
- Update news (#5655)
- Update news section in
README.md
(#5657) - Add
InMemoryStorage
to document (#5672, thanks @kAIto47802!) - Add the news about blog of
JournalStorage
toREADME.md
(#5674) - Fix broken link in the artifacts tutorial (#5677, thanks @kAIto47802!)
- Add
pandas
installation guide to RDB tutorial (#5685, thanks @kAIto47802!) - Add installation guide to multi-objective tutorial (#5686, thanks @kAIto47802!)
- Update document and notice interoperability between NSGA-II and Pruners (#5688)
- Fix typo in
EMMREvaluator
(#5694) - Fix
RegretBoundEvaluator
document (#5696) - Update news section in
README.md
(#5705) - Add link to related blog post in
emmr.py
(#5707) - Update FAQ entry for model preservation using Optuna Artifact (#5716, thanks @chitvs!)
- Escape
\D
for Python 3.12 with sphinx build (#5735) - Avoid using functions in
sphinx_gallery_conf
to remove document build error with Python 3.12 (#5738) - Remove all
generated
directories indocs/source
recursively (#5739) - Add information about
AutoSampler
to the docs (#5745)
Examples
- Update CI config for
fastai
(optuna/optuna-examples#279) - Introduce
optuna.artifacts
to the PyTorch checkpoint example (optuna/optuna-examples#280, thanks @kAIto47802!) - Fix inline code in README files in
kubernetes
directory (optuna/optuna-examples#282) - Test ray example with Python 3.12 (optuna/optuna-examples#284)
- Add a link to molecule LLM notebook (optuna/optuna-examples#285)
- Fix syntax error in YAML file of rapids CI (optuna/optuna-examples#286)
- Another fix for syntax error in YAML file of rapids CI (optuna/optuna-examples#287)
- Add checking for Python 3.12 (optuna/optuna-examples#288, thanks @kAIto47802!)
- Add Python 3.12 to tfkeras CI and remove warning message (optuna/optuna-examples#289)
- Add Python 3.12 to
lightgbm
CI (optuna/optuna-examples#290) - Remove Python 3.7 from the workflow (optuna/optuna-examples#291)
Code Fixes
- Add a comment for an unexpected bug in
CategoricalDistribution
(#5683) - Add more information about the hack in
WFG
(#5687) - Simplify type annotations to
_imports.py
(#5692, thanks @Prabhat-Thapa45!) - Use
__future__.annotations
inoptuna/_experimental.py
(#5714, thanks @Jonathan43!) - Use
__future__.annotations
intests/importance_tests/fanova_tests/test_tree.py
(#5731, thanks @guisp03!) - Resolve TODO comments related to dropping Python 3.7 support (#5734)
Continuous Integration
- Fix CI for
fastaiv2
(optuna/optuna-integration#164) - Fix for mypy (optuna/optuna-integration#166)
- Fix mlflow integration for CI (optuna/optuna-integration#168)
- Update CI to support Python 3.12 (optuna/optuna-integration#170, thanks @kAIto47802!)
- Update artifact version to v4 (optuna/optuna-integration#176)
- Add a tri-objective problem to speed benchmarking (#5635)
- Bump
actions/download-artifact
from 2 to 4.1.7 in/.github/workflows
(#5660) - Update MySQL version in CI from 5.7 to 8 (#5673)
- Remove performance benchmarks (#5675)
- Update PostgreSQL version in CI to latest (#5676)
- Update the version of Python used in the checks from 3.8 to 3.11 (#5684)
- Run tests with Python 3.13 (#5691)
- Fix for mypy (#5706)
- [hotfix] Add a version constraint on fakeredis (#5726)
- Update Python versions used in CI workflow (#5728)
- Update sphinx build's
upload-artifact
version (#5744)
Other
- Bump up version number to 4.1.0.dev (optuna/optuna-integration#159)
- Update supported Python versions (optuna/optuna-integration#175)
- Bump up to v4.1.0 (optuna/optuna-integration#179)
- Add pre-commit config (#5408)
- Add link to MOEA/D blog post in News (#5719)
- Include all test files in
sdist
by updatingMANIFEST.in
(#5720)
Thanks to All the Contributors!
This release was made possible by the authors and the people who participated in the reviews and discussions.
@HideakiImamura, @Jonathan43, @Prabhat-Thapa45, @c-bata, @chitvs, @contramundum53, @eukaryo, @gen740, @guisp03, @kAIto47802, @muhlbach, @nabenabe0928, @not522, @nzw0301, @porink0424, @toshihikoyanase, @y0z, @yu9824