Skip to main content
QUICK REVIEW

[Paper Review] Toward Understanding Why Adam Converges Faster Than SGD for Transformers

Yan Pan, Yuanzhi Li|arXiv (Cornell University)|May 31, 2023
Stochastic Gradient Optimization TechniquesComputer Science6 citations
TL;DR

This paper explains why Adam converges faster than SGD in training Transformers by introducing directional sharpness as a key metric: SGD suffers from high directional sharpness due to imbalanced gradients across coordinates, while Adam's adaptive learning rates reduce this sharpness. The authors propose coordinate-wise clipping to mitigate this issue, demonstrating improved convergence speed and local loss reduction across multiple optimization algorithms.

ABSTRACT

While stochastic gradient descent (SGD) is still the most popular optimization algorithm in deep learning, adaptive algorithms such as Adam have established empirical advantages over SGD in some deep learning applications such as training transformers. However, it remains a question that why Adam converges significantly faster than SGD in these scenarios. In this paper, we propose one explanation of why Adam converges faster than SGD using a new concept directional sharpness. We argue that the performance of optimization algorithms is closely related to the directional sharpness of the update steps, and show SGD has much worse directional sharpness compared to adaptive algorithms. We further observe that only a small fraction of the coordinates causes the bad sharpness and slow convergence of SGD, and propose to use coordinate-wise clipping as a solution to SGD and other optimization algorithms. We demonstrate the effect of coordinate-wise clipping on sharpness reduction and speeding up the convergence of optimization algorithms under various settings. We show that coordinate-wise clipping improves the local loss reduction when only a small fraction of the coordinates has bad sharpness. We conclude that the sharpness reduction effect of adaptive coordinate-wise scaling is the reason for Adam's success in practice and suggest the use of coordinate-wise clipping as a universal technique to speed up deep learning optimization.

Motivation & Objective

  • To understand why Adam outperforms SGD in training Transformers despite similar theoretical convergence rates.
  • To identify the geometric properties of optimization trajectories that influence convergence speed in deep learning.
  • To analyze the role of gradient imbalance across network coordinates in degrading SGD performance.
  • To propose a simple, universal technique—coordinate-wise clipping—to improve convergence by reducing directional sharpness.
  • To validate that sharpness reduction via adaptive scaling is the key reason for Adam's empirical success.

Proposed method

  • Introduce directional sharpness as a measure of curvature along the update direction, arguing it better predicts optimization performance than standard metrics.
  • Define directional sharpness as the spectral norm of the Hessian projected onto the update direction, capturing local function smoothness.
  • Propose coordinate-wise clipping to limit the influence of high-gradient, high-sharpness coordinates, thereby reducing overall directional sharpness.
  • Use Gauss-Newton Hessian approximation to estimate local curvature in cross-entropy loss for neural networks.
  • Apply clipping to gradients before parameter updates, enabling larger stable step sizes and better local loss reduction.
  • Evaluate directional sharpness and convergence speed across multiple optimizers (SGD, Adam, Adafactor, etc.) on Transformers and ResNet.

Experimental results

Research questions

  • RQ1Why does Adam converge significantly faster than SGD when training Transformers, despite similar theoretical convergence guarantees?
  • RQ2What geometric property of optimization trajectories correlates with faster convergence in deep learning?
  • RQ3To what extent is the poor performance of SGD due to high directional sharpness caused by gradient imbalance across coordinates?
  • RQ4Can coordinate-wise clipping universally improve the convergence of optimization algorithms by reducing directional sharpness?
  • RQ5Is the observed sharpness behavior specific to Transformers or general across architectures?

Key findings

  • SGD exhibits significantly higher directional sharpness than Adam, especially in the early training phases of Transformers.
  • Only 1% to 2.5% of coordinates account for the majority of SGD’s directional sharpness, indicating a strong imbalance in gradient magnitudes.
  • Removing these high-sharpness coordinates via coordinate-wise clipping improves function smoothness by 2 to 3 times, leading to faster local loss reduction.
  • Coordinate-wise clipping reduces directional sharpness across all tested optimizers, including Adam and Adafactor, and consistently improves convergence speed.
  • The directional sharpness of adaptive algorithms like Adam and Adafactor can exceed that of SGD on non-Transformer architectures like ResNet, showing the phenomenon is specific to Transformers.
  • With optimal step sizes, low-directional-sharpness algorithms achieve significantly better local loss reduction, confirming sharpness as a key predictor of performance.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.