Foundations to Frontier
Tests
A. Mathematical Foundations › A6 Optimization › Optimization for ML

Learning-Rate Schedules: Warmup, Cosine, Cyclical

The learning rate is the most important hyperparameter of stochastic training, and the best value changes over the run: start gently, move fast, then settle. You will learn why annealing removes SGD's noise floor, how step, cosine, inverse-time, cyclical, one-cycle and warmup–stable–decay (WSD) schedules behave, why warmup is essential for Adam and transformers, and how a learning-rate range test picks a good peak rate in a single run.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Start gently, run, then slow down to park

Driving into a parking space, you don’t hold one speed. You pull away gently, cruise, and slow right down as you arrive. Training a model is similar. A schedule changes the step size over time:

  • a short warmup so the first steps don’t throw the model off;
  • a long phase at a high rate to make fast progress;
  • a cool-down to a small rate so the model settles precisely instead of jittering around the answer.
Shape the learning rate over time
η_t1e-41e-21e01e2
■ constant: final E[f] 1.7e-1■ step: final E[f] 2.8e-3■ cosine: final E[f] 4.6e-3■ wsd: final E[f] 1.5e-2
A large learning rate makes fast early progress but leaves SGD bouncing at a noise floor ∝ ησ². Every good schedule ends by annealing η toward zero, which squeezes out the noise. Cosine, step and WSD all do this, in different shapes. Warmup ramps up gently at the start. It matters little on this quadratic but a lot for transformers and Adam, whose early statistics are unreliable. Above η = 2/μ = 2 the constant schedule diverges.
Why engineers care

The difference between a good and a bad schedule can be worth more than a bigger model. Every modern training recipe, from vision backbones to robot policies to large language models, specifies warmup length, peak rate and decay shape.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Lowering the step size near the end of training helps the model…
  2. 2. A short ramp-up at the start is called…
  3. 3. SGD with a constant large step ends up…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Common schedules (t = step, T = total)

  • Step decay: ηt=η0γ⌊t/s⌋\eta_t = \eta_0\gamma^{\lfloor t/s\rfloor}, e.g. ×0.1 every T/3T/3.
  • Inverse time: ηt=η0/(1+t/τ)\eta_t = \eta_0/(1 + t/\tau), matching the theory of A6.3-2.
  • Cosine annealing (Loshchilov and Hutter, 2017): ηt=ηmin⁡+12(ηmax⁡−ηmin⁡)(1+cos⁡(πt/T))\eta_t = \eta_{\min} + \tfrac12(\eta_{\max} - \eta_{\min})(1 + \cos(\pi t/T)).
  • Linear warmup: ηt=ηmax⁡(t+1)/W\eta_t = \eta_{\max}(t + 1)/W for t<Wt < W.
  • Cyclical / triangular (Smith, 2017): bounce between a base and a peak.
  • One-cycle: warm up to a high peak, then anneal to nearly zero in a single cycle.
  • Warmup–stable–decay (WSD): warmup, a long constant phase, then a short final decay. A run can be extended or branched from any checkpoint (Hu et al., 2024).
📝 Quick check (Level 1)
0/3 answered
  1. 1. Cosine annealing at t = T/2 gives…
  2. 2. WSD's decay happens…
  3. 3. Linear warmup over W steps starts at…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Why decay at the end?

From A6.3-1, constant-step SGD settles where the error variance is about ησ2/(2μ)\eta\sigma^2/(2\mu). Large η\eta buys fast early progress, and small η\eta buys a low floor. A schedule gets both: the high phase moves far, and the decay squeezes the noise out. On a noisy quadratic, decaying from η=0.2\eta = 0.2 cuts the final expected loss about 25× compared with holding it constant.

Why warmup?

  • Adam’s second-moment estimate v^\hat v is unreliable for the first ~1/(1−β2)1/(1 - \beta_2) steps, so updates can be huge. Warmup (or RAdam’s rectification) tames them (Liu et al., 2020).
  • Large batches with the linear-scaling rule need warmup to avoid early divergence (Goyal et al., 2017).
  • Transformers with post-LayerNorm are unstable without warmup (Xiong et al., 2020). Early curvature is high, and warmup lets the network move to flatter regions first.

Choosing the peak: the LR range test

Increase the learning rate exponentially over a few hundred steps and plot the smoothed loss. Loss falls, bottoms out, then explodes. A peak LR near the bottom (or a few times below it) works well for one-cycle schedules (Smith, 2017). It costs one short run instead of a grid search.

