# Run Grid Search But Choose Next Config Randomly Within Grid

**URL:** <https://community.wandb.ai/t/run-grid-search-but-choose-next-config-randomly-within-grid/6794>\
**Category:** W&B Help\
**Tags:** sweeps\
**Created:** [May 28, 2024, 10:08pm UTC](https://community.wandb.ai/t/run-grid-search-but-choose-next-config-randomly-within-grid/6794 "2024-05-28T22:08:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjvolk3](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mjvolk3](https://community.wandb.ai/u/mjvolk3)\
**Post date:** [May 28, 2024, 10:08pm UTC](https://community.wandb.ai/t/run-grid-search-but-choose-next-config-randomly-within-grid/6794/1 "2024-05-28T22:08:36Z")

</div>

Random over the grid would be a very nice feature. Any updates on this?

[github issue](https://github.com/wandb/wandb/issues/2848)

[grid\_search\_next\_runs](https://github.com/wandb/sweeps/blob/99bccfba31834805974c59f21b6ac82b0bdb8f01/src/sweeps/grid_search.py#L22C1-L28C31)

```python
def grid_search_next_runs(
    runs: List[SweepRun],
    sweep_config: Union[dict, SweepConfig],
    validate: bool = False,
    n: int = 1,
    randomize_order: bool = False,
) -> List[Optional[SweepRun]]:

```

How to pass `random_order = True` when running sweeps?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)\
**Post date:** [May 28, 2024, 10:18pm UTC](https://community.wandb.ai/t/run-grid-search-but-choose-next-config-randomly-within-grid/6794/2 "2024-05-28T22:18:32Z")

</div>

Hello, This a reply from our support bot designed to assist you with your Weights & Biases related queries. To reach a human please reply to this message.

To randomize the order of configurations in grid search sweeps in Weights & Biases, you can utilize the `randomize_order` parameter in your sweep configuration. However, based on the provided documentation, there isn’t a direct mention of a `randomize_order` parameter that can be set directly in the sweep configuration YAML or dictionary.

The concept of running grid search with the option to choose the next configuration randomly within the grid is interesting but not explicitly covered in the provided documentation.

For implementing a feature like `randomize_order` in your sweeps, you would typically look for an option within the sweep configuration settings. Since the documentation does not detail this feature, here’s a general approach on how you might attempt to achieve a randomized grid search, assuming such functionality exists or is planned:

1. **Define your sweep configuration** : Start by defining your sweep configuration in a Python dictionary or a YAML file. Specify your parameters, the search method (grid, random, or Bayesian), and other relevant settings.

2. **Look for a `randomize_order` option** : If Weights & Biases were to support a `randomize_order` feature directly in the sweep configuration, it would likely be a boolean flag you could set to `True` to enable random selection of grid search configurations.

3. **Implementing without direct support** : If direct support for `randomize_order` is not available, you might need to implement a custom solution. This could involve generating all possible configurations upfront, shuffling them to achieve random order, and then iterating over them in your training script. However, this approach would not leverage the W&B sweeps infrastructure directly for the randomization aspect.

4. **Check for updates and request features** : Since the feature you’re asking about is not documented, it’s a good idea to check the official Weights & Biases documentation or GitHub issues for any updates regarding this feature. You can also reach out to the W&B support or community forums to request this feature or inquire about its availability.

As of now, to enable a feature like `random_order` for sweep runs, you would need to check the latest Weights & Biases documentation or contact their support for the most current information and guidance on achieving this functionality.

For the most accurate and up-to-date information on sweeps and any potential features like `randomize_order`, please refer to the official Weights & Biases documentation or reach out to their support team.

**Sources** :

- [Sweep Configuration Options](https://docs.wandb.ai/guides/sweeps/sweep-config-keys)
- [Define Sweep Configuration](https://docs.wandb.ai/guides/sweeps/define-sweep-configuration)
- [Tune Hyperparameters with W&B Sweeps](https://docs.wandb.ai/guides/sweeps)

To reach a human please reply to this message.

-WandBot 🤖

---

<div class="post-metadata">

**Author:** ![luis\_bergua](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@luis\_bergua](https://community.wandb.ai/u/luis_bergua)\
**Post date:** [June 7, 2024, 4:13pm UTC](https://community.wandb.ai/t/run-grid-search-but-choose-next-config-randomly-within-grid/6794/3 "2024-06-07T16:13:09Z")

</div>

Thanks @mjvolk3! We’ll add you to the internal feature request
