Reproducible results of optuna when n_jobs=-1

27 views Asked by At

I am currently working with optuna and I have noticed that when I use n_jobs = -1, the TPESampler does not sample the exact same parameters for different study, even with the seed inside optuna.samplers.TPESampler(seed = 10) fixed. It seems that combining multiprocessing of optuna and get determinist results are incompatible. I really need my results to be reproducible, but I also need n_jobs = -1, otherwise the code will take to much time. I am fully aware that using n_jobs = 1 will remove this issue, but as I said, I don't want to use it because I have constraint on time.

Did any of you could have the solution to this problem ?

The code :

study1 = optuna.create_study(direction="maximize", sampler=optuna.samplers.TPESampler(seed = 10))
study1.optimize(objective, n_trials=5, n_jobs = -1)

study2 = optuna.create_study(direction="maximize", sampler=optuna.samplers.TPESampler(seed = 10))
study2.optimize(objective, n_trials=5, n_jobs = -1)

Thanks a lot stackoverflow community :) !

0

There are 0 answers