xadrianzetx / optuna-distributed

Distributed hyperparameter optimization made easy
MIT License
34 stars 1 forks source link

Send kill signal to running trials when `stop_optimization` is called #14

Closed xadrianzetx closed 2 years ago

xadrianzetx commented 2 years ago

Is your feature request related to a problem? Please describe. Currently manager.stop_optimization will only cancel scheduled trials, but is unable to stop already running ones. This is a limitation of Dask (or actually Python itself) as described in this so thread.

Describe the solution you'd like Make stop_optimization emit a signal to all running trials (e.g. using variable) and make sure trial is periodically checking for this signal, as we can't assume users will do it manually in objective functions. If trial reads reads stop signal, optimization should be immediately halted.

Describe alternatives you've considered Do nothing and wait for Dask to implement thread interrupts as discussed in https://github.com/dask/distributed/issues/4694.

Additional context

xadrianzetx commented 2 years ago

This is actually quite hard, as we can't:

Not sure how to approach it at the moment.

xadrianzetx commented 2 years ago

A possible, but hacky solution.