1

I understand that I can do distributed optimization with Optuna. However, I don't know if I can do it with multiple models at the same time?

For example:

optuna create-study --study-name "distributed-example1" --storage "sqlite:///example.db"

optuna create-study --study-name "distributed-example2" --storage "sqlite:///example.db"

Then in example1.py:

import optuna

def objective(trial):
    x = trial.suggest_uniform('x', -10, 10)
    return (x - 2) ** 2

if __name__ == '__main__':
    study = optuna.load_study(study_name='distributed-example1', storage='sqlite:///example.db')
    study.optimize(objective, n_trials=100)

Then in example2.py:

import optuna

def objective(trial):
    x = trial.suggest_uniform('x', -10, 10)
    return (x - 2) ** 2

if __name__ == '__main__':
    study = optuna.load_study(study_name='distributed-example2', storage='sqlite:///example.db')
    study.optimize(objective, n_trials=100)

1 Answers1

1

Yes, you can. Optuna supports running multiple studies simultaneously by using the same storage (DB).

sile
  • 201
  • 2
  • 4
  • NOTE: These storage instances cannot be SQLite per Optuna documentation: https://optuna.readthedocs.io/en/stable/tutorial/10_key_features/004_distributed.html?highlight=distributed (see both notes at bottom of page, one of which refers to:) https://www.sqlite.org/faq.html#q5 – brethvoice Jun 21 '21 at 18:20