Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Don’t trust an estimate built from one sample
Adam scales each step by an average of past squared gradients. At step 1 that “average” is a single number, and at step 5 it is five numbers, so it is a very rough estimate of the true gradient scale. Dividing by a rough estimate can make the first steps wildly too large or small, which is why practitioners ramp the learning rate up slowly (warm-up). RAdam works out how uncertain the estimate still is and shrinks the adaptive step accordingly, giving a warm-up that follows from the statistics rather than a hand-picked schedule.
Training instabilities in the first few hundred steps waste compute and can permanently damage a run. Large transformers, deep networks without normalisation, and networks trained from scratch on small or noisy datasets are all susceptible. RAdam removes one hyperparameter (the warm-up length) and makes early training more predictable.
- 1. Adam's early steps are unreliable because…
- 2. RAdam's rectification grows from about 0 to…
- 3. RAdam replaces…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Equivalent averaging length: an exponential moving average with decay β₂ is treated as a simple moving average of length ρ. Its maximum is ρ∞ = 2/(1 − β₂) − 1: 1999 for β₂ = 0.999 and 199 for β₂ = 0.99.
- At step t: ρₜ = ρ∞ − 2tβ₂ᵗ/(1 − β₂ᵗ), with ρ₁ = 1.
- Rectification: for ρₜ > 4, rₜ = √[(ρₜ − 4)(ρₜ − 2)ρ∞ / ((ρ∞ − 4)(ρ∞ − 2)ρₜ)], and the step is η·rₜ·m̂/(√v̂ + ε). For ρₜ ≤ 4 the variance is undefined, and RAdam takes an un-normalised momentum step η·m̂.
- Numbers for β₂ = 0.999:
- adaptive steps start at t = 5, with rₜ ≈ 0.017;
- rₜ reaches 0.5 at t = 556 and 0.9 at t = 2737.
- Linear warm-up, for comparison: η·min(1, t/T). For T = 100 at t = 50, the learning rate is half of η.
- 1. ρ∞ for β₂ = 0.99?
- 2. RAdam's first adaptive step (β₂ = 0.999) is…
- 3. Before that, RAdam takes…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.RAdam in code
Exercise 1.
- ρ∞ = 1999.
- RAdam’s adaptive steps begin at t = 5 with a rectification of 0.017.
- The rectification increases monotonically, reaching 0.5 at t = 556 and 0.9 at t = 2737.
That is an implied warm-up lasting a few thousand steps, longer than typical hand-set warm-ups, and determined entirely by β₂.
Practice.
- Use the same η and β’s as Adam.
- PyTorch’s RAdam supports decoupled weight decay (
decoupled_weight_decay=True). - The first few momentum-SGD steps are un-normalised, so their size depends on the gradient scale. Very large initial gradients can still cause trouble; gradient clipping guards against it.
- Liu et al. found RAdam competitive with tuned Adam-plus-warm-up on image classification and translation; other studies found a short warm-up works about as well. RAdam’s advantage is not needing to choose one.
torch.optim.RAdam(params, lr=1e-3, betas=(0.9, 0.999))- 1. RAdam's implied warm-up for β₂ = 0.999 reaches 0.9 at about…
- 2. RAdam's early momentum steps are…
- 3. A guard against huge first gradients is…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
The variance argument. Liu et al. (2020) modelled the gradients as Gaussian with zero mean and showed that the variance of the adaptive learning rate 1/√v̂ₜ is divergent for very small t and large for the first hundreds of steps. That is the source of early instability, and it explains why warm-up, which shrinks η exactly while this variance is large, works.
The rectification. Treating v̂ₜ as a simple moving average of ρₜ squared samples, 1/√v̂ has a scaled inverse-chi distribution. Its variance is finite only for ρₜ > 4. The factor rₜ rescales the adaptive step so that its variance matches the long-run value at ρ∞: it is the ratio of standard deviations. For ρₜ ≤ 4 there is nothing to rescale, so RAdam falls back to un-normalised momentum.
Limits.
- The analysis is approximate: gradients are not Gaussian or independent.
- The implied warm-up depends only on β₂, not on the model or data.
- Subsequent work (Ma and Yarats, 2021) argued that a simple linear warm-up over about 2/(1 − β₂) steps matches RAdam closely. Exercise 2’s 100-step warm-up was much shorter than that and did not help.
- 1. The variance of Adam's adaptive rate is finite only when ρₜ exceeds…
- 2. RAdam was introduced by…
- 3. Ma and Yarats suggested a linear warm-up over about…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Rectification versus warm-up
History.
- Learning-rate warm-up became standard with large-batch training (Goyal et al., 2017) and transformers (Vaswani et al., 2017).
- L. Liu et al. (2020) explained warm-up through the variance of the adaptive rate and introduced RAdam.
- J. Ma and D. Yarats (2021) showed an untuned linear warm-up of about 2/(1 − β₂) steps performs similarly.
Exercise 2. An 8-layer tanh network (width 32, no normalisation) on spirals, mini-batches of 32, 400 steps, comparing Adam, Adam with a 100-step linear warm-up, and RAdam at three learning rates. “Largest rise” is the biggest increase in training loss between consecutive 10-step checks.
| method | η | largest rise (2 seeds) | final loss (2 seeds) |
|---|---|---|---|
| Adam | 0.003 | 0.453, 0.087 | 0.009, 0.002 |
| Adam + warm-up | 0.003 | 0.052, 0.422 | 0.010, 0.430 |
| RAdam | 0.003 | 0.006, 0.004 | 0.006, 0.010 |
| Adam | 0.01 | 0.417, 0.184 | 0.098, 0.001 |
| Adam + warm-up | 0.01 | 0.709, 0.174 | 0.043, 0.016 |
| RAdam | 0.01 | 0.010, 0.472 | 0.001, 0.012 |
| Adam | 0.03 | 0.562, 0.320 | 1.148, 0.822 |
| Adam + warm-up | 0.03 | 0.930, 0.350 | 0.945, 0.757 |
| RAdam | 0.03 | 0.429, 0.625 | 0.489, 0.015 |
A separate native probe with four more seeds confirmed the pattern:
-
at η = 0.003, RAdam’s largest rise was 0–0.03, against up to 0.15 for Adam;
-
at η = 0.03, RAdam’s final loss averaged about 0.3, against about 1.0 for Adam and for Adam with warm-up.
-
RAdam almost removed loss spikes at the small learning rate, at the cost of slightly slower final progress (its rectification keeps steps small for hundreds of steps).
-
At the large learning rate everything was unstable, but RAdam still reached much lower losses.
-
The 100-step linear warm-up did not stabilise Adam here. It is far shorter than the roughly 2000 steps that the variance argument (and Ma and Yarats) suggest for β₂ = 0.999. RAdam needs no such choice.
-
Seed-to-seed variation was large (spikes of 0.01 against 0.47 at η = 0.01), so judge stability over several seeds.
RAdam in AI, robotics and aerospace
- Training from scratch on new sensor modalities, where good warm-up settings are unknown, benefits from an automatic warm-up.
- Deep networks without normalisation (some control and physics-informed models) are prone to early instability.
- Automated pipelines that train many models (hyperparameter sweeps, per-vehicle models) remove one tuning knob.
References
- L. Liu, H. Jiang, P. He, W. Chen, X. Liu, J. Gao, J. Han (2020). “On the variance of the adaptive learning rate and beyond.” Proc. ICLR.
- J. Ma, D. Yarats (2021). “On the adequacy of untuned warmup for adaptive optimization.” Proc. AAAI.
- P. Goyal et al. (2017). “Accurate, large minibatch SGD: training ImageNet in 1 hour.” arXiv:1706.02677.