Adam with model exponential moving average is effective for nonconvex optimization

Kwangjun Ahn, Ashok Cutkosky

Introduction

Despite the overwhelming dominance of the Adam optimizer in training large-scale models like Transformers, theoretical explanations for its success have often lagged behind its practical applications. Furthermore, practitioners almost universally pair Adam with a Model Exponential Moving Average (EMA)—keeping a running average of the model weights—to stabilize training in complex applications such as Diffusion models and GANs. This paper provides a long-awaited theoretical justification for why the combination of Adam and Model EMA is so remarkably effective, proving that momentum, adaptivity, and EMA are mathematically optimal components of a unified optimization strategy.

The Theoretical Gap: Practice vs. Theory

Historically, theoretical analyses of Adam have felt disconnected from real-world results. Many existing frameworks suggest that Adam’s convergence rate is no better—or even worse—than standard Stochastic Gradient Descent (SGD). Some studies have even implied that momentum, a core feature of Adam, might hinder convergence in certain nonconvex settings.

Additionally, most nonconvex optimization theory relies on "random iterate selection" (picking a random point from the training history) to prove convergence. This technique is almost never used in practice. By contrast, this paper bridges the gap by demonstrating that Model EMA is not merely a heuristic stabilization trick, but a theoretically sound mechanism for achieving optimal convergence.

Methodology: Discounted Online-to-Nonconvex Conversion

The authors approach the optimization problem through the lens of Online-to-Nonconvex Conversion, treating the choice of optimization increments as an online learning problem. Their framework introduces several key technical innovations:

  • Discounted-to-Nonconvex Conversion: Unlike standard frameworks that weight all past gradients equally, this method uses a discounting factor ($\beta$) to prioritize recent information. This naturally necessitates the use of momentum, proving that integrating past gradient history is essential for fast nonconvex convergence.
  • Scale-Free FTRL: The authors utilize a "Follow-the-Regularized-Leader" (FTRL) approach that is scale-free, ensuring the algorithm's performance remains stable even if the loss function is scaled by a constant.
  • Coordinate-Wise Adaptivity: By applying the discounted FTRL framework to each dimension independently, the authors derive CLIPPED-ADAM.
  • EMA as the Natural Output: Within this framework, Model EMA emerges not as an afterthought, but as the mathematically derived "best guess" for the optimal point at any given time, minimizing "discounted regret."

Key Insights and Optimal Convergence Rates

The theoretical analysis yields several profound insights into why Adam and EMA excel in high-dimensional, nonconvex landscapes:

1. Optimal Convergence in Smooth and Nonsmooth Settings

The authors prove that CLIPPED-ADAM with EMA achieves an iteration complexity of $O(\epsilon^{-7/2})$ for finding Goldstein stationary points in nonsmooth nonconvex settings (e.g., networks with ReLU activations). This matches known theoretical lower bounds, meaning the algorithm is as efficient as mathematically possible for this class of problems. For smooth functions, the rate translates to an optimal $O(\epsilon^{-4})$.

2. The Power of Coordinate-Wise Adaptivity

Adam’s ability to scale updates differently for each dimension is shown to be a massive advantage when the Lipschitz constant (or "steepness") varies across coordinates. In heterogeneous settings where a few dimensions have much larger gradients than others, the coordinate-wise approach of Adam leads to a complexity of $O(d^{1/2} \epsilon^{-7/2})$. In contrast, non-adaptive methods suffer a much worse $O(d^{3/2} \epsilon^{-7/2})$ complexity—demonstrating a provable $d$-factor improvement.

Limitations and Future Directions

While this work provides a robust theoretical foundation, it notes a few limitations. First, the analysis applies to a clipped version of Adam. Although clipping is often a "no-op" in practice once a model begins to converge, the theory requires it to control variance. Second, the theoretical "optimal" hyperparameters derived in the paper ($\beta_1 = \beta, \beta_2 = \beta^2$) do not perfectly align with the standard defaults used in libraries like PyTorch (typically $\beta_1=0.9, \beta_2=0.999$). Investigating this discrepancy remains an open path for future research. Finally, as a purely theoretical work, it does not explore how these optimal rates translate to wall-clock time on specific hardware or interact with practical tricks like learning rate schedules.

Overall, this paper successfully grounds the empirical success of Adam and EMA in rigorous mathematics, proving that their core components are essential for optimal nonconvex optimization.

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