Learning Rate Schedules & Training Loop
Shaping the descent over the whole run
One learning rate over the whole run is rarely optimal: warm-up, decay and restarts shape a trajectory that converges faster and better. This concept covers schedules and the loop that evaluates them.
What you will learn
- Explain why a static LR is a poor plan for most runs
- Choose warm-up, decay and restart strategies per schedule
- Inspect loss/weights trajectory to tune schedule knobs
What is this?
A learning-rate schedule changes the optimizer's step size over training. Modern recipes combine a short warm-up (low LR rising to peak), a long decay (step/linear/cosine toward near zero), and occasional restarts that re-explores. The schedule must match the optimizer — Adam and SGD respond differently — and is usually chosen along with batch size in a few guided runs rather than by feel.
Why do you need it?
- Early steps with too-large LR diverge; with too-small LR you waste the period where gradients are strongest.
- Decaying LR toward the end lets the optimizer settle into a sharp-but-accurate valley.
- Warm-up protects Adam's extreme early updates on huge, poorly-scaled batches.
- Restarts escape local flats and re-explore the landscape when loss plateaus.
Mental model
Landing an aircraft
LR schedule
You approach fast early (a high LR), then flare and bleed speed at the threshold (warm-up is unfewise not to mis-begin; decay is the final glide path, smoothing into the touch-down so you don't bounce off the runway).
How it works
- Warm-up: raise LR from a tiny value to a peak over 1-10% of steps — lets the optimizer build stable moments/statistics.
- Step decay: multiply LR by γ every k epochs — coarse approximation of a smooth decay.
- Cosine decay: follow the first half of a cosine from peak to ~0 — smooth annealing that lands softly.
- One-cycle: warm-up to a high peak, then cosine down below start; excellent for vision.
- Restarts: periodically raise LR again (cosine with restarts) to jump out of shallow minima.
LR over training with warm-up and cosine decay.
In production
- ImageNet classifiers train with one-cycle/multi-step cosine schedules, not constant LR.
- LLM fine-tuning uses linear warm-up + cosine decay over the final token budget.
- RL agents anneal LR and explore by episode — schedule is part of the policy training recipe.
Best practices
- Run a short LR range test to find the max stable LR; base your peak on it.
- Pair warm-up length with total steps (10% warm-up is a common default).
- Log LR alongside loss so 'improved after epoch 20' can be attributed to the schedule.
- Keep schedule tied to step counts, not epoch counts, when data size changes.
Common mistakes
- Warming up a perfectly fine constant-LR run and only adding instability.
- Decaying LR to 0 too fast — model stops sharpening and validation stagnates with slack.
- Using SGD's decay pattern on Adam (primary learning rate) without re-checking the peak.
- Relying on loss alone, when weight-norm and val-history would separate signal from noise.
Common issues
Loss spikes exactly when warm-up endsJump to a peak LR that's too high for the weights' current state
Lower the peak or make warm-up longer; verify with the LR range test.
Validation gets worse in the last 10% of trainingLR too small late → fits training noise at fine granularity
Stop decay earlier, or early-stop at the best-val checkpoint regardless of schedule.
Scheduler shows lr unchanged every stepScheduler not invoked per optimizer step (forgotten .step() call)
Call scheduler.step() each batch/epoch consistently and print lr in logs.
Debugging tips
- If loss peaks during warm-up, your peak LR is too high for the optimizer — lower by half.
- If late-training loss plateaus at a slightly-too-high value, extend/steepen the decay.
- Graph lr.tolist() against step to confirm the scheduler is actually firing (a classic silent bug).
- On restarts, val loss spikes are normal — judge by the troughs, not the peaks.
Interview checkpoint
Quick quiz
What is the primary job of warm-up in an LR schedule?
A single constant learning rate is optimal for modern deep training.