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

Bases: ray.tune.search.searcher.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: https://github.com/huawei-noah/HEBO/tree/master/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.

  • 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. (See tune/examples/hebo_example.py)

  • 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(

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(
set_max_concurrency(max_concurrent: int) bool[source]#

Set max concurrent trials this searcher can run.

This method will be called on the wrapped searcher by the ConcurrencyLimiter. It is intended to allow for searchers which have custom, internal logic handling max concurrent trials to inherit the value passed to ConcurrencyLimiter.

If this method returns False, it signifies that no special logic for handling this case is present in the searcher.


max_concurrent – Number of maximum concurrent trials.

set_search_properties(metric: Optional[str], mode: Optional[str], config: Dict, **spec) bool[source]#

Pass search properties to searcher.

This method acts as an alternative to instantiating search algorithms with their own specific search spaces. Instead they can accept a Tune config through this method. A searcher should return True if setting the config was successful, or False if it was unsuccessful, e.g. when the search space has already been set.

  • metric – Metric to optimize

  • mode – One of [β€œmin”, β€œmax”]. Direction to optimize.

  • config – Tune config dict.

  • **spec – Any kwargs for forward compatiblity. Info like Experiment.PUBLIC_KEYS is provided through here.

suggest(trial_id: str) Optional[Dict][source]#

Queries the algorithm to retrieve the next set of parameters.


trial_id – Trial ID used for subsequent notifications.


Configuration for a trial, if possible.

If FINISHED is returned, Tune will be notified that no more suggestions/configurations will be provided. If None is returned, Tune will skip the querying of the searcher for this step.

Return type

dict | FINISHED | None

on_trial_complete(trial_id: str, result: Optional[Dict] = None, error: bool = False)[source]#

Notification for the completion of trial.

HEBO always minimizes.

add_evaluated_point(parameters: Dict, value: float, error: bool = False, pruned: bool = False, intermediate_values: Optional[List[float]] = None)[source]#

Pass results from a point that has been evaluated separately.

This method allows for information from outside the suggest - on_trial_complete loop to be passed to the search algorithm. This functionality depends on the underlying search algorithm and may not be always available.

  • parameters – Parameters used for the trial.

  • value – Metric value obtained in the trial.

  • error – True if the training process raised an error.

  • pruned – True if trial was pruned.

  • intermediate_values – List of metric values for intermediate iterations of the result. None if not applicable.

save(checkpoint_path: str)[source]#

Storing current optimizer state.

restore(checkpoint_path: str)[source]#

Restoring current optimizer state.