Skip to main content
After you define a sweep configuration and before you launch agents, initialize a sweep to register its configuration with W&B and receive a sweep ID. Agents use the sweep ID to fetch run instructions. After a sweep is initialized, it’s ready to coordinate hyperparameter searches across one or more machines. W&B uses a sweep controller to manage sweeps across one or more machines. After a run completes, the controller issues a new set of instructions that describe the next run to execute, and agents pick up these instructions and run them. By default, W&B hosts the controller, and agents run on your machines. Before you initialize a sweep, you must have a sweep configuration defined either in a YAML file or a nested Python dictionary object in your script. For more information, see Define sweep configuration. The following code snippets show how to initialize sweeps with the CLI and within a Jupyter notebook or Python script. Choose the method that matches your workflow.
The sweep and the run must be in the same project. The project name you provide when you initialize W&B (wandb.init()) must match the project name you provide when you initialize a sweep (wandb.sweep()).
Use the W&B SDK to initialize a sweep. Pass the sweep configuration dictionary to the sweep parameter. Optionally set the project parameter to the project name where you want W&B to store the output of the run. If you don’t specify the project, W&B puts the run in an “Uncategorized” project.
The wandb.sweep() function returns the sweep ID. The sweep ID includes the entity name and the project name. Note the sweep ID, which you pass to agents when you start them. With the sweep ID, you’re ready to launch one or more agents to execute runs.