-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
bugIssue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.v5Issue/PR related to Optuna version 5.Issue/PR related to Optuna version 5.
Description
Expected behavior
When two parameters share the same name up to capitalization, e.g. "a" and "A", only one is stored in the trials when using a MySQL database. Instead, both should be stored, just like when using in memory storage.
Environment
- Optuna version: 4.2.1
- Python version: 3.10.12
- OS: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.35
Error messages, stack traces, or logs
[I 2025-04-04 15:59:35,803] A new study created in memory with name: works
[I 2025-04-04 15:59:35,931] A new study created in RDB with name: worknt
[I 2025-04-04 15:59:35,978] Trial 0 finished with value: 11.0 and parameters: {'a': 6, 'A': 5}. Best is trial 0 with value: 11.0.
[I 2025-04-04 15:59:35,979] Trial 1 finished with value: 4.0 and parameters: {'a': 1, 'A': 3}. Best is trial 1 with value: 4.0.
[I 2025-04-04 15:59:35,979] Trial 2 finished with value: 11.0 and parameters: {'a': 7, 'A': 4}. Best is trial 1 with value: 4.0.
[I 2025-04-04 15:59:36,129] Trial 0 finished with value: 12.0 and parameters: {'a': 6}. Best is trial 0 with value: 12.0.
[I 2025-04-04 15:59:36,271] Trial 1 finished with value: 9.0 and parameters: {'a': 9}. Best is trial 1 with value: 9.0.
[I 2025-04-04 15:59:36,433] Trial 2 finished with value: 2.0 and parameters: {'a': 2}. Best is trial 2 with value: 2.0.
In memory: {'a': 1, 'A': 3}
MySQL: {'a': 2}Steps to reproduce
- Configure the database in the example code
- Execute
import optuna
# Insert your DB config here
hyper_opt_db = {
"host": "localhost",
"port": 3306,
"user": "optuna",
"password": "password",
"database": "hyper_opt"
}
db_url = f"mysql://{hyper_opt_db['user']}:{hyper_opt_db['password']}@{hyper_opt_db['host']}:{hyper_opt_db['port']}/{hyper_opt_db['database']}"
def objective(trial):
a = trial.suggest_int("a", 0, 10)
A = trial.suggest_int("A", 0, 10)
return a + A
study_in_memory = optuna.create_study(study_name="works")
study_in_db = optuna.create_study(study_name="worknt", storage=db_url)
# this works
study_in_memory.optimize(objective, n_trials=3)
# this does not
study_in_db.optimize(objective, n_trials=3)
print("In memory: ", study_in_memory.best_params)
print("MySQL: ", study_in_db.best_params)Additional context (optional)
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.v5Issue/PR related to Optuna version 5.Issue/PR related to Optuna version 5.