Create a hyperparameter sweep
A sweep runs many trials, each with a different combination of hyperparameters. It tracks the metric you are optimizing and surfaces the best trial.
Prerequisites
- A Kubernetes cluster in ready status with at least one compute pool
- The Vantage SDK installed and configured
Choose a search strategy
Vantage supports three sweep algorithms:
| Algorithm | Best for | How it works |
|---|---|---|
| Grid | Small, discrete spaces | Tests every combination of specified values |
| Random | Large spaces, quick exploration | Samples random combinations from defined ranges |
| Bayesian | Expensive training, adaptive search | Uses prior trial results to pick the next combination |
Create a sweep with the SDK
from vantage_sdk import VantageClient
client = VantageClient()
sweep = client.sweeps.create(
name="lr-batch-sweep",
objective_metric="val_accuracy",
objective_goal="maximize",
algorithm="bayesian",
parameters={
"learning_rate": {"min": 1e-5, "max": 1e-2, "distribution": "log_uniform"},
"batch_size": {"values": [16, 32, 64, 128]},
"epochs": {"values": [10, 20, 50]},
},
training_job={
"image": "pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime",
"script": "train.py",
"gpu": 1,
"cpu": "4",
"memory": "16Gi",
},
max_trials=50,
)
print(f"Sweep started: {sweep.id}")
Monitor a sweep in the UI
- Click Workbench in the left sidebar, then click Sweeps under the Train section.
- The sweep list shows each sweep with its name, algorithm, objective metric, number of trials, and best metric value so far.
- Click a sweep to view:
- Trials -- each trial's parameters and resulting metric, sorted by objective
- Best trial -- the parameter combination that produced the best result
- Presets -- saved configurations that can seed new sweeps
Use a sweep preset
Presets are pre-defined configurations for common search patterns. Select an existing preset when creating a sweep to start from a known-good configuration instead of defining every parameter from scratch.
Related
- Sweep algorithms for details on each strategy
- Submit a training job