Why Warmup Works
Adam’s noisy second moments, early instability, and how warmup tames them.
Remove the warmup from a Post-LN transformer trained with Adam and it may never train properly; remove it from a Pre-LN transformer and little changes. Warmup is nearly universal, yet its explanation has moved from the variance of Adam's statistics, to the size of early updates, to the curvature of the early landscape. This lesson derives each mechanism, weighs the experiments for and against it, and asks what each one predicts about how long warmup should last.
What you’ll learn
- Summarize the evidence that warmup matters, for large-batch SGD and for Post-LN transformers, and the changes that remove the need for it.
- Derive RAdam's approximate SMA length and its variance rectification, and explain why an untuned linear warmup over steps does as well.
- Derive how Adam's momentum bias correction inflates its first updates by , and relate early update size to weight norms and to the critical batch size.
- Explain the curvature account (the stability threshold, sharpness reduction versus progressive sharpening, self-stabilization and Adam's preconditioned sharpness), and state what remains open.
What needs explaining
Learning-Rate Schedules & Warmup showed the first piece of evidence: ResNet-50 at a batch of 8,192 trained as well as at 256 only with a gradual warmup. Transformers supplied the second. Xiong et al. (2020) trained the original Post-LN transformer with Adam on IWSLT14 German–English translation. Without warmup it reached a BLEU score of 8.45, against about 34 with a 4,000-step warmup; with a 500-step warmup it reached 31.16 at a peak rate of but only 2.77 at . On the same task, Liu et al. (2020) saw the training loss stall near 10 without warmup and reach about 3 with it. At larger scale, a longer warmup makes the final loss less sensitive to the peak rate, most clearly for the larger models tested (Wortsman et al., 2023).
| Hypothesis | Mechanism | Time scale it predicts | Support | Challenge |
|---|---|---|---|---|
| Unreliable second moments (Liu et al., 2020) | averages few squared gradients, so the per-coordinate rate is erratic | about steps | freezing the weights for 2,000 steps while accumulates removes the failure | and move together, so update sizes are regular even when is not (Ma & Yarats, 2021) |
| Oversized early updates (Ma & Yarats, 2021; Kosson et al., 2024) | momentum bias correction, small initial weights and correlated early gradients make the first updates effectively large | a few times steps for the bias correction; longer for weight norms | normalizing update sizes reduces the benefit of warmup | normalizing their size alone does not remove it |
| Early curvature (Gilmer et al., 2022; Kalra & Barkeshli, 2024) | the sharpness, or Adam's preconditioned sharpness, starts above and must fall first | as long as the sharpness takes to fall | sharpness traces; warmup matches better initializations; works for SGD too | needs Hessian measurements that are expensive at scale |
| Architecture (Xiong et al., 2020) | Post-LN's output-side gradients are large at initialization | until those gradients settle | Pre-LN trains without warmup | Pre-LN models are still warmed up in practice, for the other reasons |
Adam's second moment from a handful of samples
Write Adam's step on one coordinate as , with the adaptive learning rate (taking ). Liu et al. (2020) asked how noisy is early on. Model the coordinate's gradients at initialization as i.i.d. . At , , and since has a scaled inverse chi-squared distribution with one degree of freedom, has infinite variance. How fast does that improve?
Treat the bias-corrected moving average as a simple moving average (SMA) of the last squared gradients, so that . Choose so that the SMA has the same center of mass, the same average age of its terms, as the exponential average, whose weights on ages are :
The right-hand side is the average age of an SMA of length . Solving for it gives the effective number of samples. For the weights are nearly equal and , with exactly; the limit is 1,999 for and is approached only after a few thousand steps:
Now is scaled inverse chi-squared with degrees of freedom. Its first two moments and the first-order (delta-method) approximation give a variance that is finite only for and decays like . (The exact variance, finite for , is about 250 times larger at than at .)
RAdam multiplies the adaptive step by , chosen so that its variance equals the asymptotic one, and while it switches adaptivity off and takes plain momentum steps:
A fixed schedule in disguise. Ma & Yarats (2021) noted that exactly when , for every from up to , and that depends only on and , never on the gradients. RAdam is therefore four steps of heavy-ball momentum followed by Adam with a fixed warmup factor : for , is at step 100, at step 1,000 and at step 5,000. They also questioned the premise. Early gradients are not zero-mean, which shrinks the variance of ; more importantly, and move together. At , , so every coordinate moves by exactly : the update has zero spread at the very step where is infinite.
To compare warmups, they defined the effective warmup period of a warmup factor . A linear ramp over steps has a period of about . With , RAdam's factor has a period of about 1,030 steps and a linear ramp over steps about 1,000. On ImageNet with ResNet-50, language modeling on WikiText-103 and English–German translation, that untuned linear warmup performed like RAdam, and they recommended it as the default.
Why can RAdam be described as Adam with a fixed warmup schedule?
- Because it resets to zero whenever the loss rises
- Because it uses a larger during the first steps
- Because its rectifier depends only on the step and on , and its momentum-only phase () lasts exactly four steps
- Because it raises gradually from zero
Show the answer
C. Because its rectifier depends only on the step and on , and its momentum-only phase () lasts exactly four steps
and therefore are deterministic functions of and , so RAdam multiplies Adam's step by the same sequence on every problem, after four momentum steps. That is a warmup, and its effective length of about steps is what an untuned linear warmup over steps reproduces.
Updates that are too large
Shift attention from to the update itself, , the step measured in units of . Even at a minimum, where the gradients are pure noise and nothing needs fixing, Adam's first updates are several times larger than its later ones.
Let one coordinate's gradients be i.i.d. with mean and variance , as at a minimum. Unrolling , independence gives
Bias correction divides by , which is exact for a constant gradient but too much for noise, whose terms partly cancel. Since :
So the root-mean-square update starts at (exactly ) and settles at , which is for . The early excess fades over a few times steps:
With and pure-noise gradients, by what factor is Adam's first update larger, in root-mean-square, than its updates once the averages have settled?
Show the answer
4.36
. Every coordinate's first step is exactly , while the settled steps have root-mean-square and median about , close to the that Ma & Yarats measured in simulation. With the factor is about 14 at and still about at : higher momentum needs longer protection.
Ma & Yarats (2021) simulated exactly this case, i.i.d. zero-mean gradients for 25,000 parameters with , and : the median update started at and settled near only after about 40 steps, and in a real EMNIST network it took about 100. SGD's steps at a minimum are proportional to the small gradients, so a nearly converged model can be restarted with SGD without warmup; with Adam it cannot, one reason adaptive methods need warmup more than SGD does.
Kosson, Messmer & Jaggi (2024) pushed the update-size view further for GPT-2-style models trained with AdamW and Lion, and found three ways in which early updates are too large:
- The bias correction above. Removing the correction removes the inflation.
- Large relative to the weights. What changes a neuron's behavior is the direction of its weight vector. The angular update, the angle between and , is large while the weight norm is small compared with the equilibrium norm that the learning rate and weight decay eventually produce (What Weight Decay Really Does).
- Too correlated to average. Early in training the gradients of different examples point in similar directions, so the critical batch size is small (Gradient Noise, Batch Size & Scaling Rules) and a large batch at the full rate changes the network's internal representations too fast.
Optimizers that normalize the size or the angle of every update reduced the benefit of warmup but did not remove it; controlling the change in the representations, or very high momentum together with the other fixes, came close to removing it in their setting. The authors still recommend a short warmup in practice, since fully eliminating it took substantial changes to the optimizer.
The curvature account
Gradient descent multiplies the error along the top Hessian eigenvector by at every step, so it is stable only below the stability threshold . Gilmer et al. (2022) tracked the sharpness across many architectures and tasks: training with SGD and momentum stayed stable only while it remained roughly where . Configurations that diverged without warmup started out highly curved, and warmup let fall gradually until the peak rate was safe; warmup alone matched the gains of initialization schemes designed for the same failures (MetaInit, GradInit, Fixup). For Adam the relevant quantity is the sharpness of the preconditioned Hessian, with .
Kalra & Barkeshli (2024) studied warmup systematically with SGD and Adam on fully connected networks, ResNets and transformers, and found two regimes, depending on the initialization and the parameterization:
- Natural progressive sharpening (). The sharpness rises on its own while warmup raises the rate, a head-on collision: the run reaches the threshold and then rides it, , in a persistent cycle of catapults for the rest of the warmup.
- Natural sharpness reduction (). The sharpness already falls on its own. A fast warmup still hits the threshold and triggers a few separate catapults; a slower one can ride the natural decrease, so lengthening warmup makes the catapults later and milder.
Either way the payoff is the same: warmup lets the run tolerate a larger target rate, and the target rate largely sets the final performance. For Adam they found the preconditioned sharpness starts high even at large batch sizes, where the statistics are accurate, and so located Adam's need for warmup in curvature rather than in a shortage of samples. Two fixes follow. GI-Adam initializes the second moment with the squared initial gradient, , instead of zero, which needs no second-moment bias correction and consistently matched or improved on standard Adam; and the starting rate can be chosen by deliberately triggering a catapult, which in some settings removed the need for warmup altogether.
Warmup from theory, and what is open
For convex problems, Defazio, Cutkosky, Mehta & Mishchenko (2023) bounded the loss of SGD's last iterate for an arbitrary schedule in terms of the sequence of gradient norms, and found the schedule that minimizes the bound. With weights it is
Key takeaways
- Warmup matters most for large-batch SGD, adaptive optimizers and Post-LN transformers, whose output-side gradients at initialization are of order at every depth, against for Pre-LN.
- RAdam treats as an average of samples and rescales the step to equalize its variance; since depends only on and , it is a fixed warmup, matched by an untuned linear warmup over steps.
- For zero-mean gradients, momentum bias correction inflates Adam's root-mean-square update by , at for . Small initial weight norms and a small early critical batch size make early updates effectively large as well.
- In the curvature account, training is stable only while the sharpness (for Adam, the preconditioned sharpness) stays below about ; warmup gives it time to fall, naturally or through self-stabilizing instabilities, so that a larger peak becomes usable. No single mechanism explains every case.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
By RAdam's approximation, after steps with , Adam's second-moment estimate is worth about how many independent squared gradients?
- 1, because the first gradient dominates
- About 10
- About 1,000, the averaging horizon
- About 1,999, the limit
Show the answer
B. About 10
. For the bias-corrected average weights its terms almost equally, so it is worth about samples; it approaches only after a few thousand steps.
According to Xiong et al. (2020), why does the original Post-LN transformer need warmup while a Pre-LN transformer often does not?
- Post-LN transformers have more parameters
- The Pre-LN models were trained with a different optimizer
- Post-LN transformers have no residual connections
- At initialization the gradients of Post-LN's last layers are of order whatever the depth, while in Pre-LN they shrink like , so a large rate is unstable only for Post-LN
Show the answer
D. At initialization the gradients of Post-LN's last layers are of order whatever the depth, while in Pre-LN they shrink like , so a large rate is unstable only for Post-LN
Their Theorem 1 bounds the last feed-forward layer's gradient by for Post-LN and for Pre-LN. Post-LN trains with warmup anyway; Pre-LN trained without it matched the Post-LN baselines on translation and BERT.
Kosson et al. (2024) found that Adam's first updates are inflated by its momentum bias correction. Which change removes that inflation?
- Dropping the correction of the first moment
- Dropping the correction of the second moment
- Raising toward 1
- Lowering to zero
Show the answer
A. Dropping the correction of the first moment
For noisy gradients, dividing the momentum by overcorrects: the averaged noise partly cancels, so the corrected estimate is too large by in root-mean-square. Without the correction the momentum starts small and grows, which acts like a short built-in warmup.
Kalra & Barkeshli (2024) varied the warmup length and the target (peak) rate separately. What did they conclude is warmup's main benefit?
- Collecting accurate second-moment statistics before large steps are taken
- Reducing the noise in each gradient estimate early in training
- Letting the network tolerate a larger target rate, by moving it into better-conditioned regions; at a fixed target rate a longer warmup helps only marginally
- Lowering the final loss by a large margin at any fixed target rate
Show the answer
C. Letting the network tolerate a larger target rate, by moving it into better-conditioned regions; at a fixed target rate a longer warmup helps only marginally
Performance was set mainly by the target rate. Warmup raises the largest target rate that trains without failure by letting the sharpness, for Adam the preconditioned sharpness, fall first, either naturally or through self-stabilizing instabilities. For a fixed target, extra warmup mostly keeps the run further from the failure boundary.
Further reading
- L. Liu, H. Jiang, P. He, W. Chen, X. Liu, J. Gao & J. Han, "On the variance of the adaptive learning rate and beyond," ICLR (2020).
- J. Ma & D. Yarats, "On the adequacy of untuned warmup for adaptive optimization," AAAI (2021).
- R. Xiong, Y. Yang, D. He, K. Zheng, S. Zheng, C. Xing, H. Zhang, Y. Lan, L. Wang & T.-Y. Liu, "On layer normalization in the transformer architecture," ICML (2020).
- A. Kosson, B. Messmer & M. Jaggi, "Analyzing & reducing the need for learning rate warmup in GPT training," NeurIPS (2024).
- D. S. Kalra & M. Barkeshli, "Why warmup the learning rate? Underlying mechanisms and improvements," NeurIPS (2024).