Adaptive Methods in Depth
AdaGrad’s regret bound, Adam’s failure cases and AdamW.
Adam is the default optimizer of deep learning, yet on a one-dimensional convex problem it can converge to the worst possible point. This lesson proves the regret bound that made AdaGrad famous, builds the counterexample that broke Adam's original analysis, reads Adam's step as a sign step scaled by a signal-to-noise ratio, and sorts out what is known, and what is still argued, about warmup, decoupled weight decay and generalization.
What you’ll learn
- Define regret in online convex optimization and prove AdaGrad's data-dependent bound .
- Analyze Reddi, Kale & Kumar's counterexample, explain why a short-memory second moment breaks convergence, and how AMSGrad or a large repairs it.
- Interpret Adam's step as a sign step scaled by the gradient's signal-to-noise ratio, and explain warmup and RAdam's variance rectification.
- Show why an L2 penalty and decoupled weight decay differ under adaptive preconditioning, and weigh the evidence on how adaptive methods generalize.
Online convex optimization and AdaGrad
The cleanest theory of adaptive methods lives in online convex optimization, the convex corner of online learning. At each round a learner picks in a convex set ; then a convex loss is revealed and the learner pays . Performance is measured by regret against the best fixed point in hindsight,
with no assumption on how the losses are generated (Online Learning & Regret). Projected online gradient descent, with and , achieves , where is the diameter of and bounds (Zinkevich, 2003). Regret bounds are optimization bounds too: if the are i.i.d. draws of a random convex loss with mean , the averaged iterate satisfies (online-to-batch conversion).
Proof of the bound, and what it buys
One step. Projection onto a convex set in the -norm does not increase -distances to points of the set, so for the comparator :
Rearrange, and use convexity, :
Distance terms. Summed over , these do not telescope exactly because the norm changes each round. What is left is controlled by the growth of , which is diagonal and nondecreasing (set ):
Gradient terms. Coordinate by coordinate these are . For nonnegative with partial sums , , so the sum telescopes:
Combine the two sums and choose , which balances them:
What the bound buys. Online gradient descent with the best fixed step chosen in hindsight guarantees , with the Euclidean diameter. On the box , while , and by Cauchy–Schwarz . So AdaGrad's bound is never more than times that tuned bound, needs no knowledge of the gradient sequence, and is far smaller when a few coordinates carry most of the gradient mass while many others are rarely active: sparse, heavy-tailed features, as in text and click data.
Think first On the box with , coordinate of the gradient is in a fraction of the rounds and otherwise. Compare the two bounds.
Now . AdaGrad: . Tuned online gradient descent: . AdaGrad's guarantee is about times smaller, and the ratio grows like . If instead every coordinate were active in every round, AdaGrad's bound would be times larger: adaptivity pays off for uneven gradients.
When Adam fails: the counterexample
Adam replaces AdaGrad's sum by an exponential average, . In AdaGrad the effective learning rate can only shrink; with a short memory it can grow again whenever recent gradients are small. Kingma & Ba's (2015) original convergence analysis implicitly relied on it shrinking, and Reddi, Kale & Kumar (2018) showed that the gap is real, with a problem small enough to work out by hand.
Let , fix and present the losses cyclically. Each cycle of three rounds sums to , so the best fixed point is :
Run Adam with , and steps (bias correction is negligible after a few rounds). The second moment forgets quickly and settles into a three-round cycle; with , so , it reads after the large gradient and , then , after the two small ones:
The informative large gradient is normalized away. In units of , the round with gradient moves by about toward the optimum, and the two rounds with gradient move it by about away from it: a net drift of about per cycle toward .
Since diverges, the drift pushes the iterates to , the worst point of , where each cycle costs more than ; hence . AMSGrad keeps a running maximum of the second moment, so the effective step can only shrink, and on this problem it converges to .
In the counterexample with , once Adam sits at , what is its average regret per round against ?
Show the answer
0.67
Per cycle the losses sum to , so Adam pays while pays : a difference of every three rounds, about per round, forever. A no-regret method drives this average to .
How much does this matter in practice? The construction ties to the problem: it needs a short memory, . With the usual or , Adam reaches on this very example. Zhang, Chen, Shi, Sun & Luo (2022) proved that, without changing the update rule, Adam converges to a neighborhood of critical points when is large enough and , and that a small can indeed make it diverge. Défossez, Bottou, Bach & Usunier (2022) proved that, with suitably chosen parameters, Adam drives the average squared gradient norm of a smooth nonconvex objective with bounded gradients down at the rate after steps, the same rate they prove for AdaGrad. The counterexample exposes a real mechanism, the forgetting of rare large gradients, rather than a typical failure.
What Adam's step does: sign, noise and warmup
Per coordinate, Adam steps by , with and . Writing and for the mean and standard deviation of a coordinate's gradient, the average step is
When the signal dominates () the step is about ; when noise dominates it shrinks to about . Balles & Hennig (2018) made this decomposition precise: Adam is a sign method whose step length adapts to the gradient's signal-to-noise ratio. With and it is exactly sign descent, , the steepest-descent direction for the norm, since . Mirror Descent & Natural Gradient develops this geometric view.
Warmup and RAdam. In the first steps averages very few squared gradients, so the adaptive learning rate is itself highly variable, and the early updates are erratic. Liu et al. (2020) quantified this variance and proposed RAdam, which switches the adaptive scaling on gradually through a rectification factor derived from it; a linear warmup of over the first steps (a learning-rate schedule) has a similar effect and is standard practice for transformers. Large early gradients and sharp regions of the loss early in training are other proposed reasons why warmup helps, and their relative importance is still debated.
Weight decay and generalization
For SGD, the gradient of produces a multiplicative shrink followed by a gradient step, so the penalty and weight decay coincide:
With a diagonal preconditioner (momentum set aside for simplicity), the penalty's gradient is preconditioned as well, and coordinate shrinks by : least where gradients have been largest.
AdamW applies the decay outside the preconditioner, so every coordinate shrinks by the same factor. Heuristically, at a fixed point and , a stationary point of with frozen: a weighted L2 penalty that is strongest where gradients are largest. The L2-in-the-loss version keeps the fixed points of the plain penalty, ; what differs across its coordinates is how fast each weight decays on the way there.
Do adaptive methods generalize worse? Wilson, Roelofs, Stern, Srebro & Recht (2017) designed a separable classification problem with more features than examples on which the outcome depends on the optimizer: gradient descent started at zero finds a solution that predicts new points correctly, while AdaGrad, RMSProp and Adam settle on a different solution that generalizes poorly. They also reported adaptive methods generalizing worse than tuned SGD on several image and language benchmarks. The mechanism is implicit bias: among the many solutions that fit the data, each optimizer's geometry selects a different one (The Implicit Bias of Gradient Descent).
Later work complicated the picture. Choi et al. (2019) argued that a more general optimizer should never lose to the special cases it contains once every hyperparameter, Adam's included, is tuned, and found exactly that, so many reported gaps reflected tuning protocols. On transformers the gap runs the other way: Adam trains them markedly better than SGD. Heavy-tailed gradient noise was proposed as the reason (Zhang et al., 2020); Kunstner et al. (2023) found that noise is not the main factor, since the gap persists as the batch grows, and that at large batch sizes Adam behaves like sign descent with momentum. As of the mid-2020s the question is open.
Which statement about weight decay is correct?
- With plain SGD, an L2 penalty and decoupled weight decay coincide once is matched to the learning rate; with Adam they do not
- Adam with an L2 penalty in the loss decays every weight at the same relative rate
- AdamW's decay acts most strongly on weights with small gradients
- Decoupled weight decay changes the gradients that Adam's moment estimates see
Show the answer
A. With plain SGD, an L2 penalty and decoupled weight decay coincide once is matched to the learning rate; with Adam they do not
Plain SGD folds the penalty's gradient into the shrink factor , so the two are the same update. Adam divides the penalty's gradient by together with the loss's, which is why Loshchilov & Hutter (2019) moved the decay outside the adaptive scaling.
Key takeaways
- Online convex optimization measures regret against the best fixed point; online gradient descent has regret, and online-to-batch conversion turns regret bounds into optimization bounds.
- AdaGrad's regret is at most without any tuning to the data: never much worse than tuned online gradient descent, and far better with sparse, unevenly active features.
- A short-memory second moment can normalize away rare informative gradients, and Adam then converges to the worst point of a convex problem. AMSGrad's running maximum, or close to , restores convergence.
- Adam is a sign method whose step shrinks with the gradient's signal-to-noise ratio; warmup or RAdam tames the noisy early second moments, and AdamW's decoupled decay shrinks every weight at the same rate.
- Adaptive methods can select worse-generalizing solutions on constructed problems, but tuning explains many reported gaps, and on transformers Adam clearly beats SGD, for reasons still debated.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
AdaGrad's bound is most favorable, compared with online gradient descent, when…
- every coordinate's gradient is large in every round
- the domain is a Euclidean ball
- a few coordinates are active often and most are active rarely, on a domain such as a box where
- the losses are strongly convex
Show the answer
C. a few coordinates are active often and most are active rarely, on a domain such as a box where
Sparse, unevenly active coordinates make far smaller than its worst case , and a box has against . Both effects favor the per-coordinate bound.
In Reddi, Kale & Kumar's counterexample, what goes wrong?
- The losses are nonconvex, so Adam finds a poor local minimum
- The momentum term overshoots the optimum
- The bias correction is missing
- A short-memory second moment normalizes away the rare large gradient, so the frequent small gradients win and push the iterate to the worst point
Show the answer
D. A short-memory second moment normalizes away the rare large gradient, so the frequent small gradients win and push the iterate to the worst point
With , is large only right after the gradient , so that step is normalized to about , while each of the two gradients also earns a step of about , in the opposite direction. A running maximum (AMSGrad) or a long memory ( near ) keeps the effective step from growing back, and the method converges.
On one coordinate, mini-batch gradients have mean and standard deviation . Roughly how far does Adam move that coordinate per step on average, in units of ?
- About
- About
- About
- Exactly , because the mean is so small
Show the answer
B. About
: a noise-dominated coordinate drifts at a rate shrunk by its signal-to-noise ratio. Individual steps fluctuate more, since averages noise over only about recent steps, but the fluctuations largely cancel.
According to Liu et al. (2020), why can Adam's first steps be erratic without warmup?
- averages only a few squared gradients, so the adaptive learning rate has very high variance early on
- Bias correction overshoots in the first steps
- Momentum has not yet built up
- The weights are initialized too large
Show the answer
A. averages only a few squared gradients, so the adaptive learning rate has very high variance early on
With one or two samples, can be far from its typical value, so the per-coordinate learning rate is very noisy and the early updates are erratic. RAdam rectifies the variance of the adaptive rate; a linear warmup of has a similar effect.
Further reading
- J. Duchi, E. Hazan & Y. Singer, "Adaptive subgradient methods for online learning and stochastic optimization," Journal of Machine Learning Research 12, 2121–2159 (2011).
- D. P. Kingma & J. Ba, "Adam: a method for stochastic optimization," ICLR (2015).
- S. J. Reddi, S. Kale & S. Kumar, "On the convergence of Adam and beyond," ICLR (2018).
- I. Loshchilov & F. Hutter, "Decoupled weight decay regularization," ICLR (2019).
- A. C. Wilson, R. Roelofs, M. Stern, N. Srebro & B. Recht, "The marginal value of adaptive gradient methods in machine learning," Advances in Neural Information Processing Systems 30 (2017).