Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Driving speed and road curvature
On a straight road you can drive fast; on a hairpin bend the same speed sends you off the road. The safe speed depends on the curvature. For gradient descent, the learning rate is the speed and the loss surface’s curvature is the bend. Training dynamics is the study of how the two interact. Networks, it turns out, steer themselves into regions where they are driving right at the limit.
Large training runs fail through early instabilities, loss spikes and badly transferred hyperparameters, and each failure costs real compute. Warmup, an understanding of curvature-limited step sizes, and width-transferable parametrisations (μP) are the practical tools that make a schedule tuned on a small model work on the big one.
- 1. A learning rate that is fine on a flat region may…
- 2. Warmup means…
- 3. μP is about…
Level 1: Beginner
★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.Curvature and step size by hand
Quadratic. For f(x) = λx²/2, gradient descent gives x ← (1 − ηλ)x.
- It is stable if |1 − ηλ| < 1, that is, λ < 2/η.
- With η = 0.1 the threshold is 20: λ = 19 gives a factor of −0.9 per step (converging oscillation), and λ = 21 gives −1.1 per step (divergence).
- λ = 10 with η = 0.1 converges in one step (factor 0).
Sharpness. For a network, the relevant λ is the largest eigenvalue of the Hessian of the loss. Power iteration on Hessian–vector products finds it without forming the Hessian. For diag(12, 3, −1) it returns 12.
Warmup and cosine decay. A common schedule:
- Warmup: η_t = η_peak (t + 1)/T_w for the first T_w steps.
- Cosine decay: η_t = η_peak · ½(1 + cos(π p)), where p is the fraction of the decay completed.
With a peak of 1, 10 warmup steps and 100 steps in total, the rate is 0.1 at step 0 and 1.0 at step 9, and halfway through the decay (step 55) it is 0.5.
μP scaling (for Adam, hidden matrices): a learning rate tuned at width 256 transfers to width 4096 as 1 × 10⁻² × 256/4096 = 6.25 × 10⁻⁴.
- 1. Stability threshold on curvature for η = 0.05?
- 2. With η = 0.1 and λ = 15, each step multiplies x by…
- 3. Power iteration finds…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Why warm up?
Reasons.
- At the start, curvature can be high and gradients large, so full-size steps overshoot.
- Adam’s second-moment estimate v is based on very few gradients, so its per-parameter step sizes are unreliable; bias correction makes the first steps effectively large.
- In transformers, post-LayerNorm architectures have large gradients near the output at initialisation (Xiong et al., 2020).
Warmup keeps steps small until these settle.
Exercise 1 (Adam on a 6-layer tanh MLP fitting sin 2x, 400 steps with cosine decay, 2 seeds):
| peak learning rate | warmup steps | largest loss in the first 100 steps | mean final loss |
|---|---|---|---|
| 0.03 | 0 | 4.96 | 8.6 × 10⁻⁶ |
| 0.03 | 100 | 0.325 | 3.4 × 10⁻⁶ |
| 0.1 | 0 | 2.44 | 0.118 |
| 0.1 | 100 | 0.348 | 4.5 × 10⁻⁶ |
- Without warmup, Adam’s first steps threw the loss up by an order of magnitude: from 0.2 at the start to about 5.
- At peak 0.03 the run recovered. At peak 0.1 it ended far worse (0.118 against a near-perfect fit).
- A 100-step warmup removed the spike at both peaks.
sched = torch.optim.lr_scheduler.SequentialLR(opt, [
torch.optim.lr_scheduler.LinearLR(opt, start_factor=0.01, total_iters=warmup),
torch.optim.lr_scheduler.CosineAnnealingLR(opt, T_max=total - warmup)], milestones=[warmup])- 1. Without warmup at peak 0.03, the early loss rose to about…
- 2. One reason warmup helps Adam is that early second-moment estimates are…
- 3. Cosine decay ends with a learning rate of…
Level 3: Advanced
★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.Theory: edge of stability and μP
Edge of stability. Cohen et al. (2021) found that full-batch gradient descent shows two phases:
- Progressive sharpening: the sharpness grows during training.
- Once it reaches 2/η, it stops growing and hovers at about 2/η. The loss keeps decreasing, but no longer monotonically.
Classical analysis, which assumes λ < 2/η, does not explain this. Damian, Nichani and Lee (2023) showed a self-stabilisation mechanism: the oscillation along the top eigenvector itself pushes the iterate toward flatter regions, as in the demo. Adaptive optimisers show an analogous “adaptive edge of stability”.
Catapults. Starting with sharpness well above 2/η, the loss first spikes, then the network moves to a much flatter region and continues (Lewkowycz et al., 2020). Exercise 2’s η = 0.2 run started at sharpness 12 > 10 and was pushed down to 9.9.
μP (maximal update parametrisation). Yang and Hu (2021) and Yang et al. (2022) showed that under the standard parametrisation, the best learning rate shifts with width. μP instead scales:
- the output layer’s initialisation (and multiplier) by 1/width;
- hidden-layer learning rates (for Adam) by 1/width;
- input-layer settings as for fixed width.
Every layer’s features then change by order 1 per step at any width, so the optimal hyperparameters stay put as width grows (“μTransfer”). This was used to tune GPT-3-scale models from small proxies.
Interview questions.
- Why does the loss sometimes oscillate yet still go down? Training at the edge of stability: gradient descent oscillates along the sharpest direction while making progress in the others.
- How do you choose the warmup length? Typically 1–5% of training, or a few thousand steps for transformers. Longer for larger peak learning rates and batch sizes.
- 1. At the edge of stability the sharpness…
- 2. Under μP with Adam, hidden-layer learning rates scale like…
- 3. A catapult phase is…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Watching the sharpness during training
History.
- P. Goyal et al. (2017) used linear warmup for large-batch ImageNet training.
- I. Loshchilov and F. Hutter (2017) introduced cosine (SGDR) schedules.
- A. Lewkowycz et al. (2020) described the catapult phase.
- J. Cohen et al. (2021) described the edge of stability.
- G. Yang et al. (2022) introduced μP and μTransfer.
Exercise 2. Full-batch gradient descent on a 1-32-32-1 tanh MLP fitting sin 2x (64 points). The sharpness is measured every 100 steps by power iteration on finite-difference Hessian–vector products.
| η | 2/η | sharpness at steps 0, 300, 600, 900, 1200, 1500 | loss at those steps |
|---|---|---|---|
| 0.05 | 40 | 12.1, 24.3, 26.9, 29.2, 31.5, 33.8 | 0.219, 0.016, 0.010, 0.0068, 0.0044, 0.0028 |
| 0.1 | 20 | 12.1, 20.3, 20.2, 20.0, 20.0, 20.0 | 0.219, 0.012, 0.011, 0.0093, 0.0072, 0.0056 |
| 0.2 | 10 | 12.1, 10.0, 9.9, 9.9, 9.9, 9.9 | 0.219, 0.016, 0.011, 0.0083, 0.0068, 0.0058 |
| 0.4 | 5 | 12.1, then diverged | — |
- Progressive sharpening. With η = 0.05 the sharpness climbed steadily from 12 toward its ceiling of 40.
- The edge of stability. With η = 0.1 it rose to 20.0 = 2/η and stayed exactly there for over 1000 steps, while the loss kept falling.
- Self-stabilisation. With η = 0.2 the initial sharpness (12.1) already exceeded 2/η = 10. Instead of diverging, gradient descent pushed it down to 9.9 and continued.
- Too large to recover. With η = 0.4 (ceiling 5) training diverged.
- The learning rate decided the curvature. The final sharpness was set by the learning rate, not by the problem: larger steps settled in flatter regions.
Training dynamics in AI, robotics and aerospace
- Foundation models for robotics and Earth observation: μP-style tuning on small proxies saves enormous compute when scaling up.
- Stable fine-tuning: warmup protects pretrained weights from large early updates when adapting models to new sensors or tasks.
- Monitoring: loss spikes and oscillations in long runs are interpretable through curvature (sharpness) and step size. Logging both speeds diagnosis.
References
- J. M. Cohen, S. Kaur, Y. Li, J. Z. Kolter, A. Talwalkar (2021). “Gradient descent on neural networks typically occurs at the edge of stability.” Proc. ICLR.
- A. Lewkowycz, Y. Bahri, E. Dyer, J. Sohl-Dickstein, G. Gur-Ari (2020). “The large learning rate phase of deep learning: the catapult mechanism.” arXiv:2003.02218.
- A. Damian, E. Nichani, J. D. Lee (2023). “Self-stabilization: the implicit bias of gradient descent at the edge of stability.” Proc. ICLR.
- G. Yang, E. J. Hu et al. (2022). “Tensor Programs V: tuning large neural networks via zero-shot hyperparameter transfer.” Advances in NeurIPS 34.
- P. Goyal et al. (2017). “Accurate, large minibatch SGD: training ImageNet in 1 hour.” arXiv:1706.02677.