Build a Hyperparameter Sweep Orchestrator with Early Stopping
distributed-systems cost-optimization reliability
AI System Design Deep Dive
Hyperparameter Sweep Orchestrator
A full grid costs $183,130, and ASHA finds the same winner for $24,499.
Think of an audition show with 243 singers and 4 rounds. The judges do not make every singer perform a full set. They listen for 30 seconds, cut the clearly lost, and let the rest sing longer. The system works until a great singer who needs a minute to warm up gets cut in round 1, and until a judge keeps a loud, flashy act who fades by the final. A hyperparameter sweep with early stopping is that show, run on GPUs at $55.04 per node-hour.
Here are the numbers. Before committing 512 H100s and $3.04M to the 70B run from posts 31 to 35, we want to choose peak learning rate, batch size, warmup and weight decay on a 1.3B proxy model. One proxy trial trains 20B tokens on one p5.48xlarge node (8 H100, 40 percent MFU of 989 TFLOPS bf16 dense, which is 405,744 tokens/s). That is 13.69 hours and $753.62 per trial. A budget of 243 configurations run to completion costs 243 x $753.62 = $183,130 and takes 208 hours on a 16 node pool. That is 6 percent of the 70B run just to pick four numbers.
A naive sweep fails in three ways. It spends 86.6 percent of its tokens on work that is not needed to find the same winner. It lets 12.1 percent of the sampled configurations diverge and keep burning a node until someone notices. And it treats the first loss reading as truth, when the rank correlation between loss at 0.74B tokens and loss at 20B tokens is only 0.77 in my simulation, so a hard cut on early loss throws away good configurations.
We need to solve for early-stopping policy, cheap pause and resume, and trustworthy ranking simultaneously. Post 33 gave the checkpoint format we reuse for pause and resume, and post 34 gave the batch and learning rate rules we sweep around. This post builds the orchestrator that decides, every 0.25B tokens, which trial lives, which dies and which gets promoted.
Early stopping is a ranking problem, not a threshold problem. The scheduler never asks whether a loss is good. It asks whether this trial is in the top third of the trials that have been measured at the same token count.
Requirements and Constraints
Functional requirements
- Accept a sweep spec: search space, token budget per trial, rung schedule, dollar cap.
- Sample configurations, run each on one node, and stream loss every 0.25B tokens.
- Stop, pause, promote and resume trials from checkpoints with no recompute.
- Kill diverging trials within one eval interval and free the node.
- Report the top 3 configurations with their full-budget loss and a reproducibility check on fresh seeds.
Non-functional requirements
- Cost: full-budget trial $753.62 (13.69 h). Sweep cost target under 15 percent of the exhaustive grid, so under $27,500 for 243 configurations.
- Latency (wall clock): sweep makespan under 2 days on 16 nodes (128 GPUs). Scheduler decision latency under 1 second after a metric arrives.
- Throughput: 16 concurrent trials, one per node, 0.25B tokens per eval interval, so one metric roughly every 616 seconds per node.
- Quality: top-1 recovery of at least 95 percent against the exhaustive grid and regret under 0.001 nats. In the offline analogue of recall@k, at least 1 of the true top 3 survives to the last rung in every world.
- Capacity: a 1.3B trial holds 20.8 GB of state at 16 bytes per parameter, which fits an 80 GB H100 with room for activations. A checkpoint is 14 bytes per parameter, 18.2 GB.
- Reliability: node loss must cost at most one eval interval of recompute.
Constraints
- Proxy model 1.3B parameters,
bf16, sequence length 4,096, 20B token budget (about 15 tokens per parameter), one trial per 8 GPU node. The mapping to the 70B model is a power-law fit on three proxy sizes, covered below. - Price is $55.04 per
p5.48xlargehour, us-east-1, from third party trackers in October 2026. Spot, reserved and savings plan pricing are out of scope. - Out of scope: neural architecture search, multi-objective sweeps, and data mixture search. The objective is validation loss on a fixed held-out set.
The 15 percent cost target, not the quality target, drives the design. Quality is cheap to check at the end, while every extra rung-0 trial is paid in node-hours.
High-Level Architecture
The system has five components. A Sweep API accepts the spec and the budget. A Sampler proposes configurations. The ASHA Scheduler decides promotions and kills from rung results. The Worker Pool runs one trial per node and reports loss. Postgres plus a checkpoint store hold the state that survives a node or scheduler crash.
A request flows like this. The Sweep API stores the spec and the Sampler draws configurations. The Scheduler hands the next job to a free node, and that job is either a promotion (resume trial X from its rung 1 checkpoint and train to rung 2) or a fresh configuration. The worker trains, writes a checkpoint at the rung boundary and streams smoothed loss. The Divergence Guard inspects each eval. At the rung boundary the Scheduler ranks the trial against its peers and returns promote, or stop and release.
Every component has one job. The Sampler proposes. The Scheduler decides. The Workers train and never decide anything. Postgres holds the truth, so a restarted scheduler rebuilds its rung tables from rung_result rows. The checkpoint store holds 18.2 GB per paused trial.
The scheduler is stateless and workers are dumb. All decisions are a pure function of the rung_result table, so a scheduler crash loses nothing and a decision can be replayed for audit.
The Sampler and Search Space
The Sampler’s job is to turn the spec into configurations that waste as few trials as possible on obviously bad regions.
The non-obvious part is that learning rate and batch size are not independent. Post 34 used the square root rule, so the best learning rate moves with batch size. If we sample lr and bs independently, a large share of the pool lands far from the ridge and tells us nothing. The fix is to sample the learning rate as an offset from the batch-scaled reference, d = log10(lr / lr_ref(bs)), so every sampled point sits in the same relative position to the ridge.
The simulation world below uses independent log-uniform lr over 10^-4.2 to 10^-2.4, which is the harder case. It is the code that ran:
# Synthetic learning-curve world for a 1.3B proxy model (20B token budget per trial)
import numpy as np
TOK_FULL = 20e9
EVAL_EVERY = 0.25e9
def sample_config(rng):
return {
"lr": float(10 ** rng.uniform(-4.2, -2.4)),
"bs": int(rng.choice([524_288, 1_048_576, 2_097_152, 4_194_304])),
"wd": float(rng.choice([0.0, 0.05, 0.1, 0.2])),
"warm": float(rng.choice([0.002, 0.01, 0.03])),
}
def lr_opt(bs):
return 3e-4 * (bs / 1_048_576) ** 0.5
def true_loss(cfg, t):
"""Noise-free loss after t tokens; cfg['diverge_at'] is set by make_trial."""
d = np.log10(cfg["lr"]) - np.log10(lr_opt(cfg["bs"]))
linf = 2.05 + 0.9 * d**2 + 0.3 * abs(cfg["wd"] - 0.1) + 1.0 * abs(cfg["warm"] - 0.01)
tau = 0.5e9 * 10 ** (-1.2 * d) * (cfg["bs"] / 1_048_576) ** 0.3
amp = 1.8 + 0.5 * max(0.0, -d)
return linf + amp * (1.0 + t / tau) ** -0.45
def make_trial(cfg, rng):
d = np.log10(cfg["lr"]) - np.log10(lr_opt(cfg["bs"]))
p = 0.6 if d > 0.75 else (0.15 if d > 0.5 else 0.0)
cfg = dict(cfg)
cfg["diverge_at"] = float(rng.uniform(0.1e9, 1.0e9)) if rng.random() < p else None
cfg["noise"] = 0.02 * (1 + 2 * max(0.0, d))
cfg["final"] = np.inf if cfg["diverge_at"] else float(true_loss(cfg, TOK_FULL))
return cfg
def observe(cfg, t, rng):
"""Smoothed loss at token count t: mean of the last 4 evals, so sigma/2."""
if cfg["diverge_at"] is not None and t >= cfg["diverge_at"]:
return float("nan")
sig = cfg["noise"] * (max(t, 1e8) / 1e9) ** -0.15 / 2
return float(true_loss(cfg, t) + rng.normal(0, sig))Premium Content
Unlock the full article along with everything else in the archive — all in one place.