AMSGrad is Adam with one change: it divides by the running maximum of the second-moment estimate rather than the estimate itself, so each parameter's effective learning rate can never increase. Reddi, Kale and Kumar introduced it after proving that Adam (and RMSProp) can converge to the worst point on a simple online convex problem, because a short memory lets rare large gradients be forgotten. This page covers the failure mechanism, the fix, its convergence guarantee and its practical cost. In the exercises you show that AMSGrad's effective rate never increases and that one gradient spike keeps it small long afterwards, then reproduce the counterexample: with the paper's short memory Adam converged to the worst point, AMSGrad to the optimum, and with the usual β₂ = 0.999 Adam was fine.
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.
Never forget a big gradient
Adam divides each step by a moving average of recent squared gradients. Suppose a parameter usually gets small gradients but occasionally a large, important one. A short memory forgets the large one quickly, the denominator shrinks, and the steps from the frequent small gradients become relatively large. They can then outweigh the rare large ones and push the parameter the wrong way. AMSGrad keeps the largest denominator seen so far, so rare large gradients are never discounted.
Optimizer lab: AMSGrad versus plain gradient descent
AMSGrad: final loss 0.012 (target reached at step 75) · gradient descent: final loss 2.2e-9 (step 22)
Orange: the chosen optimizer; grey dashed: plain gradient descent with the same learning rate. Darker shading means higher loss. On the ill-conditioned bowl, raise κ and watch gradient descent zig-zag across the narrow direction; on the saddle it stalls near the flat start; on the plateau its gradients are tiny. Adaptive methods rescale each direction; momentum methods build speed along consistent directions. The target is 1% of the starting loss (for the saddle, a loss below −0.2; its minima are at −0.25).
Why engineers care
Rare but large gradients are typical of rare events: faults, unusual manoeuvres, edge-case inputs. An optimiser that systematically underweights them can learn a model that is wrong exactly where it matters. AMSGrad shows the mechanism and one fix. It also shows why β₂ close to 1, a long memory, is the practical default.
📝 Quick check (Level 0)
0/3 answered
1. AMSGrad divides by…
2. AMSGrad's effective learning rate can…
3. AMSGrad was motivated by…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.
By hand
Update: m and v as in Adam, then v_max ← max(v_max, v), and w ← w − η·m/(√v_max + ε). The original paper uses no bias correction for v_max.
Example with β₁ = β₂ = 0.5, v_max = 1, g = 1: m = 0.5, v = 0.5, v_max stays 1, step = η × 0.5.
The failure (Reddi et al.): on [−1, 1], the loss is Cx on every third step and −x otherwise. The average gradient (C − 2)/3 is positive for C > 2, so the best point is x = −1.
What goes wrong: with a short memory, the C-gradient is divided by a large √v, but by the next steps v has decayed, so the two −1 gradients get larger steps. Their combined push toward +1 beats the single push toward −1, and Adam drifts to the worst point.
Running maximum: for 1, 3, 2, 5, 4 it is 1, 3, 3, 5, 5.
📝 Quick check (Level 1)
0/3 answered
1. Running maximum of (2, 1, 4, 3)?
2. In the counterexample with C = 3 the optimum is…
3. Adam fails there because the rare large gradient is…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.
AMSGrad in code
Exercise 1.
Along a gradient sequence of ones with a single spike of 50, AMSGrad’s effective learning rate never increased: 1.26 before the spike, 0.198 a thousand steps after.
Adam’s recovered to 0.999.
The protection has a cost: one outlier gradient can permanently slow AMSGrad’s learning for that parameter.
Practice.
PyTorch implements AMSGrad as amsgrad=True on Adam or AdamW, with bias correction on the maximum.
In most deep-learning benchmarks AMSGrad performs about the same as Adam, sometimes slightly worse. Its value is mainly theoretical, plus cases with rare large gradients and short memories.
Gradient clipping limits the permanent slow-down caused by outlier spikes.
torch.optim.Adam(params, lr=1e-3, amsgrad=True)
🐍 Exercise 1: the running maximum
Implement AMSGrad and compare its effective learning rate with Adam's along a gradient sequence containing one spike.
📝 Quick check (Level 2)
0/3 answered
1. After a single large gradient spike, AMSGrad's steps…
2. In PyTorch AMSGrad is enabled with…
3. On typical deep-learning benchmarks AMSGrad versus Adam is…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.
Theory
The convergence gap. Adam’s original proof relied on the quantity Γₜ = √vₜ/ηₜ − √vₜ₋₁/ηₜ₋₁ being positive, so that the effective learning rate is non-increasing. With exponential moving averages, vₜ can drop sharply after a large gradient leaves the window, making Γₜ negative. Reddi, Kale and Kumar (2018) built online convex problems where this leads to non-vanishing average regret: Adam converges to a suboptimal point. They also showed a stochastic version and gave conditions involving β₁ and β₂ for the failure.
The fix. Using v̂ₜ = max(v̂ₜ₋₁, vₜ) guarantees Γₜ ≥ 0 with ηₜ = η/√t. AMSGrad then has O(√T) regret (average regret → 0) for online convex problems, like AdaGrad.
What the theory needs. The counterexample requires a second-moment memory short enough to forget the rare gradient between its occurrences (β₂ small compared with the gap). With β₂ = 0.999 the memory spans about 1000 steps, much longer than the period-3 pattern, and Adam converges correctly on that problem, as exercise 2 shows. Failures with practical β₂ need rarer large gradients. Later work (e.g. Zhang et al., 2022) showed that Adam with β₂ chosen as a function of the problem does converge.
📝 Quick check (Level 3)
0/3 answered
1. AMSGrad's regret for online convex problems is…
2. The counterexample requires a second-moment memory that is…
3. Reddi et al.'s paper won…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.
Reproducing the counterexample
History.
D. Kingma and J. Ba (2015) published Adam with a convergence proof that turned out to have a gap.
S. Reddi, S. Kale and S. Kumar (2018) exposed it, introduced AMSGrad and won a best-paper award at ICLR.
Y. Zhang et al. (2022) showed Adam can converge without modification when β₂ is large enough relative to the problem.
Exercise 2. The online problem on [−1, 1]: loss Cx on steps where t mod 3 = 1, and −x otherwise, for 30 000 steps with ηₜ = 0.1/√t, β₁ = 0 and projection back onto [−1, 1]. Following the paper’s construction, β₂ = 1/(1 + C²), a very short memory; Adam with the usual β₂ = 0.999 is also run. The table gives the final x (the optimum is −1) and the average regret against x = −1.
method
C
final x
average regret
Adam, β₂ = 1/(1 + C²)
2.5
+0.9997
0.331
AMSGrad, β₂ = 1/(1 + C²)
2.5
−0.9998
0.007
Adam, β₂ = 0.999
2.5
−0.9997
−0.001
Adam, β₂ = 1/(1 + C²)
3
+0.9997
0.663
AMSGrad, β₂ = 1/(1 + C²)
3
−0.9998
0.006
Adam, β₂ = 1/(1 + C²)
5
+0.9997
1.991
AMSGrad, β₂ = 1/(1 + C²)
5
−0.9999
0.006
Adam, β₂ = 0.999
5
−0.9998
−0.001
The failure is real. With the short memory, Adam converged to x = +1, the worst point, and its average regret grew with C (0.33, 0.66, 1.99) instead of vanishing.
AMSGrad converged to the optimum in every case, with regret near zero.
With the usual β₂ = 0.999, Adam also converged to −1. The failure depends on a memory short enough to forget the large gradient between occurrences. (A negative average regret is possible early on, while x is still moving toward −1.)
Lesson: keep β₂ close to 1 unless there is a reason not to. When lowering β₂ (as some transformer recipes do), be aware of this failure mode for rare, large gradients.
🐍 Exercise 2 (research): reproducing the counterexample
Run Adam and AMSGrad on Reddi et al.'s online convex problem with C = 2.5, 3 and 5 and β₂ = 1/(1 + C²), plus Adam with β₂ = 0.999; compare final points and average regret.
AMSGrad in AI, robotics and aerospace
Rare-event learning: models trained on data where informative examples are rare (faults, near-misses) can use AMSGrad or a long β₂ to avoid discounting them.
Online learning on deployed systems: convergence guarantees in the online convex setting matter when models adapt continuously.
Robust training recipes: a long second-moment memory plus gradient clipping is a pragmatic alternative.
References
S. J. Reddi, S. Kale, S. Kumar (2018). “On the convergence of Adam and beyond.” Proc. ICLR.
D. P. Kingma, J. Ba (2015). “Adam: a method for stochastic optimization.” Proc. ICLR.
Y. Zhang, C. Chen, N. Shi, R. Sun, Z.-Q. Luo (2022). “Adam can converge without any modification on update rules.” Advances in NeurIPS 35.
Adam’s failure needs a second-moment memory shorter than the gap between rare large gradients; β₂ = 0.999 avoided it here.
Practice
Show:
Level 0
Problem 1Level 0
Last value of the running maximum of 1, 3, 2, 5, 4?
5.
Problem 2Level 0
Average gradient (C − 2)/3 for C = 3?
0.333.
Problem 3Level 0
Optimum of the counterexample for C = 3?
−1.
Level 1
Problem 4Level 1
AMSGrad step (no bias correction) with β₁ = β₂ = 0.5, v_max = 1, m = v = 0, g = 1, η = 0.1?
m = 0.5, v = 0.5, v_max = 1: −0.1 × 0.5 = −0.05.
Problem 5Level 1
β₂ = 1/(1 + C²) for C = 3?
0.1.
Problem 6Level 1
Sum of the gradients over one period for C = 3?
3 − 1 − 1 = 1.
Problem 7Level 1
Memory length of β₂ = 0.999?
1000 steps.
Level 2
Problem 8Level 2
AMSGrad’s effective rate 1000 steps after the spike in exercise 1?
0.198.
Problem 9Level 2
Adam’s effective rate 1000 steps after the spike?
0.999.
Problem 10Level 2
Adam’s average regret for C = 3 (short memory) in exercise 2?
0.663.
Problem 11Level 2
Adam’s average regret for C = 5?
1.991.
Problem 12Level 2
AMSGrad’s average regret for C = 3?
≈ 0.006.
Problem 13Level 2
Adam’s final x for C = 3 (short memory)?
+0.9997.
Level 3
Problem 14Level 3
Explain how Adam drifts to x = +1 in the counterexample.
With β₂ = 1/(1 + C²) the second moment almost resets every step. At the C-step, v is about (1 − β₂)C², large, so the step toward −1 is η·C/√v, of order η. At the next two steps v has fallen back to about 1, so each −1 gradient produces a step of order η toward +1. Two steps toward +1 outweigh one toward −1, so x drifts to the boundary +1, even though the average gradient points toward −1. ∎
Problem 15Level 3
Explain why the running maximum fixes it.
With v_max, the denominator after the first C-step stays at least (1 − β₂)C² forever. Every step, including the −1 steps, is divided by that same large value, so the sizes of the steps are proportional to the gradients themselves: C toward −1 and 1 + 1 toward +1 per period. Their sum has the sign of the average gradient (C − 2)/3 > 0, so x moves toward −1, and with ηₜ = η/√t it converges there. ∎
Problem 16Level 3
Explain why Adam with β₂ = 0.999 converged in exercise 2.
With β₂ = 0.999 the second moment averages over about 1000 steps, which spans hundreds of periods of the pattern. It settles near the average of g², about (C² + 2)/3, and barely changes between steps of a period. All three steps in a period are divided by nearly the same value, so the update follows the average gradient, as for AMSGrad. The failure needs the memory to be short compared with the gap between large gradients. ∎
Problem 17Level 3
Advise on β₂ for training a fault detector where informative large gradients occur only every few thousand steps.
Here the gap between informative gradients (thousands of steps) can exceed even β₂ = 0.999’s memory, the regime where Adam can underweight them. Options: use AMSGrad (amsgrad=True), so each large gradient keeps the denominator large; raise β₂ toward 0.9999 for a longer memory; or rebalance the data so informative examples occur more often (oversampling or class weights), which removes the root cause. Clip gradients to limit the permanent slowdown AMSGrad suffers after a genuinely bad outlier. Validate on the rare cases specifically. ∎
Level 4
Problem 18Level 4
Adam’s average regret for C = 2.5 (short memory)?
0.331.
Problem 19Level 4
Adam’s (β₂ = 0.999) final x for C = 5?
−0.9998.
Problem 20Level 4
AMSGrad’s effective rate just before the spike in exercise 1?
1.256.
Coding practice
🐍 Code 1 (Level 1): AMSGrad step
Adam moments, running max of v.
🐍 Code 2 (Level 0): running maximum
Maximum so far.
🐍 Code 3 (Level 0): average regret
Mean of loss minus best loss.
🐍 Code 4 (Level 0): projection
Clip to [lo, hi].
🐍 Code 5 (Level 0): the counterexample's gradient
C or −1.
Topic test
A timed test drawn at random from this topic's question bank. Each attempt gets new questions. For a longer test across the whole chapter, see the chapter test, or mix topics in the question bag.
AMSGrad: topic test
10 questions, drawn at random from a bank of 21. Every attempt is different.
⏱ Time limit: 15 minutes. The test submits itself when time runs out.
Levels covered: 0, 1, 2, 3, 4. No hints or solutions until you submit.