Adam with model exponential moving average is effective for nonconvex optimization

Kwangjun Ahn, Ashok Cutkosky

TL;DR

This paper bridges the gap between the practical success and theoretical understanding of the Adam optimizer combined with Model Exponential Moving Average (EMA). By leveraging an online-to-nonconvex learning framework, the authors prove that a clipped version of Adam with EMA achieves optimal convergence rates in both smooth and nonsmooth nonconvex optimization, providing the first analysis that crucially relies on Adam's core components: momentum, discounting factors, and coordinate-wise adaptivity.

What Problem Does This Paper Address?

Despite Adam's ubiquity in training large-scale models like Transformers, theoretical justifications for its success have historically fallen short. Many existing proofs suggest that Adam's convergence rate actually worsens with momentum or offers no benefit over standard Stochastic Gradient Descent (SGD)—a stark contradiction to empirical reality.

Furthermore, standard optimization theory often assumes the final output of an algorithm is a randomly selected iterate from the training trajectory. In practice, engineers almost always use a Model Exponential Moving Average (EMA) of the weights to stabilize training and improve generalization. This paper addresses this theory-practice mismatch by providing a rigorous analysis of Adam with model EMA in nonconvex, potentially nonsmooth settings.

Methods

The authors analyze a variant called CLIPPED-ADAM by framing optimization as a game of online learning. They utilize the online-to-nonconvex conversion framework, which translates an online learner's ability to minimize "discounted regret" into a nonconvex optimizer's ability to find stationary points.

The key methodological steps include:

  1. Discounted FTRL: The authors show that running a discounted version of the scale-free Follow-the-Regularized-Leader (FTRL) algorithm coordinate-wise yields the core update rule of Adam.
  2. Iterate Clipping: To control variance in nonsmooth settings, they incorporate a coordinate-wise clipping mechanism based on the EMA of past gradients.
  3. Natural EMA Integration: Within this framework, Model EMA is not just an arbitrary add-on; it naturally emerges as the mathematical expectation of the optimization iterates under a specific randomized step-size regime.

The foundational FTRL algorithm used in their reduction is outlined below:

Algorithm 2: Follow-the-Regularized-Leader (FTRL)

Datasets

None used. This is a purely theoretical paper focused on mathematical proofs of convergence complexities.

Key Insights and Ideas

  • Momentum and Discounting are Essential: Unlike previous analyses where momentum was a hindrance to the proof, this framework requires momentum and discounting factors ($\beta_1, \beta_2$) to guarantee low discounted regret in the underlying online learning problem.
  • EMA is Theoretically Sound: The paper provides a clean optimization-driven justification for Model EMA, showing it directly minimizes the variance term required to hit optimal stationarity bounds.
  • The Power of Coordinate Adaptivity: The authors mathematically formalize why coordinate-wise learning rates help. When gradient scales are highly heterogeneous across different dimensions (common in deep learning), adapting to each coordinate independently prevents large gradients from dominating and slowing down progress on flatter coordinates.

Key Results

  • Optimal Convergence Rates: The authors prove that CLIPPED-ADAM with EMA achieves the minimax optimal iteration complexity of $\mathcal{O}(\epsilon^{-7/2})$ for finding $(\lambda, \epsilon)$-stationary points in nonsmooth nonconvex settings. For smooth settings, this translates to the optimal $\mathcal{O}(\epsilon^{-4})$ rate.
  • Provable Coordinate-Wise Speedup: When coordinates are heterogeneous (i.e., a few coordinates have much larger gradient magnitudes than others), CLIPPED-ADAM reduces the iteration complexity by a multiplicative factor of $d$ (the dimension of the model) compared to non-adaptive methods like SGD.

Limitations and Future Work

While a major step forward, the authors note a few limitations:

  • Hyperparameter Mismatch: The theoretical analysis dictates setting $\beta_2 = \beta_1^2$, which does not perfectly align with the standard empirical defaults (e.g., $\beta_1=0.9, \beta_2=0.999$).
  • Clipping Dependency: The algorithm relies on an explicit clipping step to guarantee variance bounds in the proof, though the authors conjecture this clipping is often a "no-op" in practical, converging regimes.
  • Unknown Constants: When the Lipschitz constant $G$ and variance $\sigma$ are completely unknown, the iteration complexity degrades slightly, leaving open the question of whether a fully adaptive optimal rate is achievable.

Summary updated

BibTeX
@inproceedings{ahn2024adam,
  author = {Kwangjun Ahn and Ashok Cutkosky},
  title = {{Adam with model exponential moving average is effective for nonconvex optimization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=v416YLOQuU},
}
Figure