ML Systems Lab Open interactive version →
Intermediate 45 min read lr-schedulewarmupcosinecyclicone-cycle

Learning Rate Schedules

Warmup, cosine annealing, cyclic LR, and why the schedule shape changes what you find.

You are training a ResNet from scratch. You pick a learning rate and run 90 epochs. If you picked too high — say $α = 0.1$ when $0.01$ is appropriate — loss oscillates from epoch 1 and the model never converges. If you picked too low — $α = 0.0001$ — loss decreases smoothly but stops at 72% accuracy when the same architecture should reach 76%. Congratulations, you found a mediocre minimum and permanently settled there. No single fixed learning rate gives you both the early progress you need and the fine-grained convergence required to reach the best basin. This is not a tuning problem. It is a structural mismatch between one constant value and a landscape that requires different step sizes at different phases of training.

The solution is to make the learning rate change over time. But how? The crudest version is step decay: drop $α$ by a factor of 10 at epoch 30 and epoch 60. This is the classic ResNet schedule and it works. The problem is the suddenness. Wherever the optimizer happens to be at epoch 30, that basin is now where it will stay — a sharp drop removes the energy needed to escape. If the optimizer landed in a slightly sharp basin at epoch 29, it is now trapped there.

Before we even get to decay strategies, there is a problem at the very start. Early in training, gradient directions are unreliable: weights are far from any useful configuration, batch statistics are noisy, and Adam's second moment estimate $v_t$ has not stabilized from zero. Applying the full learning rate at step 1 means taking large steps in arbitrary directions. Warmup — linearly ramping $α$ from near-zero to the target value over the first 1%–5% of training steps — gives gradient estimates time to accumulate before large steps are applied. For transformers, skipping warmup causes early embedding corruption that is nearly impossible to recover from.

NOT this. Most people think warmup is an Adam-specific trick to work around bias correction. Actually, warmup solves a different problem: gradient direction reliability. Even with perfect bias correction, the gradient direction at step 1 is computed on one mini-batch of a randomly-initialized model — it is essentially noise. Warmup says "do not trust this yet, take small steps until the signal stabilizes." Bias correction fixes the magnitude of early moments; warmup is about not acting aggressively on unreliable directions.

After the stable phase, cosine annealing replaces step decay's abrupt drop with a smooth curve: $α(t) = α_{min} + 0.5(α_{max} - α_{min})(1 + cos(πt/T))$. The gradual decrease means the optimizer keeps exploring broadly early and narrows its search gradually rather than stopping abruptly. Empirically, cosine annealing finds flatter basins than step decay, delivering 0.5%–2% better test accuracy on standard benchmarks. The mechanism: in the high-$α$ phase, the optimizer can still occasionally escape mediocre basins. As $α$ decreases continuously, exploration narrows and the optimizer settles into the flattest basin it has found.

OneCycleLR (Smith, 2018) goes further: ramp $α$ up from $α_{min}$ to a peak 5–10x higher than a typical constant rate over 30% of steps, then cosine decay down over the remaining 70%. The high-$α$ peak phase is aggressive exploration. The long decay phase is fine-grained convergence. This "super-convergence" has achieved matching accuracy in 10–20x fewer epochs on some tasks. The canonical transformer schedule — linear warmup, cosine decay to near zero — is structurally identical: aggressive early phase, extended fine-grained final phase.

Key points

Takeaway

Learning rate schedules change which regions of the loss landscape are accessible: warmup prevents corrupt early steps, cosine annealing prevents premature basin-locking, and OneCycleLR combines aggressive exploration with fine-grained convergence — together they are worth 5%–10% accuracy over a naive fixed rate.

Recap

Check your understanding

Q1. A transformer language model diverges in the first 100 training steps when trained with Adam and α=1e-4, β2=0.999. No warmup is used. What is the likely cause and fix?

Q2. Why does cosine annealing consistently outperform step decay in practice, even though both eventually reduce the learning rate to the same final value?

Q3. Two models train with OneCycleLR: Model A uses a peak lr of 0.1, Model B uses a peak lr of 0.01 (standard for that architecture). Both train for the same number of steps. Which two of the following statements are true?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →