Skip to main content
Ctrl+K
Try Ray with $100 credit — Start now

Site Navigation

  • Get Started

  • Use Cases

  • Example Gallery

  • Library

    • Ray CoreScale general Python applications

    • Ray DataScale data ingest and preprocessing

    • Ray TrainScale machine learning training

    • Ray TuneScale hyperparameter tuning

    • Ray ServeScale model serving

    • Ray RLlibScale reinforcement learning

  • APIs

  • Resources

    • Discussion ForumGet your Ray questions answered

    • TrainingHands-on learning

    • BlogUpdates, best practices, user-stories

    • EventsWebinars, meetups, office hours

    • Success StoriesReal-world workload examples

    • EcosystemLibraries integrated with Ray

    • CommunityConnect with us

Try Managed Ray

Site Navigation

  • Get Started

  • Use Cases

  • Example Gallery

  • Library

    • Ray CoreScale general Python applications

    • Ray DataScale data ingest and preprocessing

    • Ray TrainScale machine learning training

    • Ray TuneScale hyperparameter tuning

    • Ray ServeScale model serving

    • Ray RLlibScale reinforcement learning

  • APIs

  • Resources

    • Discussion ForumGet your Ray questions answered

    • TrainingHands-on learning

    • BlogUpdates, best practices, user-stories

    • EventsWebinars, meetups, office hours

    • Success StoriesReal-world workload examples

    • EcosystemLibraries integrated with Ray

    • CommunityConnect with us

Try Managed Ray

Loading API navigation…

  • Ray APIs
  • Ray Tune API
  • Tune Search Space API
  • grid_search

grid_search#

ray.tune.grid_search(values: Iterable) → Dict[str, Iterable][source]#

Specify a grid of values to search over.

Values specified in a grid search are guaranteed to be sampled.

If multiple grid search variables are defined, they are combined with the combinatorial product. This means every possible combination of values will be sampled.

Example

>>> from ray import tune
>>> param_space={
...   "x": tune.grid_search([10, 20]),
...   "y": tune.grid_search(["a", "b", "c"])
... }

This will create a grid of 6 samples: {"x": 10, "y": "a"}, {"x": 10, "y": "b"}, etc.

When specifying num_samples in the TuneConfig, this will specify the number of random samples per grid search combination.

For instance, in the example above, if num_samples=4, a total of 24 trials will be started - 4 trials for each of the 6 grid search combinations.

Parameters:

values – An iterable whose parameters will be used for creating a trial grid.

Returns:

A dict in the form {"grid_search": values} understood by Tune’s variant generator.

PublicAPI (beta): This API is in beta and may change before becoming stable.

previous

choice

next

sample_from

On this page
  • grid_search()
Thanks for the feedback!
Was this helpful?
Yes
No
Feedback
Submit

© Copyright 2026, The Ray Team.

Created using Sphinx 8.2.3.

Built with the PyData Sphinx Theme 0.18.0.