Simple Algorithm
Deep Learning · Emergence · 28 min

Why Adam Beats SGD on Transformers

Competing explanations: heavy-tailed noise, heterogeneous curvature and sign descent.

Train a ResNet with well-tuned SGD and momentum and it does about as well as Adam. Train a transformer language model the same way and it falls far behind. Nobody disputes the gap, but its cause is contested. This lesson lays out the leading explanations as competing hypotheses, each with the experiment that supports it and the one that cuts against it, and asks what evidence could settle the question.

What you’ll learn

  • Describe the empirical gap between SGD and Adam on transformers, and the controls (tuning, batch size, compute) needed to measure it fairly.
  • State the heavy-tailed-noise hypothesis, derive why clipping tames heavy tails, and explain the full-batch experiments that challenge it.
  • Derive Adam's sign-descent limit and its signal-to-noise damping, and explain how coordinate-wise updates exploit heterogeneous curvature, heavy-tailed class imbalance and ℓ∞\ell_\infty geometry.
  • Compare the hypotheses, recognize where they overlap, and design experiments that could distinguish them.

The gap and the suspects

The gap is robust. In convolutional image classification, SGD with momentum matches Adam when both are tuned. In transformer language models, SGD trains markedly slower even with momentum, warmup and a tuned learning rate. Zhao, Morwani, Brandfonbrener, Vyas & Kakade (2025) compared Adam, Adafactor, Lion, Sophia and signum on language-model pretraining over a wide range of hyperparameters: all performed comparably, both at their best and in their stability to the learning rate, except SGD.

Measuring the gap fairly takes care. A more general optimizer must get a tuning budget comparable to the simpler one (Choi et al., 2019), runs must be compared at equal compute, and, as we will see, the batch size changes the answer. Four hypotheses lead the field:

HypothesisMechanismMain supportMain challenge
Heavy-tailed noiserare, huge stochastic gradients force SGD's step to be small; clipping and adaptive scaling are robust to themZhang et al. (2020): BERT's gradient noise is heavy-tailed, ResNet-50's on ImageNet is not; clipping helpsthe gap persists, and grows, as the batch approaches the full dataset (Kunstner et al., 2023)
Sign descent and geometryAdam behaves like sign descent with momentum, which suits losses that are smooth in the ℓ∞\ell_\infty geometryfull-batch Adam tracks sign descent with momentum (Kunstner et al., 2023); rotating the parameters hurts Adam, not SGD (Xie, Mohamadi & Li, 2024)says how Adam wins, not why transformer losses have this geometry
Block heterogeneityHessian spectra differ wildly between parameter blocks, so no single learning rate suits them allZhang et al. (2024): SGD matches Adam when heterogeneity is absent, also on quadraticsa correlational measure; which blocks matter is still being mapped
Heavy-tailed class imbalancerare tokens get tiny gradients, so gradient descent learns them slowly; sign-like updates do not careKunstner et al. (2024): reproduced in CNNs with imbalanced classes and in linear modelsexplains the output side best; whether it accounts for the whole gap is open
The hypotheses are not mutually exclusive. Class imbalance creates heterogeneous curvature in the output layer, and sign-like updates are the common remedy for all four.

Hypothesis 1: heavy-tailed noise

Zhang, Karimireddy, Veit, Kim, Reddi, Kumar & Sra (2020) measured the norms of stochastic gradient noise. For ResNet-50 on ImageNet they were well concentrated; for BERT they were heavy-tailed, with an empirical variance that did not settle even over very many samples. Heavy tails came from both the attention architecture and the text data: an attention model produced them even on synthetic Gaussian inputs. They modeled this as noise whose α\alpha-th moment is bounded for some α∈(1,2]\alpha\in(1,2], so the variance may be infinite. On f(x)=12x2f(x)=\frac12x^2 with such noise, SGD with any fixed step sizes has E∥∇f(xk)∥2=∞\E\norm{\nabla f(x_k)}^2=\infty: a single huge, wrong gradient can throw it arbitrarily far.

