This is the release note of [v3.0.0-b0](https://github.com/optuna/optuna/milestone/41?closed=1).
Highlights
Simplified Distribution Classes: Float, Int and Categorical
Search space definitions, which consist of `BaseDistribution` and its child classes in Optuna, are greatly simplified. We have introduced `FloatDistribution`, `IntDistribution`, and `CategoricalDistribution`. If you use the suggest API and `Study.optimize`, the search space information is stored as these three distributions. Previous `UniformDistribution`, `LogUniformDistribution`, `DiscreteUniformDistribution`, `IntUniformDistribution`, and `IntLogUniformDistribution` are deprecated. If you pass deprecated distributions to APIs such as `Study.ask` or `create_trial`, they are internally converted to corresponding `FloatDistribution` or `IntDistribution`.
Storage Database Migration
To use Optuna v3.0.0-b0 with `RDBStorage` that was created in the previous versions of Optuna, please run `optuna storage upgrade` to migrate your database.
If you use `RedisStorage`, copy your study with `RDBStorage` using [`copy_study`](https://optuna.readthedocs.io/en/stable/reference/generated/optuna.study.copy_study.html?highlight=copy_study) with the Optuna you used to create the study, thenrun `optuna storage upgrade` with Optuna v3.0.0-b0. After upgrading the storage, copy the study back as a new `RedisStorage`.
sh
python -c ‘import optuna; optuna.copy_study(from_study_name=”example”, from_storage=”redis://localhost:6379”, to_storage=”sqlite:///upgrade.db”)
pip install –pre -U optuna
optuna storage upgrade –storage sqlite:///upgrade.db
python -c ‘import optuna; optuna.copy_study(from_study_name="example", from_storage="sqlite:///upgrade.db", to_study_name="new-example", to_storage="redis://localhost:6379")’
Consistent Ask-and-Tell Interface with `Study.optimize`
`Study.tell` fails a trial when it is called with certain invalid combinations of `state` and `values`, instead of raising an error. This change aims to make `Study.tell` consistent with `Study.optimize`, which continues an optimization even if an objective returns an invalid value.
`Study.tell` now also returns the resulting trial (`FrozenTrial`) in order to allow inspecting how the arguments were interpreted.
Before
`Study.tell` raises an exception when it is called with an invalid combination of `state` and `values`.
python
study.tell(study.ask(), values=None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/…/optuna/optuna/study/study.py", line 579, in tell
raise ValueError(
ValueError: No values were told. Values are required when state is TrialState.COMPLETE.
After
`Study.tell` automatically fails the trial.
python
trial: FrozenTrial = study.tell(study.ask(), value=None)
assert trial.state == TrialState.FAIL
See 3144 for more details.
Stable `Study` APIs
We are converting all positional arguments of `create_study`, `delete_study`, `load_study`, and `copy_study` to keyword-only arguments since the order of arguments were inconsistent. This is not yet a breaking-change, but if you use these features with positional arguments, then you will get a warning message to use them with keyword-only arguments.
In addition, we have fixed all of problems described in 2955, so we have stabled the `Study` APIs. Specifically, `Study.add_trial`, `Study.add_trials`, `Study.enqueue_trial`, and `copy_study` have been stabled.
See 3270 and 2955 for more details.
Improved Visualization
Several bugs in the visualization module have been resolved. For instance,
the parallel coordinates plot ignores trials with missing parameters ([3373](https://github.com/optuna/optuna/pull/3373)) and the scale of the objective value is fixed ([#3369](https://github.com/optuna/optuna/pull/3369)). The edf plot filters trials with `inf` values ([#3395](https://github.com/optuna/optuna/pull/3395) and [#3435](https://github.com/optuna/optuna/pull/3435)).
Before: Trials with missing parameters are wrongly connected to each other.
<img width="1203" alt="158495812-acb399e5-d817-4cae-8c8b-c69bcc91efea" src="https://user-images.githubusercontent.com/38826298/162878578-fc162708-5c3b-45a0-b098-47445a1242a7.png">
After: Trials with missing parameters are removed from the plot.
<img width="1191" alt="158495810-98a5ec29-581c-426a-a255-11d16ae1c144" src="https://user-images.githubusercontent.com/38826298/162878606-aa937868-b8f5-4b51-b09b-6aced6fd28ff.png">
Breaking Changes
- Add option to exclude best trials from study summaries (3109)
- Migrate to `{Float,Int}Distribution` using `alembic` (3113)
- Move validation logic from `_run_trial` to `study.tell` (3144)
- Enable `FloatDistribution` and `IntDistribution` (3246)
- Use an enqueued parameter that is out of range from suggest API (3298)
- Convert deprecated distribution to new distribution internally (3420)
New Features
- Add `CatBoostPruningCallback` (2734, thanks tohmae!)
- Create common API for all NSGA-II crossover operations (3221)
- Add a history of retried trial numbers in `Trial.system_attrs` (3223, thanks belltailjp!)
- Convert all positional arguments to keyword-only (3270, thanks higucheese!)
- Stabilize `study.py` (3309)
- Add `targets` and deprecate `axis_order` in `optuna.visualization.matplotlib.plot_pareto_front` (3341, thanks shu65!)
Enhancements
- Enable cache for `study.tell()` (3265, thanks masap!)
- Warn if heartbeat is used with ask-and-tell (3273)
- Make `optuna.study.get_all_study_summaries()` of `RedisStorage` fast (3278, thanks masap!)
- Improve Ctrl-C interruption handling (3374, thanks CorentinNeovision!)
- Use same colormap among `plotly` visualization methods (3376)
- Make EDF plots handle trials with nonfinite values (3435)
- Make logger message optional in `filter_nonfinite` (3438)
Bug Fixes
- Make TPE work with a categorical variable with different choice types (3190, thanks keisukefukuda!)
- Fix axis range issue in `matplotlib` contour plot (3249, thanks harupy!)
- Allow `fail_state_trials` show warning when heartbeat is enabled (3301)
- Clip untransformed values sampled from int uniform distributions (3319)
- Fix missing `user_attrs` and `system_attrs` in study summaries (3352)
- Fix objective scale in parallel coordinate of Matplotlib (3369)
- Fix `matplotlib.plot_parallel_coordinate` with log distributions (3371)
- Fix parallel coordinate with missing value (3373)
- Add utility to filter trials with `inf` values from visualizations (3395)
- Return the best trial number, not worst trial number by `best_index_` (3410)
- Avoid using `px.colors.sequential.Blues` that introduces `pandas` dependency (3422)
- Fix `_is_reverse_scale` (3424)
Installation
- Drop TensorFlow support for Python 3.6 (3296)
- Pin AllenNLP version (3367)
- Skip run `fastai` job on Python 3.6 (3412)
- Avoid latest `click==8.1.0` that removed a deprecated feature (3413)
- Avoid latest PyTorch lightning until integration is updated (3417)
- Revert "Avoid latest `click==8.1.0` that removed a deprecated feature" (3430)
Documentation
- Add reference to tutorial page in CLI (3267, thanks tsukudamayo!)
- Carry over notes on `step` behavior to new distributions (3276)
- Correct the disable condition of `show_progress_bar` (3287)
- Add a document to lead FAQ and example of heartbeat (3294)
- Add a note for `copy_study`: it creates a copy regardless of its state (3295)
- Add note to recommend Python 3.8 or later in documentation build with artifacts (3312)
- Fix crossover references in `Raises` doc section (3315)
- Add reference to `QMCSampler` in tutorial (3320)
- Fix layout in tutorial (with workaround) (3322)
- Scikit-learn required for `plot_param_importances` (3332, thanks ll7!)
- Add a link to multi-objective tutorial from a pareto front page (3339, thanks kei-mo!)
- Add reference to tutorial page in visualization (3340, thanks Hiroyuki-01!)
- Mention tutorials of User-Defined Sampler/Pruner from the API reference pages (3342, thanks hppRC!)
- Add reference to saving/resuming study with RDB backend (3345, thanks Hiroyuki-01!)
- Fix a typo (3360)
- Remove deprecated command `optuna study optimize` in FAQ (3364)
- Fix nit typo (3380)
- Add see also section for `best_trial` (3396, thanks divyanshugit!)
- Updates the tutorial page for re-use the best trial (3398, thanks divyanshugit!)
- Add explanation about `Study.best_trials` in multi-objective optimization tutorial (3443)
Examples
- Remove Python 3.6 from `haiku`'s CI (https://github.com/optuna/optuna-examples/pull/83)
- Apply `black` 22.1.0 & run `checks` daily (https://github.com/optuna/optuna-examples/pull/84)
- Add `hiplot` example (https://github.com/optuna/optuna-examples/pull/86)
- Stop running jobs using TF with Python3.6 (https://github.com/optuna/optuna-examples/pull/87)
- Pin AllenNLP version (https://github.com/optuna/optuna-examples/pull/89)
- Add Medium link (https://github.com/optuna/optuna-examples/pull/91)
- Use official `CatBoostPruningCallback` (https://github.com/optuna/optuna-examples/pull/92)
- Stop running `fastai` job on Python 3.6 (https://github.com/optuna/optuna-examples/pull/93)
- Specify Python version using `str` in workflow files (https://github.com/optuna/optuna-examples/pull/95)
- Introduce upper version constraint of PyTorchLightning (https://github.com/optuna/optuna-examples/pull/96)
- Update `SimulatedAnnealingSampler` to support `FloatDistribution` (https://github.com/optuna/optuna-examples/pull/97)
Tests
- Add plot value tests to `matplotlib_tests/test_param_importances` (3180, thanks belldandyxtq!)
- Make tests of `plot_optimization_history` methods consistent (3234)
- Add integration test for `RedisStorage` (3258, thanks masap!)
- Change the order of arguments in the `catalyst` integration test (3308)
- Cleanup `MLflowCallback` tests (3378)
- Test serialize/deserialize storage on parametrized conditions (3407)
- Add tests for parameter of 'None' for TPE (3447)
Code Fixes
- Switch to `IntDistribution` (3181, thanks nyanhi!)
- Fix type hints for Python 3.8 (3240)
- Remove `UniformDistribution`, `LogUniformDistribution` and `DiscreteUniformDistribution` code paths (3275)
- Merge `set_trial_state()` and `set_trial_values()` into one function (3323, thanks masap!)
- Follow up for `{Float, Int}Distributions` (3337, thanks nyanhi!)
- Move the `get_trial_xxx` abstract functions to base (3338, thanks belldandyxtq!)
- Update type hints of `states` (3359, thanks BasLaa!)
- Remove unused function from `RedisStorage` (3394, thanks masap!)
- Remove unnecessary string concatenation (3406)
- Follow coding style and fix typos in `tests/integration_tests` (3408)
- Fix log message formatting in `filter_nonfinite` (3436)
- Add `RetryFailedTrialCallback` to `optuna.storages.*` (3441)
- Unify `fail_stale_trials` in each storage implementation (3442, thanks knshnb!)
Continuous Integration
- Add performance benchmarks using `bayesmark` (3354)
- Fix speed benchmarks (3362)
- Pin `setuptools` (3427)
Other
- Bump up version to `v3.0.0b0.dev` (3289)
- Add description field for `question-and-help-support` (3305)
- Update README to inform `v3.0.0a2` (3314)
- Add Optuna-related URLs for PyPi (3355, thanks andriyor!)
- Bump Optuna to `v3.0.0-b0` (3458)
Thanks to All the Contributors!
This release was made possible by the authors and the people who participated in the reviews and discussions.
BasLaa, CorentinNeovision, HideakiImamura, Hiroyuki-01, andriyor, belldandyxtq, belltailjp, contramundum53, divyanshugit, harupy, higucheese, himkt, hppRC, hvy, kei-mo, keisuke-umezawa, keisukefukuda, knshnb, ll7, masap, not522, nyanhi, nzw0301, shu65, sile, tohmae, toshihikoyanase, tsukudamayo, xadrianzetx