Skip to main content

Create a hyperparameter sweep

Run a systematic search over hyperparameters and find the best configuration

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

Choose a search strategy

Vantage supports three sweep algorithms:

AlgorithmBest forHow it works
GridSmall, discrete spacesTests every combination of specified values
RandomLarge spaces, quick explorationSamples random combinations from defined ranges
BayesianExpensive training, adaptive searchUses 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

  1. Click Workbench in the left sidebar, then click Sweeps under the Train section.
  2. The sweep list shows each sweep with its name, algorithm, objective metric, number of trials, and best metric value so far.
  3. 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.

Ask AI
Ask a question about Vantage Compute...