DerivationClipping trades a small bias for a finite second moment
  1. E[clip⁡τ(x)2]≤τ2−α E∣x∣α<∞\E\big[\operatorname{clip}_\tau(x)^2\big]\le\tau^{2-\alpha}\,\E\abs x^\alpha<\infty

    Clip a scalar noisy gradient xx at level τ\tau: clip⁡τ(x)=x\operatorname{clip}_\tau(x)=x if ∣x∣≤τ\abs x\le\tau, else τ sign⁡(x)\tau\,\sign(x). If ∣x∣≤τ\abs x\le\tau then x2=∣x∣α∣x∣2−α≤τ2−α∣x∣αx^2=\abs x^\alpha\abs x^{2-\alpha}\le\tau^{2-\alpha}\abs x^\alpha; if ∣x∣>τ\abs x>\tau the clipped square is τ2≤τ2−α∣x∣α\tau^2\le\tau^{2-\alpha}\abs x^\alpha. Either way:

  2. ∣E[x]−E[clip⁡τ(x)]∣≤E[∣x∣ 1{∣x∣>τ}]≤τ1−α E∣x∣α\big|\E[x]-\E[\operatorname{clip}_\tau(x)]\big|\le\E\big[\abs x\,\mathbb 1\{\abs x>\tau\}\big]\le\tau^{1-\alpha}\,\E\abs x^\alpha

    The price is a bias, paid only on the rare large values. For ∣x∣>τ\abs x>\tau, ∣x∣=∣x∣α∣x∣1−α≤τ1−α∣x∣α\abs x=\abs x^\alpha\abs x^{1-\alpha}\le\tau^{1-\alpha}\abs x^\alpha:

  3. E∥∇f∥≤O(K−α−13α−2)⟺K=O(ε−3α−2α−1)  steps to reach ε\E\norm{\nabla f}\le\order{K^{-\frac{\alpha-1}{3\alpha-2}}}\quad\Longleftrightarrow\quad K=\order{\varepsilon^{-\frac{3\alpha-2}{\alpha-1}}}\ \text{ steps to reach }\varepsilon

    Balancing the two as training proceeds gives Zhang et al.'s rate for clipped SGD on smooth nonconvex losses, with a matching lower bound. At α=2\alpha=2 it is the familiar ε−4\varepsilon^{-4} of SGD with finite variance; heavier tails make it slower.

Adam's normalization acts like a soft, per-coordinate clip: one outlier inflates v^\hat{\mathbf v} along with m^\hat{\mathbf m}, so the step stays near η\eta. Zhang et al. proposed adaptive coordinate-wise clipping (ACClip), which did well on BERT. A related argument does not need noise at all. Along real training trajectories, curvature grows with the gradient norm, roughly ∥∇2f∥≤L0+L1∥∇f∥\norm{\nabla^2f}\le L_0+L_1\norm{\nabla f}, and under this relaxed smoothness clipped or normalized gradient descent converges arbitrarily faster than gradient descent with a fixed step (Zhang, He, Sra & Jadbabaie, 2020).

The challenge. If noise were the cause, removing it should close the gap. Kunstner, Chen, Lavington & Schmidt (2023) increased the batch size all the way to the full dataset on transformer tasks. The noise vanished, but the gap did not: Adam improved with larger batches much more than SGD did, so its advantage grew, and in the full-batch regime Adam behaved much like sign descent with momentum. Noise may still matter at small batch sizes, but it cannot be the main reason.

Check your understanding

Which experiment most directly tests whether gradient noise is the main reason Adam beats SGD on a transformer?

  1. Measure the tail index of the gradient noise at a small batch size
  2. Compare tuned SGD and Adam as the batch size grows to the full dataset
  3. Show that gradient clipping speeds up SGD
  4. Train a ResNet with both optimizers
Show the answer

B. Compare tuned SGD and Adam as the batch size grows to the full dataset

Growing the batch removes the noise while keeping everything else fixed. If the gap survives at full batch, as Kunstner et al. (2023) found, the cause must lie in the deterministic geometry of the problem. The other experiments are consistent with the noise hypothesis but cannot rule out the alternatives.

Hypothesis 2: Adam is mostly sign descent

