Explain learning rate scheduling strategies and how to pick one
Written by the mlprep team · Updated
Walk me through learning rate scheduling. What are the common strategies, and how do you choose between them? Why do transformers specifically need warmup?
Why scheduling matters#
Early training: parameters are far from a good solution. Large steps useful, but gradients may be noisy — especially for adaptive methods like Adam where moment estimates are not yet stable.
Late training: near a minimum. Large steps cause bouncing around the optimum. Small steps allow fine-grained convergence.
A fixed learning rate is a compromise that's suboptimal at both stages.
Warmup#
Start with a very small LR, linearly increase to target LR over N_warmup steps:
η(t) = η_max · (t / N_warmup) for t < N_warmup
Why transformers need it: in Adam/AdamW, the second moment estimate v starts at 0. In early steps, v̂ is very small (due to bias correction: v̂ = v/(1-β₂ᵗ)), making the update magnitude η/√v̂ very large. Without warmup, early updates can be orders of magnitude larger than intended, destabilizing training irreversibly.
Warmup gives Adam time to build up reliable second-moment estimates before applying full learning rates. Typically N_warmup ≈ 1-4% of total steps.
Cosine annealing#
Smoothly decays LR following a cosine curve:
η(t) = η_min + ½·(η_max - η_min)·[1 + cos(π·t/T)]
Starts high (fast progress), decays smoothly (avoids sharp transitions), ends near zero (fine convergence). Most common schedule for modern transformers and CNNs.
Cosine with restarts (SGDR): restarts the cosine cycle periodically, with each cycle potentially doubling in length. Allows escaping local minima — the LR spikes back up briefly before decaying again. Useful when training longer.
Linear decay#
Simply: η(t) = η_max · (1 - t/T). Very common for BERT fine-tuning. Simple, fast, effective.
Step decay#
Reduce LR by a factor (commonly 0.1) every k epochs:
η(t) = η₀ · γ^(floor(t/k))
Classic schedule for CNNs (ResNet paper used this). Produces sudden drops which can initially destabilize training. Cosine annealing is generally smoother and preferred.
Cyclic LR (CLR)#
Oscillate LR between a minimum and maximum on a cycle. The intuition: cycling allows the optimizer to explore the loss landscape rather than converging to a narrow minimum. Often achieves better generalization than monotone decay. One-cycle policy (fast.ai): ramp up then down, momentum inversely cycled.
Finding the base learning rate#
LR range test (Smith, 2017): run training for a few hundred steps while linearly increasing LR from very small to very large. Plot loss vs LR. Pick the LR just before loss starts increasing rapidly — that's your upper bound. Use 1/3 to 1/10 of that as your base LR.
Practical defaults#
| Model type | Schedule | Typical values | |-----------|---------|---------------| | Transformer (train from scratch) | Warmup + cosine | N_warmup=4k steps, η_max=1e-4 | | Transformer (fine-tune) | Warmup + linear decay | N_warmup=0.1×T, η=2e-5 to 5e-5 | | ResNet | Step decay | η₀=0.1, decay by 0.1 at epochs 30, 60, 90 | | General NN | Cosine annealing | Always reasonable starting point |
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Warmup: start LR small, ramp to target — required for Adam/AdamW because early moment estimates are unreliable and cause large unstable updates. Cosine annealing: smooth LR decay following cos curve — best general-purpose schedule. Step decay: legacy CNN schedule, abrupt drops, cosine preferred. Linear decay: simple, common for BERT fine-tuning. Use LR range test to find base LR. Transformers: warmup + cosine or linear. CNNs: cosine or step.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- How do you set the warmup duration? Is there a principled approach or is it heuristic?
- What is the "1cycle policy" and why does cycling momentum inversely with LR help?
- In distributed training across many GPUs, the effective batch size scales up. How should you adjust the learning rate?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions