On the Variance of the Adaptive Learning Rate and Beyond

Liyuan Liu, Haoming Jiang, Pengcheng He, Weizhu Chen, Xiaodong Liu, Jianfeng Gao, Jiawei Han

TL;DR

This paper identifies that the "learning rate warmup" heuristic—essential for training models like Transformers—works by mitigating the extreme variance of adaptive learning rates in the early stages of training. The authors introduce Rectified Adam (RAdam), an optimizer that mathematically predicts and offsets this variance, providing the stability of warmup without the need for manual hyperparameter tuning.

What Problem Does This Paper Address?

Adaptive optimization algorithms like Adam and RMSprop are the workhorses of modern deep learning because they converge quickly by adjusting learning rates for each parameter. However, they are notoriously unstable at the start of training. Without a "warmup" period—where the learning rate is manually kept very small for the first few thousand iterations—these models often converge to "suspicious" local optima or fail to train entirely.

Gradient distribution distortion in early updates

While warmup is a standard "trick," it lacks a solid theoretical foundation. Researchers usually have to guess how many warmup steps are needed for a new architecture. This paper asks: Why is warmup necessary, and can we build an optimizer that handles this stabilization automatically?

Methods

The authors hypothesize that the root cause of early instability is the high variance of the adaptive learning rate. In the first few steps of training, the optimizer has seen very few gradient samples, making its estimate of the "adaptive" term (the moving average of squared gradients) extremely unreliable.

To solve this, they propose Rectified Adam (RAdam):

  1. Variance Analysis: They model the adaptive learning rate term using a scaled inverse chi-square distribution. They prove that in the very early stages, the variance of this term is "problematically large" (even divergent).
  2. The Rectification Term ($r_t$): Instead of a heuristic linear ramp-up, RAdam calculates a rectification factor based on the "degrees of freedom" of the moving average.
  3. Dynamic Switching:
    • If the variance is intractable (very early in training), RAdam effectively "turns off" the adaptive part and acts like SGD with momentum.
  4. As more samples are collected and the variance stabilizes, it smoothly transitions into a rectified version of Adam.

Datasets

The authors validated RAdam across several diverse and standard benchmarks:

  • Language Modeling: One Billion Word dataset (using LSTMs).
  • Image Classification: CIFAR-10 and ImageNet (using ResNet-18 and ResNet-20).
  • Neural Machine Translation (NMT): IWSLT’14 (De-En/En-De) and WMT’16 (En-De) using Transformer architectures.

Key Insights and Ideas

  • Warmup is Variance Reduction: The most significant "aha moment" is the realization that warmup isn't just about "starting slow"; it's a crude way to perform variance reduction.
  • The "Divergent" Start: The paper shows that at $t=1$, the variance of the adaptive learning rate is technically infinite. This explains why vanilla Adam often "breaks" a model in the first ten updates if no warmup is used.
  • Automatic Adaptation: Unlike standard warmup, which requires a user to specify a fixed number of steps (e.g., 4,000 steps), RAdam’s rectification term is derived from the moving average coefficients ($\beta_2$). It adapts itself to the optimizer's own internal logic.
  • Robustness to Learning Rates: RAdam is significantly less sensitive to the initial learning rate than vanilla Adam or SGD, making it much easier to use for new, unexplored model architectures.

Key Results

  • Stability: On the De-En IWSLT’14 NMT task, removing warmup from vanilla Adam caused the training loss to jump from ~3 to ~10. RAdam achieved the lower loss (~3) automatically without any manual warmup.
Training loss comparison showing vanilla Adam failing without warmup
  • Performance: RAdam consistently matched or slightly outperformed Adam with optimal warmup across ImageNet and Language Modeling tasks. For example, on ImageNet, RAdam achieved a top-1 accuracy of 67.62%, compared to Adam's 66.54%.
  • Hyperparameter Sensitivity: In tests on CIFAR-10, RAdam provided consistent performance across a wide range of learning rates ($0.1$ to $0.003$), whereas vanilla Adam failed to converge at higher learning rates.

Limitations and Future Work

  • Computational Overhead: While RAdam automates the warmup, it adds a small amount of mathematical complexity to each update step (though this is negligible in the context of training large neural networks).
  • Assumption of Normality: The theoretical derivation assumes that gradients follow a normal distribution. While the authors provide simulations suggesting the method is robust even when this assumption is slightly violated, extreme edge cases in non-standard architectures might behave differently.
  • Future Directions: The authors suggest exploring "sharing" the second-moment estimation (the adaptive part) across similar parameters to further reduce variance and improve convergence speed.

Summary updated

BibTeX
@inproceedings{liu2020variance,
  author = {Liyuan Liu and Haoming Jiang and Pengcheng He and Weizhu Chen and Xiaodong Liu and Jianfeng Gao and Jiawei Han},
  title = {{On the Variance of the Adaptive Learning Rate and Beyond}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
}
Figure