DerivationAdam as a damped sign method
  1. β1=β2=ϵ=0:Δθ=−η gg2=−η sign⁡(g)\beta_1=\beta_2=\epsilon=0:\qquad\Delta\boldsymbol\theta=-\eta\,\frac{\mathbf g}{\sqrt{\mathbf g^2}}=-\eta\,\sign(\mathbf g)

    Switch off both averages and ϵ\epsilon: with β1=β2=0\beta_1=\beta_2=0, m^=g\hat{\mathbf m}=\mathbf g and v^=g2\hat{\mathbf v}=\mathbf g^2, and Adam becomes sign descent. Keeping the momentum but taking the sign gives signum, the momentum version of signSGD (Bernstein, Wang, Azizzadenesheli & Anandkumar, 2018).

  2. m^v^≈μμ2+σ2=sign⁡(μ)1+σ2/μ2\frac{\hat m}{\sqrt{\hat v}}\approx\frac{\mu}{\sqrt{\mu^2+\sigma^2}}=\frac{\sign(\mu)}{\sqrt{1+\sigma^2/\mu^2}}

    With averaging, suppose a coordinate's gradient has mean μ\mu and standard deviation σ\sigma, so m^≈μ\hat m\approx\mu and v^≈μ2+σ2\hat v\approx\mu^2+\sigma^2. Adam's step is the sign of the mean, damped by the relative variance (Balles & Hennig, 2018):

  3. arg min⁡∥Δ∥∞≤η⟨g,Δ⟩=−η sign⁡(g),min⁡∥Δ∥∞≤η⟨g,Δ⟩=−η∥g∥1\argmin_{\norm{\Delta}_\infty\le\eta}\langle\mathbf g,\Delta\rangle=-\eta\,\sign(\mathbf g),\qquad\min_{\norm{\Delta}_\infty\le\eta}\langle\mathbf g,\Delta\rangle=-\eta\norm{\mathbf g}_1

    Sign descent is steepest descent for the ℓ∞\ell_\infty norm: among steps with ∥Δ∥∞≤η\norm{\Delta}_\infty\le\eta, the one that lowers a linear model of the loss the most is −η sign⁡(g)-\eta\,\sign(\mathbf g), lowering it by η∥g∥1\eta\norm{\mathbf g}_1. Gradient descent is steepest descent for ℓ2\ell_2. Beyond Adam: Lion, Muon & Steepest Descent develops this view.

Predict before you look

For one coordinate, the gradient's mean equals its standard deviation (σ=μ\sigma=\mu). In steady state, about what fraction of the full step η\eta does Adam take along that coordinate?

Show the answer

0.71

1/1+σ2/μ2=1/2≈0.711/\sqrt{1+\sigma^2/\mu^2}=1/\sqrt2\approx0.71. At a signal-to-noise ratio of 0.10.1 the factor is 1/101≈0.11/\sqrt{101}\approx0.1, and as the signal vanishes Adam's step shrinks toward zero while the sign alone would keep stepping by η\eta: this damping is how Adam anneals itself near a minimum.

Why would sign-like steps suit transformers? Suppose the loss is smooth with respect to the ℓ∞\ell_\infty norm, L(θ+Δ)≤L(θ)+⟨g,Δ⟩+L∞2∥Δ∥∞2\loss(\boldsymbol\theta+\Delta)\le\loss(\boldsymbol\theta)+\langle\mathbf g,\Delta\rangle+\frac{L_\infty}{2}\norm{\Delta}_\infty^2. A sign step then guarantees a decrease of η∥g∥1−L∞2η2\eta\norm{\mathbf g}_1-\frac{L_\infty}2\eta^2, and ∥g∥1\norm{\mathbf g}_1 can be up to d\sqrt d times ∥g∥2\norm{\mathbf g}_2 when the gradient is spread over many coordinates. Xie, Mohamadi & Li (2024) found that the ℓ∞\ell_\infty smoothness of GPT-2 and ResNet losses is much more favorable than the usual ℓ2\ell_2 analysis suggests, and that changing this geometry makes Adam much worse while SGD is provably unaffected.

