ray.tune.search.hebo.HEBOSearch#

class ray.tune.search.hebo.HEBOSearch(space: Dict | hebo.design_space.design_space.DesignSpace | None = None, metric: str | None = None, mode: str | None = None, points_to_evaluate: List[Dict] | None = None, evaluated_rewards: List | None = None, random_state_seed: int | None = None, max_concurrent: int = 8, **kwargs)[source]#

Bases: Searcher

Uses HEBO (Heteroscedastic Evolutionary Bayesian Optimization) to optimize hyperparameters.

HEBO is a cutting edge black-box optimization framework created by Huawei’s Noah Ark. More info can be found here: huawei-noah/HEBO.

space can either be a HEBO’s DesignSpace object or a dict of Tune search spaces.

Please note that the first few trials will be random and used to kickstart the search process. In order to achieve good results, we recommend setting the number of trials to at least 16.

Maximum number of concurrent trials is determined by max_concurrent argument. Trials will be done in batches of max_concurrent trials. If this Searcher is used in a ConcurrencyLimiter, the max_concurrent value passed to it will override the value passed here.

Parameters:
  • space – A dict mapping parameter names to Tune search spaces or a HEBO DesignSpace object.

  • metric – The training result objective value attribute. If None but a mode was passed, the anonymous metric _metric will be used per default.

  • mode – One of {min, max}. Determines whether objective is minimizing or maximizing the metric attribute.

  • points_to_evaluate – Initial parameter suggestions to be run first. This is for when you already have some good parameters you want to run first to help the algorithm make better suggestions for future parameters. Needs to be a list of dicts containing the configurations.

  • evaluated_rewards – If you have previously evaluated the parameters passed in as points_to_evaluate you can avoid re-running those trials by passing in the reward attributes as a list so the optimiser can be told the results without needing to re-compute the trial. Must be the same length as points_to_evaluate.

  • random_state_seed – Seed for reproducible results. Defaults to None. Please note that setting this to a value will change global random states for numpy and torch on initalization and loading from checkpoint.

  • max_concurrent – Number of maximum concurrent trials. If this Searcher is used in a ConcurrencyLimiter, the max_concurrent value passed to it will override the value passed here.

  • **kwargs – The keyword arguments will be passed to HEBO()`.

Tune automatically converts search spaces to HEBO’s format:

from ray import tune
from ray.tune.search.hebo import HEBOSearch

config = {
    "width": tune.uniform(0, 20),
    "height": tune.uniform(-100, 100)
}

hebo = HEBOSearch(metric="mean_loss", mode="min")
tuner = tune.Tuner(
    trainable_function,
    tune_config=tune.TuneConfig(
        search_alg=hebo
    ),
    param_space=config
)
tuner.fit()

Alternatively, you can pass a HEBO DesignSpace object manually to the Searcher:

from ray import tune
from ray.tune.search.hebo import HEBOSearch
from hebo.design_space.design_space import DesignSpace

space_config = [
    {'name' : 'width', 'type' : 'num', 'lb' : 0, 'ub' : 20},
    {'name' : 'height', 'type' : 'num', 'lb' : -100, 'ub' : 100},
]
space = DesignSpace().parse(space_config)

hebo = HEBOSearch(space, metric="mean_loss", mode="min")
tuner = tune.Tuner(
    trainable_function,
    tune_config=tune.TuneConfig(
        search_alg=hebo
    )
)
tuner.fit()

Methods

add_evaluated_trials

Pass results from trials that have been evaluated separately.

on_trial_complete

Notification for the completion of trial.

on_trial_result

Optional notification for result during training.

restore

Restoring current optimizer state.

restore_from_dir

Restores the state of a searcher from a given checkpoint_dir.

save

Storing current optimizer state.

save_to_dir

Automatically saves the given searcher to the checkpoint_dir.

Attributes

CKPT_FILE_TMPL

FINISHED

metric

The training result objective value attribute.

mode

Specifies if minimizing or maximizing the metric.