Toward Understanding Why Adam Converges Faster Than SGD for Transformers

Yan Pan, Yuanzhi Li · DOI

Introduction

While Stochastic Gradient Descent (SGD) is a staple of deep learning, it consistently underperforms when training Transformer architectures compared to adaptive optimizers like Adam. Despite Adam's empirical success, theoretical convergence proofs often fail to explain its superiority over SGD. This research investigates the gap by examining the local geometry of the loss landscape, specifically identifying directional sharpness as the primary factor limiting SGD's performance.

Methodology: Directional Sharpness

The authors move beyond global convergence rates to analyze the curvature along specific update directions. They define directional sharpness as $v^\top \nabla^2 f(x) v$, where $v$ is the update direction. This metric captures how "bumpy" the loss landscape is along the path chosen by the optimizer.

To compare optimizers fairly, the researchers use "pseudo-update steps," calculating the potential updates for different algorithms from the same point in training. They also propose Coordinate-wise Clipping, a meta-algorithm that identifies and clips the top $k\%$ of gradient coordinates by magnitude to prevent extreme curvature from dominating the update.

Key Insights: The 1% Problem

A critical discovery is that in Transformers, a tiny fraction of coordinates (often less than 4%) accounts for the vast majority of the Hessian's spectral norm. This imbalance leads to extreme directional sharpness for SGD.

Distribution of coordinate magnitudes for SGD, Adam, and Adafactor. SGD exhibits a much broader distribution of magnitudes, contributing to higher directional sharpness.

While SGD aligns well with the gradient direction, its directional sharpness can be millions of times higher than that of adaptive methods. Adam succeeds because its second-moment scaling ($1/\sqrt{v_t}$) acts as a coordinate-wise dampener, effectively targeting and scaling down the sharpest coordinates. Interestingly, this phenomenon is prominent in Transformers but absent in ResNets, where SGD often maintains lower directional sharpness and superior performance.

Key Results: Clipping as a Universal Optimizer Boost

The study demonstrates that coordinate-wise clipping can significantly bridge the performance gap between SGD and adaptive optimizers. By clipping the top 10% of gradient coordinates, SGD's directional sharpness is drastically reduced, allowing for larger, more effective step sizes.

Loss reduction vs. step size for various optimizers. Coordinate-wise clipping allows optimizers like SGD and Adam to take larger steps and achieve lower local loss.

On machine translation tasks, the directional sharpness of SGD was measured at approximately 8.67, whereas Adafactor with clipping reached a staggering $2.05 \times 10^{-7}$. Furthermore, applying a 50% clipping threshold to Adam further improved its local loss reduction, suggesting that clipping is a valuable "meta-technique" applicable across various optimization strategies.

Limitations and Future Work

Despite these advances, several questions remain. The optimal clipping percentage currently requires manual tuning; an adaptive thresholding mechanism would be a significant improvement. Additionally, while the paper identifies the imbalance in Transformers, it does not pinpoint which specific components (e.g., Attention vs. LayerNorm) are responsible for the sharp coordinates. Finally, while local geometry is a strong proxy for convergence speed, the long-term global trajectory effects of clipping warrant further study.

Summary updated

BibTeX
@inproceedings{pan2022toward,
  author = {Yan Pan and Yuanzhi Li},
  title = {{Toward Understanding Why Adam Converges Faster Than SGD for Transformers}},
  booktitle = {OPT @ NeurIPS},
  year = {2022},
  url = {https://openreview.net/forum?id=Sf1NlV2r6PO},
}
Figure