Skip to content

optuna/unseeded-sampler

Pack Severity Fix Versions
Optuna warning unsafe, with xpd check --fix --unsafe-fixes All versions

Optuna's stochastic samplers default to seed=None, so re-running the same study explores different trials and selects different hyperparameters (two 10-trial TPESampler() runs on Optuna 5.1.0 returned 0.0 vs 2.293475, while seed=0 reproduced 0.174626).

sampler = optuna.samplers.TPESampler()
sampler = optuna.samplers.TPESampler(seed=0)

Calls to TPESampler, RandomSampler, CmaEsSampler, GPSampler, QMCSampler, NSGAIISampler, and NSGAIIISampler without seed=.

Pass an explicit integer seed= to the sampler constructor and pass that sampler into optuna.create_study(sampler=...).

$C without seed= draws different trial sequences on every run. Pass seed= (for example seed=0) so hyperparameter optimization is reproducible.

See all rules in the Optuna pack.