Annif icon indicating copy to clipboard operation
Annif copied to clipboard

Annif uses deprecated Optuna n_jobs parameter

Open osma opened this issue 4 years ago • 1 comments

In recent versions of Annif (which use Optuna 2.8.0), running the annif hyperopt command with a --jobs parameter gives the following warning:

FutureWarning: `n_jobs` argument has been deprecated in v2.7.0. This feature will be removed in v4.0.0. See https://github.com/optuna/optuna/releases/tag/v2.7.0.

The Optuna documentation for the 2.7.0 release explains that process-based parallelism should be used instead (tutorial). But that would require a PostgreSQL or MySQL database (SQLite is possible but not recommended).

Another option is to keep using thread-level parallelism using ThreadPoolExecutor instead of the n_jobs parameter. That would be easier to implement at least.

osma avatar Oct 07 '21 07:10 osma

It seems that Optuna has decided to continue supporting the n_jobs parameter after all: https://github.com/optuna/optuna/issues/2937 It is also possible that in the future it will become easier to run Optuna in parallel using real multiprocessing: https://github.com/optuna/optuna/issues/2950

Both of these are on the Optuna version 3 roadmap.

So for now I think we should wait and see what happens on the Optuna side.

osma avatar Feb 04 '22 09:02 osma

Optuna 3 has been released (the current release is 3.1.0), the n_jobs option is still present, and even mentioned in the FAQ with the caveat that it's based on multi-threading which is hampered by the GIL. Process-based parallelism would probably be better, but that's a different story and issue.

I'll keep this issue open to remind us to update to Optuna 3.x, which should get rid of the deprecation message.

osma avatar Jan 30 '23 13:01 osma

In recent versions of Annif (which use Optuna 2.8.0), running the annif hyperopt command with a --jobs parameter gives the following warning:

FutureWarning: `n_jobs` argument has been deprecated in v2.7.0. This feature will be removed in v4.0.0. See https://github.com/optuna/optuna/releases/tag/v2.7.0.

When updating now to latest Optuna release, i.e. v3.3.0, the above is not shown, but a different one is:

FutureWarning: suggest_uniform has been deprecated in v3.0.0. This feature will be removed in v6.0.0. See https://github.com/optuna/optuna/releases/tag/v3.0.0. Use suggest_float instead.

When just updating to Optuna 3.3.0 unit tests pass. The migration guide tells that the (new) method trial.suggest_float(“x”, low, high) corresponds to the deprecated method trial.suggest_uniform(“x”, low, high).

juhoinkinen avatar Aug 14 '23 14:08 juhoinkinen

The https://github.com/optuna/optuna/discussions/3930 tells that the (new) method trial.suggest_float(“x”, low, high) corresponds to the deprecated method trial.suggest_uniform(“x”, low, high).

Okay, let's switch to the new method then! I don't see why it wouldn't work.

osma avatar Aug 14 '23 14:08 osma