Ray: Integrating Optuna with Ray

Created on 19 Jun 2020  路  5Comments  路  Source: ray-project/ray

I have a strict dependency on optuna for my personal project. For that, I want to integrate optuna with [ray] - [tune] (another dependency).

However, due to define-by-run strategy of Optuna as opposed to define-and-run for [hyperopt] (and most of the other strategies), I am finding it difficult to integrate, since I cannot define search space separately.

If anyone could shed some light on this, it would be of great help.

enhancement

Most helpful comment

This is currently done in #10044.

All 5 comments

This is great! Does anyone have a good idea as to how to do this?

There's two possible ways (and we could do both):

  1. integrate Optuna into RayTune as a search algorithm. The benefit is that Optuna gets Ray's distributed execution + checkpointing + logging for free.
  2. integrate Ray into Optuna as backend - seems like Optuna's distributed execution would be much improved with Ray coordinating the execution.

@sile are you involved with Optuna? what do you think?

Hi @richardliaw,

Thank you for sharing your ideas!
I'm a developer of Optuna and I think that it's great if Optuna and Ray will be integrated together.
The first way you wrote seems a straightforward way to achieve that.
The second way also sounds interesting but I cannot imagine the detail as I'm not familiar with Ray.

@g-votte If you have any comments, please let us know.

Ah, speaking of integration: Ray also has a joblib backend. Similar to what is proposed here (https://github.com/optuna/optuna/issues/1381), you can do:

from ray.util.joblib import register_ray

register_ray()

with joblib.parallel_backend('ray', n_jobs=n_jobs):
    study.optimize(objective, n_trials=100, n_jobs=n_jobs)

which effectively allows optuna to scale across many machines and take advantage of Ray's distributed execution.

Great! Thank you for your information!

This is currently done in #10044.

Was this page helpful?
0 / 5 - 0 ratings