Motivation
This issue aims to track and summarize Optuna’s support for the experimental free-threaded mode (Python v3.13t) introduced in CPython 3.13.
Description
The current status of Optuna’s compatibility with v3.13t is as follows:
Sampler
| Sampler |
Support for 3.13t |
Remarks |
| RandomSampler |
Yes |
- |
| NSGAIISampler |
Yes |
- |
| TPESampler |
Yes |
Dependent on NumPy, but NumPy already supports 3.13t |
| GridSampler |
Yes |
Same as above |
| NSGAIIISampler |
Yes |
Same as above |
| BruteForceSampler |
No |
Despite the pure Python implementation, a RuntimeError: dictionary changed size during iteration was confirmed to occur when running in multi-threaded mode on Python 3.13t. The cause is currently under investigation (Link to reproduce the error without pytest-freethreaded). |
| CmaEsSampler |
Yes |
Dependent on NumPy and cmaes, but both already support 3.13t |
| GPSampler |
No |
Dependent on PyTorch, which is not yet supported on PyPI |
| QMCSampler |
No |
Dependent on SciPy, which is not yet supported on PyPI |
Storage
| Storage |
Support for 3.13t |
Remarks |
| InMemoryStorage |
Yes |
- |
| RDBStorage (sqlite) |
Partial |
sqlite3.OperationalError can occur, but this is not due to GIL. The issue arises because sqlite does not support high-level parallel processing. Errors can be resolved by reducing the number of threads (i.e., decreasing the values of n_jobs or --threads) or by extending the sqlite timeout. However, Optuna does not recommend using sqlite in cases where concurrent processing is performed with many threads (reference). |
| RDBStorage (MySQL) |
No |
Dependent on cryptography, which is not yet supported on PyPI |
| JournalStorage (File) |
Yes |
- |
| JournalStorage (Redis) |
No |
Despite the pure Python implementation, a RuntimeError: dictionary changed size during iteration was confirmed to occur when running in multi-threaded mode on Python 3.13t. The cause is currently under investigation (Link to reproduce the error without pytest-freethreaded). |
Optuna-Integration
The current status has not yet been verified and requires further investigation.
Action Items
The possible action items are as follows (but may not be limited to) :
Motivation
This issue aims to track and summarize Optuna’s support for the experimental free-threaded mode (Python v3.13t) introduced in CPython 3.13.
Description
The current status of Optuna’s compatibility with v3.13t is as follows:
Sampler
RuntimeError: dictionary changed size during iterationwas confirmed to occur when running in multi-threaded mode on Python 3.13t. The cause is currently under investigation (Link to reproduce the error without pytest-freethreaded).Storage
sqlite3.OperationalErrorcan occur, but this is not due to GIL. The issue arises because sqlite does not support high-level parallel processing. Errors can be resolved by reducing the number of threads (i.e., decreasing the values ofn_jobsor--threads) or by extending the sqlite timeout. However, Optuna does not recommend using sqlite in cases where concurrent processing is performed with many threads (reference).RuntimeError: dictionary changed size during iterationwas confirmed to occur when running in multi-threaded mode on Python 3.13t. The cause is currently under investigation (Link to reproduce the error without pytest-freethreaded).Optuna-Integration
The current status has not yet been verified and requires further investigation.
Action Items
The possible action items are as follows (but may not be limited to) :