> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

> Hyperparameter search and model optimization with Weights & Biases Sweeps

# Sweeps overview

[Try in Colab](https://colab.research.google.com/github/wandb/examples/blob/master/colabs/pytorch/Organizing_Hyperparameter_Sweeps_in_PyTorch_with_W%26B.ipynb)

[Try in W\&B](https://forge.coreweave.com/wandb/stacey/deep-drive/workspace?workspace=user-lavanyashukla)

Use Weights & Biases Sweeps to automate hyperparameter search and visualize rich, interactive experiment tracking. Pick from popular search methods such as Bayesian, grid search, and random to search the hyperparameter space. Scale and parallelize sweep across one or more machines.

![Hyperparameter tuning insights](https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/_media/intro_what_it_is.png?fit=max\&auto=format\&n=3Dv_sw2eg8feUJlx\&q=85\&s=ba08388f527cf31ca518354c1b04d832)

## How it works

1. Define a [sweep configuration](https://docs.coreweave.com/products/wandb/sweeps/define-sweep-configuration.md) that specifies the hyperparameters to search and the optimization metric.

2. Define the training logic that the sweep uses to execute each trial.

3. Initialize a sweep:
   ```bash theme={"system"}
   wandb sweep --project <project-name> <path-to-config file>
   ```
   This returns the sweep ID that you use to start the sweep agent and the sweep scheduler if applicable.

4. (Optional) If you use [an optimization engine](https://docs.coreweave.com/products/wandb/sweeps/configure-engine.md), start a sweep scheduler:
   ```bash theme={"system"}
   wandb sweep-scheduler <entity>/<project>/<sweep-ID>
   ```

5. Start a sweep agent:
   ```bash theme={"system"}
   wandb agent <entity>/<project>/<sweep-ID>
   ```

> [!NOTE]
>
> The previous code snippet, and the colab linked on this page, show how to initialize and create a sweep with the Weights & Biases CLI. See the [Sweeps walkthrough](https://docs.coreweave.com/products/wandb/sweeps/walkthrough.md) to use the Python SDK to configure, initialize, and run a sweep.

## How to get started

Depending on your use case, explore the following resources to get started with Weights & Biases Sweeps:

* Read through the [sweeps walkthrough](https://docs.coreweave.com/products/wandb/sweeps/walkthrough.md) for a step-by-step outline of the W\&B Python SDK commands to use to define a sweep configuration, initialize a sweep, and start a sweep.
* Explore this chapter to learn how to:
  * [Add Weights & Biases to your code](https://docs.coreweave.com/products/wandb/sweeps/add-w-and-b-to-your-code.md)
  * [Define sweep configuration](https://docs.coreweave.com/products/wandb/sweeps/define-sweep-configuration.md)
  * [Initialize sweeps](https://docs.coreweave.com/products/wandb/sweeps/initialize-sweeps.md)
  * [Start sweep agents](https://docs.coreweave.com/products/wandb/sweeps/start-sweep-agents.md)
  * [Visualize sweep results](https://docs.coreweave.com/products/wandb/sweeps/visualize-sweep-results.md)
* Explore a [curated list of Sweep experiments](https://docs.coreweave.com/products/wandb/sweeps/useful-resources.md) that explore hyperparameter optimization with Weights & Biases Sweeps. Results are stored in W\&B Reports.

For a step-by-step video, see: [Tune Hyperparameters Easily with Weights & Biases Sweeps](https://www.youtube.com/watch?v=9zrmUIlScdY\&ab_channel=Weights%26Biases).

### Notebook examples

The following notebook examples explore how to use Weights & Biases Sweeps for hyperparameter optimization across a variety of frameworks and use cases:

* [Hyperparameter optimization with Sweeps](https://colab.research.google.com/github/wandb/examples/blob/master/colabs/tensorflow/Hyperparameter_Optimization_in_TensorFlow_using_W\&B_Sweeps.ipynb)
* [Using XGBoost with Weights & Biases Sweeps](https://colab.research.google.com/github/wandb/examples/blob/master/colabs/boosting/Using_W\&B_Sweeps_with_XGBoost.ipynb)
