Across modern deep learning — large language models (LLMs) and vision transformers (ViTs) alike — LayerNorm + AdamW + Linear Warmup has become an unshakable default. For a long time, this combination has been treated as "proven engineering practice": practitioners know it works, but tend to see it as three independent pieces and miss the tightly interlocked dynamics between them.
This post covers:
- Deep networks rely on LayerNorm (RMSNorm), which creates local scale invariance — and that gives rise to distinctive gradient dynamics.
- In this regime our machine-learning intuitions get turned upside down: the weight norm stops representing feature strength and becomes a knob for learning progress. In theory the norm grows steadily, so SGD comes with built-in learning-rate decay — but it brakes so hard that learning stalls early. Weight decay, meanwhile, turns from a regularizer into a dynamic valve on the effective learning rate.
- How AdamW became the default: Adam keeps the gradient step size constant, so the effective learning rate brakes gently; warmup handles tiny weights (exploding gradients) and unreliable second-moment estimates early in training; AdamW fixes the L2-regularization problem with decoupled weight decay, splitting "direction updates" and "progress control" into two clean knobs.
- The original papers are listed below; the theory was largely in place by around 2020. I think it's crucial and yet widely overlooked — at least, nowhere near as famous as AdamW.
The physical root: 0-homogeneity makes "weights act as damping"
It all begins with LayerNorm (or RMSNorm). Normalization layers give the network approximate 0-homogeneity, also called scale invariance.
Definition: for network parameters w and any scalar α > 0, the output satisfies f(αw) = f(w).
As the paper "Robust Training of Neural Networks Using Scale Invariant Architectures" argues, this architecture makes the model highly robust to the scale of weight initialization, while also introducing complex gradient dynamics.
The backpropagation paradox: by the chain rule, scale invariance in the forward pass becomes an inverse-scale relationship in the backward pass:
Conclusion: in a scale-invariant network, the weight norm ‖w‖ no longer represents feature strength (changing the norm doesn't change the output); instead it becomes the optimizer's global damping coefficient (the larger the norm, the smaller the gradient).
Caveats, before anyone objects: - By 0-homogeneity and scale invariance I mean local network structures, not the network as a whole. - LayerNorm is only approximately 0-homogeneous because of its bias; RMSNorm is strictly 0-homogeneous. When I say LN, I mean both the approximate and the strict variants.
The dynamics trap: SGD has a hidden brake
In a scale-invariant network (e.g., parameters wrapped by LayerNorm), because the gradient is divided by ‖w‖, learning itself inflates the parameters, which in turn automatically lowers the learning rate.
The absolute step size decays:
Moreover, in a scale-invariant layer what matters is the weight direction ŵ = w/‖w‖. The paper "Norm matters: efficient and accurate normalization schemes in deep networks" puts it bluntly: when a layer is rescaling-invariant, "the key feature is the direction," and it derives that the effective step size of direction updates is tightly tied to ‖w‖.
The effective (relative) step size divides by another ‖w‖ — this is the effective learning rate:
This quadratic effect reveals the real reason SGD struggles in modern deep networks: the model "flatlines" not because it has converged, but because parameter inflation drives the effective learning rate toward zero on its own.
The norm grows steadily
A natural question: in a scale-invariant network, does ‖w‖ keep growing?The answer is yes, and steadily — there is a solid theoretical derivation.
By Euler's theorem for degree-0 homogeneous functions, the gradient is always orthogonal to the parameters:
So the gradient always pushes the parameters tangentially. Using the Pythagorean theorem on a single update step:wₜ₊₁ = wₜ - ηgₜ. Since wₜ ⊥ gₜ, the three vectors form a right triangle with hypotenuse wₜ₊₁:
As long as the gradient is nonzero, ‖w‖ must increase monotonically.
How weight decay's role changes in scale-invariant networks
Under SGD, WD and L2 regularization are mathematically identical, but WD no longer acts as a regularizer in the classical sense; it becomes a control knob for learning progress.
L2 Regularization versus Batch and Weight Normalization makes the key point: in networks with normalization, L2/WD often isn't regularizing the function at all; it shapes the effective learning rate by controlling the weight scale
"Norm matters" says the same thing explicitly:without WD, the norm grows without bound and the effective step size shrinks; WD keeps the norm in a narrow range, which stabilizes the effective step size.
How AdamW became king
In the classical account, Adam is a gradient-descent method with adaptive learning rates that tunes each parameter's step from its gradient history, and warmup exists because randomly initialized parameters produce very unstable gradients.
What follows isn't that old story. It's about the new properties Adam shows in modern deep networks built around LayerNorm (or RMSNorm) — in the 0-homogeneous setting — and its inevitable coupling with weight decay and warmup.
Adam's improvement: constant step size and gentle linear braking
First, a quick recap of what Adam does.
The first moment, a moving average of gradients, stabilizes the update direction:
The second moment — classically read as an adaptive learning rate that gives each parameter its own step size:
In a 0-homogeneous network, the gradient scales as ‖g‖ ∝ η/‖w‖, while √vₜ ∝ 1/‖w‖, which cancels out the gradient's magnitude scaling: Adam is no longer adaptive in step size — it miraculously becomes constant-step (constant in magnitude).
As ‖w‖ grows steadily and the gradient g shrinks, the absolute step size stays constant:
The relative step size (effective learning rate), i.e., the angular change of w:
Compared with SGD's η_eff ∝ η/‖w‖², Adam brakes far more gently, decaying the learning rate more sensibly and reducing training stalls.
Early in training, though, when ‖w‖ is small, counterintuitively, a plain algorithm like SGD can see larger gradients, and bad initialization can blow the gradients up outright!
That's why Xavier/He initialization, which keeps ‖w‖ ∼ 1, matters even more in 0-homogeneous networks!
AdamW: weight decay isn't L2 regularization — it has to be implemented correctly
The old AdamW story first: when L2 regularization was added to Adam, the way it was implemented meant its actual effect was not the weight decay people intended.
In the SGD era, L2 regularization (adding λ/2‖w‖² to the loss) and weight decay (subtracting λw during the update) are exactly equivalent mathematically.
But in an adaptive learning rate algorithm like Adam, the two are not equivalent, and L2 regularization works poorly.
Adam's mechanism: it divides the step by the square root of the second moment vₜ. The effective decay becomes:
Consequences:
- For parameters with highly variable gradients (vₜ large), the regularization strength is artificially weakened.
- For parameters with stable gradients (vₜ small), the regularization strength is artificially amplified.
In a scale-invariant network, the extreme case pulls w toward 0 at a nearly constant step — no longer weight decay's multiplicative shrinkage.
So AdamW decouples the gradient from the decay:
You can read it as standard Adam (without L2) plus an extra decay on the weights, or as shrinking the weights multiplicatively by (1-ηλ) at every step.
In scale-invariant networks, weight decay no longer acts as a regularizer in the classical sense; it becomes a control knob for learning progress. The only effective weight updates are angular (directional), and AdamW decouples direction updates from the speed of learning:
AdamW applies a multiplicative shrink of (1-ηλ) wₜ. We saw earlier that ‖w‖ grows steadily; this change strikes a delicate physical balance, which "Rotational Equilibrium: How Weight Decay Balances Learning Across Neural Networks" calls "rotational equilibrium":
- The outward force (gradient): keeps trying to push up ‖w‖, engaging the brake.
- The inward force (decay): at a constant rate λ, shrinks ‖w‖, releasing the brake.
Because the decay is no longer distorted by √vₜ, it provides an extremely stable centripetal force. When the two forces balance, ‖w‖ locks at a fixed value, and the effective learning rate is held at "cruise control" in the optimal range.
Why does Adam need warmup?
The answer is now simple: in scale-invariant architectures, Adam uses a moving-average estimate of vₜ to avoid SGD's ‖w‖²-level braking. That estimate is key — but early in training it is statistically unreliable.
"On the Variance of the Adaptive Learning Rate and Beyond" shows why warmup is needed: at the very start of training, Adam's second-moment estimate vₜ is based on very few samples, so its variance is effectively unbounded, which makes the model take wild jumps.
So warmup's real job isn't to initialize the weights with a small learning rate; it is to let Adam build a correct optimizer state before learning begins.
Summary
LN (and RMSNorm), ubiquitous in modern deep networks, is 0-homogeneous, which creates a distinctive gradient-dynamics regime.
The conventional view needs updating:
- Scale doesn't affect the output; the norm no longer encodes feature strength but tracks learning progress
- Learning brakes itself, and weight decay is the centripetal force that counteracts the brake
That's why AdamW became the default:
- Adam fixes SGD's step size shrinking as weights grow, turning a hard brake into a gentle one
- Weight decay counters unbounded norm growth, turning brake release into cruise control
- Warmup is the standard cold-start patch for Adam's optimizer state
Further reading
Decoupled Weight Decay Regularization
Proposes AdamW after spotting an engineering bug: in Adam, adding L2 regularization (to the loss) and applying weight decay (shrinking the weights directly) are not equivalent. In standard SGD they are. But in Adam, the L2 gradient is rescaled by vₜ (the second moment), so the strength of the decay depends on the gradient's history.
L2 Regularization versus Batch and Weight Normalization
One of the first papers to state clearly that "in networks with normalization, weight decay does not regularize — it acts as learning-rate decay." It derives the effective learning rate η_eff ∝ η/‖w‖².
On the Optimization of Deep Networks: Implicit Acceleration by Overparameterization
Proves with full mathematical rigor that in scale-invariant networks, SGD + weight decay is equivalent to a complex, adaptive, state-dependent learning-rate schedule.
On Layer Normalization in the Transformer Architecture
A dedicated study of LayerNorm in Transformers. It explains why Pre-LN (today's mainstream, e.g., LLaMA) trains more easily than Post-LN (e.g., BERT). Its in-depth analysis of LayerNorm's role in backpropagation highlights the risk of gradient vanishing/exploding caused by LayerNorm, and how warmup stabilizes things during the early phase of violent gradient fluctuations.
Norm matters: efficient and accurate normalization schemes in deep neural networks
Studies weight growth under Weight Normalization and Batch Normalization in depth. It finds that, left unchecked, the weight norm grows like √t, making training efficiency degrade logarithmically. It argues that since the norm only affects the learning rate, you could even fix the norm and tune only the learning rate — indirect evidence that norm and learning rate are mathematically equivalent.
On the Variance of the Adaptive Learning Rate and Beyond
The RAdam (Rectified Adam) paper. It shows why warmup is needed: at the very start of training, Adam's second-moment estimate vₜ (the denominator) is based on very few samples, so its variance is effectively unbounded, which makes the model take wild jumps.
Root Mean Square Layer Normalization
The origin of RMSNorm. It shows that LayerNorm's core effect comes from rescaling, not re-centering. Scale is what matters; shift doesn't. This makes the 0-homogeneity assumption cleaner in RMSNorm networks (no mean subtraction; LN's bias makes it only approximately 0-homogeneous).
Robust Training of Neural Networks Using Scale Invariant Architectures
This paper answers a deeper question:"If 0-homogeneity is such a headache (it decays the effective learning rate), why use normalization layers at all? Why not just remove them?" It proves that scale-invariant architectures are extremely robustness: they make the model insensitive to the initial weight scale and more tolerant of gradient noise.
Rotational Equilibrium: How Weight Decay Balances Learning Across Neural Networks
It introduces the idea of "rotational equilibrium": during training, the gradient's "centrifugal force" and weight decay's "centripetal force" eventually reach a dynamic equilibrium. At equilibrium the weight norm stabilizes, so learning speeds across layers and neurons align automatically.
How to set AdamW’s weight decay as you scale model and dataset size
Suppose you have a base run with λ_base. Now you change the dataset size (D), the batch size (B), or the model width (W). The new weight decay λ_new should follow this unified formula: λ_new ≈ λ_base ·( B_new/B_base ) ·( D_base/D_new ) ·( W_new/W_base ) More data → smaller decay; larger batch → larger decay; wider model → larger decay.
Why Do We Need Weight Decay in Modern Deep Learning
Because modern networks (e.g., ReLU + BN/LayerNorm) are 0-homogeneous and scale-invariant in their weights, gradient descent alone lets the weight norm grow without bound, the effective learning rate keeps drifting, and training becomes unstable. Weight decay breaks this scale invariance by explicitly penalizing the weight norm, pinning down the effective step size and providing genuine regularization.