Skip to content

Commit

Permalink
[Tune] Do not warn in BayesOpt w/ Uniform sampler (ray-project#30350)
Browse files Browse the repository at this point in the history
BayesOpt supports only uniform sampling, but we erroneously warn when the Uniform sampler is used (as opposed to no sampler at all). This PR fixes that issue.

Signed-off-by: Antoni Baum <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
  • Loading branch information
Yard1 authored and WeichenXu123 committed Dec 19, 2022
1 parent 31c7311 commit db833d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 1 addition & 3 deletions doc/source/tune/examples/bayesopt_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Function checkpointing is disabled. This may result in unexpected behavior when using checkpointing features or certain schedulers. To enable, set the train function arguments to be `func(config, checkpoint_dir=None)`.\n",
"BayesOpt does not support specific sampling methods. The Uniform sampler will be dropped.\n",
"BayesOpt does not support specific sampling methods. The Uniform sampler will be dropped.\n"
"Function checkpointing is disabled. This may result in unexpected behavior when using checkpointing features or certain schedulers. To enable, set the train function arguments to be `func(config, checkpoint_dir=None)`.\n"
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions python/ray/tune/search/bayesopt/bayesopt_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Dict, List, Optional, Tuple, Any, TYPE_CHECKING

from ray.tune.result import DEFAULT_METRIC
from ray.tune.search.sample import Domain, Float, Quantized
from ray.tune.search.sample import Domain, Float, Quantized, Uniform
from ray.tune.search import (
UNRESOLVED_SEARCH_SPACE,
UNDEFINED_METRIC_MODE,
Expand Down Expand Up @@ -419,7 +419,9 @@ def resolve_value(domain: Domain) -> Tuple[float, float]:
sampler = sampler.get_sampler()

if isinstance(domain, Float):
if domain.sampler is not None:
if domain.sampler is not None and not isinstance(
domain.sampler, Uniform
):
logger.warning(
"BayesOpt does not support specific sampling methods. "
"The {} sampler will be dropped.".format(sampler)
Expand Down

0 comments on commit db833d8

Please sign in to comment.