# Search space config Validation for Search algorithms

**URL:** <https://discuss.ray.io/t/search-space-config-validation-for-search-algorithms/138>\
**Category:** Ray Tune\
**Created:** [December 4, 2020, 5:35pm UTC](https://discuss.ray.io/t/search-space-config-validation-for-search-algorithms/138 "2020-12-04T17:35:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushikb11](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kaushikb11/32/92_2.png) [@kaushikb11](https://discuss.ray.io/u/kaushikb11)\
**Post date:** [December 4, 2020, 5:35pm UTC](https://discuss.ray.io/t/search-space-config-validation-for-search-algorithms/138/1 "2020-12-04T17:35:44Z")

</div>

I was wondering if we could add validation of search space config for the search algorithms.  
For example, `grid_search` is not supported for `AxSearch` , `BayesOpt` doesn’t support `Integer` data type. It raises an error during the `tune.run` .  
If there could be a way to get functionalities that are not supported for `search_alg` before running `tune.run`. I believe it would be helpful.  
Thank you!

---

<div class="post-metadata">

**Author:** ![rliaw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rliaw/32/24_2.png) [@rliaw](https://discuss.ray.io/u/rliaw)\
**Post date:** [December 4, 2020, 8:06pm UTC](https://discuss.ray.io/t/search-space-config-validation-for-search-algorithms/138/2 "2020-12-04T20:06:17Z")

</div>

> [@kaushikb11](#):
>
> For example, `grid_search` is not supported for `AxSearch` , `BayesOpt` doesn’t support `Integer` data type. It raises an error during the `tune.run` .

Yeah, I agree this would really improve usability. cc @kai

@kaushikb11 would you be interested in making a contribution?

---

<div class="post-metadata">

**Author:** ![kaushikb11](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kaushikb11/32/92_2.png) [@kaushikb11](https://discuss.ray.io/u/kaushikb11)\
**Post date:** [December 4, 2020, 8:44pm UTC](https://discuss.ray.io/t/search-space-config-validation-for-search-algorithms/138/3 "2020-12-04T20:44:24Z")

</div>

Yeah, sure! Do you have anything in mind for the implementation? Will go through the code.

---

<div class="post-metadata">

**Author:** ![rliaw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rliaw/32/24_2.png) [@rliaw](https://discuss.ray.io/u/rliaw)\
**Post date:** [December 4, 2020, 10:37pm UTC](https://discuss.ray.io/t/search-space-config-validation-for-search-algorithms/138/4 "2020-12-04T22:37:29Z")

</div>

I think every class has a `set_search_space` option. Maybe there you can raise an error if a grid search is passed in without support?

---

<div class="post-metadata">

**Author:** ![kai](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kai/32/3380_2.png) [@kai](https://discuss.ray.io/u/kai)\
**Post date:** [December 8, 2020, 1:15pm UTC](https://discuss.ray.io/t/search-space-config-validation-for-search-algorithms/138/5 "2020-12-08T13:15:22Z")

</div>

A question I have here is how you would want to get this information.

Usually the `config` parameter is passed to `tune.run` (e.g. `tune.run(config=config)`). Do I understand that you would like to have something like `AxSearch.is_valid_search_space(config)` here?

If so I would suggest to add a method to the base `Searcher` class that tries to convert the search space and errors if it is invalid. Something like this:

```auto
@staticmethod
def is_valid_search_space(spec: Dict):
    try:
        this.convert_search_space(spec)
    except ValueError:
        return False
    return True

```

This would keep it really simple and should avoid code duplication.

---

<div class="post-metadata">

**Author:** ![kaushikb11](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kaushikb11/32/92_2.png) [@kaushikb11](https://discuss.ray.io/u/kaushikb11)\
**Post date:** [December 9, 2020, 4:43pm UTC](https://discuss.ray.io/t/search-space-config-validation-for-search-algorithms/138/6 "2020-12-09T16:43:19Z")

</div>

@kai This makes sense. Thanks! Will look into it.

I faced an error in `convert_search_space` for `AxSearch` search alg: [Issue](https://github.com/ray-project/ray/issues/12622)
