Skip to content

optuna/deprecated-suggest-api

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

Trial.suggest_uniform, Trial.suggest_loguniform, and Trial.suggest_discrete_uniform have been deprecated since Optuna 3.0 and emit a FutureWarning on every trial in Optuna 5.1 before removal in 6.0.

lr = trial.suggest_loguniform("lr", 1e-4, 1e-1)
lr = trial.suggest_float("lr", 1e-4, 1e-1, log=True)

Calls to suggest_uniform, suggest_loguniform, and suggest_discrete_uniform in files that import optuna.

Replace them with suggest_float, passing log=True for log-uniform sampling and step= for discrete uniform sampling. Safe autofixes apply directly with xpd check --fix.

suggest_uniform is deprecated since Optuna 3.0 and scheduled for removal in Optuna 6.0. Call suggest_float($NAME, $LOW, $HIGH) instead.

See all rules in the Optuna pack.