DerivationThe rotation test
  1. ∇L′(θ′)=R ∇L(R⊤θ′)\nabla\loss'(\boldsymbol\theta')=R\,\nabla\loss(R^\top\boldsymbol\theta')

    Rotate the parameters by a fixed orthogonal matrix RR: θ′=Rθ\boldsymbol\theta'=R\boldsymbol\theta and L′(θ′)=L(R⊤θ′)\loss'(\boldsymbol\theta')=\loss(R^\top\boldsymbol\theta'). The chain rule rotates the gradient the same way:

  2. sign⁡(Rg)≠R sign⁡(g)in general\sign(R\mathbf g)\ne R\,\sign(\mathbf g)\quad\text{in general}

    So gradient descent in the new coordinates traces exactly the rotated path, θt′=Rθt\boldsymbol\theta'_t=R\boldsymbol\theta_t, with an identical loss curve. Coordinate-wise methods do not commute with rotations, because the sign (or the division by v^\sqrt{\hat{\mathbf v}}) acts on each axis separately:

  3. If rotating a transformer's parameterization erases Adam's advantage while leaving SGD unchanged, the advantage comes from structure aligned with the coordinates, which is what the remaining two hypotheses propose.

Hypotheses 3 and 4: heterogeneity and imbalance

Block heterogeneity. Zhang, Chen, Ding, Li, Sun & Luo (2024) computed Hessian spectra block by block. In transformers the spectra of different parameter blocks (attention projections, MLP weights, embeddings, normalization gains) differ dramatically; in CNNs the blocks look alike. Across transformers, CNNs, MLPs and quadratic problems, SGD lagged Adam when heterogeneity was present and matched it when it was absent. The mechanism is ill-conditioning that is aligned with the blocks:

L=12(h1∥θ1∥2+h2∥θ2∥2), h1≫h2:η<2h1 ⟹ block 2 needs about h12h2 steps per factor e\loss=\tfrac12\big(h_1\norm{\boldsymbol\theta_1}^2+h_2\norm{\boldsymbol\theta_2}^2\big),\ h_1\gg h_2:\qquad\eta<\frac2{h_1}\ \Longrightarrow\ \text{block 2 needs about }\frac{h_1}{2h_2}\text{ steps per factor }e
Separate step sizes ηb=1/hb\eta_b=1/h_b would solve each block in one step. A diagonal preconditioner such as Adam's, whose v^\sqrt{\hat{\mathbf v}} tracks each block's gradient scale, recovers much of that. Zhao et al. (2025) found that a single adaptive scale per layer ("Adalayer") retains most of Adam's performance and stability, provided the last layer and the LayerNorm parameters keep their adaptivity.
DerivationHeavy-tailed class imbalance (a toy calculation)
  1. ∇wcL=E[(pc(x)−1{y=c}) h(x)]\nabla_{\mathbf w_c}\loss=\E\big[(p_c(\mathbf x)-\mathbb 1\{y=c\})\,\mathbf h(\mathbf x)\big]

    Take the output layer, with logits zc=⟨wc,h⟩z_c=\langle\mathbf w_c,\mathbf h\rangle for each class cc (each token of the vocabulary V\mathcal V) and the cross-entropy loss. The gradient for class cc's weights is

  2. −E[1{y=c} h]=−πc E[h∣y=c]-\E\big[\mathbb 1\{y=c\}\,\mathbf h\big]=-\pi_c\,\E[\mathbf h\mid y=c]

    Early in training predictions are nearly uniform, pc≈1/∣V∣p_c\approx1/\abs{\mathcal V}. The term that pulls class cc toward its own examples is then proportional to the class frequency πc\pi_c:

  3. GD: time∝1πc∝c,sign descent: roughly independent of πc\text{GD: time}\propto\frac1{\pi_c}\propto c,\qquad\text{sign descent: roughly independent of }\pi_c

    Gradient descent therefore moves wc\mathbf w_c at a rate proportional to πc\pi_c, and class cc needs time proportional to 1/πc1/\pi_c. Token frequencies are heavy-tailed, roughly πc∝1/c\pi_c\propto1/c when tokens are ranked by frequency, so the rare tail of the vocabulary is learned orders of magnitude more slowly. A sign or Adam step normalizes each coordinate, making progress nearly independent of πc\pi_c.

Kunstner, Yadav, Milligan, Schmidt & Bietti (2024) showed that this effect is a key factor in the gap: with gradient descent, the loss on infrequent words falls more slowly than on frequent ones, while Adam and sign-based methods are much less sensitive. The effect reproduces across architectures and data types, in language transformers, in vision CNNs trained on heavy-tailed imbalanced classes, and in linear models, where in continuous time gradient descent provably converges slowly on low-frequency classes and sign descent does not.

Key takeaways

  • SGD trails Adam on transformers but not on CNNs; Adam, Adafactor, Lion, Sophia and signum perform comparably on language models, SGD does not. Fair comparisons need equal tuning, equal compute and attention to the batch size.
  • Transformer gradient noise is heavy-tailed, and clipping (bias ≤τ1−αE∣x∣α\le\tau^{1-\alpha}\E\abs x^\alpha, second moment ≤τ2−αE∣x∣α\le\tau^{2-\alpha}\E\abs x^\alpha) restores convergence at rate K−(α−1)/(3α−2)K^{-(\alpha-1)/(3\alpha-2)}. But the gap persists and grows at full batch, so noise is not the main cause.
  • Adam with its averages switched off is sign descent, steepest descent for ℓ∞\ell_\infty; with averages it is a sign step damped by 1/1+σ2/μ21/\sqrt{1+\sigma^2/\mu^2}. Coordinate-wise methods exploit ℓ∞\ell_\infty-favorable, axis-aligned structure and, unlike gradient descent, are not invariant to rotations of parameter space.
  • Hessian spectra differ wildly between transformer blocks, and heavy-tailed token frequencies make gradient descent learn rare tokens in time ∝1/πc\propto1/\pi_c; per-block or per-coordinate scaling removes both. The explanations overlap, and none is settled as of the mid-2020s.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Kunstner et al. (2023) trained transformers with batch sizes growing up to the full dataset. What did they find?

  1. The gap between Adam and SGD closed at full batch, confirming that noise causes it
  2. SGD overtook Adam at large batch sizes
  3. Adam's advantage persisted and grew, and full-batch Adam behaved much like sign descent with momentum
  4. Both optimizers failed to train at full batch
Show the answer

C. Adam's advantage persisted and grew, and full-batch Adam behaved much like sign descent with momentum

Adam benefited from larger batches far more than SGD did, so noise cannot be the main factor. The sign-descent behavior points instead to the deterministic geometry of the loss.

Question 2

You re-express a network's loss in coordinates rotated by a fixed orthogonal matrix RR, and train in the new coordinates from the correspondingly rotated initialization. Whose loss curve is guaranteed to be unchanged?

  1. Gradient descent's, because its update rotates along with the coordinates
  2. Adam's, because its normalization makes it invariant to how parameters are expressed
  3. Sign descent's, because the sign of a vector does not depend on its coordinates
  4. None of them: rotations change the loss landscape
Show the answer

A. Gradient descent's, because its update rotates along with the coordinates

∇L′(θ′)=R∇L(R⊤θ′)\nabla\loss'(\boldsymbol\theta')=R\nabla\loss(R^\top\boldsymbol\theta'), so gradient descent's iterates are exactly RθtR\boldsymbol\theta_t. Adam and sign descent act coordinate by coordinate, and sign⁡(Rg)≠R sign⁡(g)\sign(R\mathbf g)\ne R\,\sign(\mathbf g), so their trajectories, and their performance, can change. That asymmetry is what makes the rotation test informative.

Question 3

Why does gradient descent learn rare tokens slowly under heavy-tailed class imbalance?

  1. Rare tokens have larger gradients, which force a smaller learning rate
  2. The rare tokens' loss is not differentiable
  3. The gradient pulling a class's output weights toward its examples is proportional to its frequency πc\pi_c, so rare classes move slowly; sign-like updates are insensitive to that scale
  4. Rare tokens are always mislabeled
Show the answer

C. The gradient pulling a class's output weights toward its examples is proportional to its frequency πc\pi_c, so rare classes move slowly; sign-like updates are insensitive to that scale

Early in training ∇wcL≈E[h]/∣V∣−πcE[h∣y=c]\nabla_{\mathbf w_c}\loss\approx\E[\mathbf h]/\abs{\mathcal V}-\pi_c\E[\mathbf h\mid y=c], so the useful pull scales with πc\pi_c and the time to learn class cc with 1/πc1/\pi_c. Normalizing per coordinate, as Adam and sign descent do, removes the dependence.

Further reading

  • J. Zhang, S. P. Karimireddy, A. Veit, S. Kim, S. J. Reddi, S. Kumar & S. Sra, "Why are adaptive methods good for attention models?," NeurIPS (2020).
  • F. Kunstner, J. Chen, J. W. Lavington & M. Schmidt, "Noise is not the main factor behind the gap between SGD and Adam on transformers, but sign descent might be," ICLR (2023).
  • Y. Zhang, C. Chen, T. Ding, Z. Li, R. Sun & Z.-Q. Luo, "Why transformers need Adam: A Hessian perspective," NeurIPS (2024).
  • F. Kunstner, R. Yadav, A. Milligan, M. Schmidt & A. Bietti, "Heavy-tailed class imbalance and why Adam outperforms gradient descent on language models," NeurIPS (2024).
  • R. Zhao, D. Morwani, D. Brandfonbrener, N. Vyas & S. Kakade, "Deconstructing what makes a good optimizer for autoregressive language models," ICLR (2025).