🐍 Exercise 1: schedules on a noisy quadratic
Implement constant, step, cosine and inverse-time schedules (with optional warmup) and run SGD on a noisy quadratic. Show that annealed schedules beat a constant step by a large factor.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Annealing helps mainly because SGD's noise floor scales with…
  2. 2. Warmup is especially important for…
  3. 3. The LR range test increases the learning rate…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Average step of cosine annealing

1T∫0Tηmax⁡2(1+cos⁡(πt/T)) dt=ηmax⁡2+ηmax⁡2π[sin⁡(πt/T)]0T=ηmax⁡2\frac1T\int_0^T\frac{\eta_{\max}}2(1 + \cos(\pi t/T))\,dt = \frac{\eta_{\max}}2 + \frac{\eta_{\max}}{2\pi}[\sin(\pi t/T)]_0^T = \frac{\eta_{\max}}2. ∎ Cosine therefore spends half its “budget” of total movement compared with a constant schedule, front-loaded where progress is cheapest.

Annealing in the noise-ball model

With mt+1=(1−ηtμ)2mt+ηt2σ2m_{t+1} = (1 - \eta_t\mu)^2m_t + \eta_t^2\sigma^2, a slowly decreasing ηt\eta_t keeps mtm_t near its instantaneous equilibrium ηtσ2/(2μ)\eta_t\sigma^2/(2\mu). Ending at ηT→0\eta_T\to0 drives the equilibrium to zero. Decaying too fast freezes the iterate before it has relaxed. The optimal rate balances the two, giving ηt∝1/t\eta_t\propto1/t asymptotically (A6.3-2).

Why cyclical schedules can help non-convex training

Periodically raising η\eta injects noise that can escape sharp basins. With snapshot ensembles, it also yields diverse models (Huang et al., 2017). On a convex problem, cycles only cost time.

Exercise 3.1: Average learning rate of cosine annealing from 0.2 to 0

0.2/2=0.10.2/2 = 0.1.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The average of a full cosine schedule from η_max to 0 is…
  2. 2. Decaying the learning rate too fast…
  3. 3. On a convex problem, cyclical restarts mostly…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

For a terrain-classification logistic model trained with mini-batch SGD, an LR range test over 600 steps (from 10−410^{-4} to 10) finds the smoothed-loss minimum near 0.27. A one-cycle schedule peaking there, trained once for 1500 steps, matches or beats the best of a 5-point grid of constant learning rates, each trained for the same 1500 steps. That’s five times the compute saved, with no guesswork.

🐍 Exercise 2 (research): LR range test and one-cycle
Implement mini-batch SGD with an LR function, Smith's range test and a one-cycle schedule. Compare one-cycle at the range-test peak against a grid of constant learning rates.

Schedules in AI, robotics and aerospace

  • LLM pre-training: linear warmup with cosine decay was standard (Brown et al., 2020). WSD makes continual pre-training and compute-optimal sweeps cheaper (Hu et al., 2024).
  • Vision backbones: step decay and cosine with warmup (He et al., 2016; Goyal et al., 2017).
  • Robot RL: linear decay of the learning rate (and of the PPO clip range) to zero is common practice (Schulman et al., 2017).
  • Fast prototyping: one-cycle “super-convergence” trains in a fraction of the usual epochs (Smith and Topin, 2019).

References

  1. I. Loshchilov, F. Hutter (2017). “SGDR: stochastic gradient descent with warm restarts.” ICLR.
  2. L. Smith (2017). “Cyclical learning rates for training neural networks.” WACV.
  3. L. Smith, N. Topin (2019). “Super-convergence: very fast training of neural networks using large learning rates.” SPIE.
  4. P. Goyal et al. (2017). “Accurate, large minibatch SGD: training ImageNet in 1 hour.” arXiv:1706.02677.
  5. L. Liu et al. (2020). “On the variance of the adaptive learning rate and beyond.” ICLR.
  6. R. Xiong et al. (2020). “On layer normalization in the transformer architecture.” ICML.
  7. S. Hu et al. (2024). “MiniCPM: unveiling the potential of small language models with scalable training strategies.” arXiv:2404.06395 (WSD).
  8. G. Huang et al. (2017). “Snapshot ensembles: train 1, get M for free.” ICLR.
  9. T. Brown et al. (2020). “Language models are few-shot learners.” NeurIPS.
  10. J. Schulman et al. (2017). “Proximal policy optimization algorithms.” arXiv:1707.06347.