Why Transformers Need Adam: A Hessian Perspective

Yushun Zhang, Congliang Chen, Tian Ding, Ziniu Li, Ruoyu Sun +1 more
2/3/2026

No official code found. Best implementation: zyushun/hessian-spectrum (65 stars, last commit 2025-03-11).

Abstract

SGD performs worse than Adam by a significant margin on Transformers, but the reason remains unclear. In this work, we provide an explanation through the lens of Hessian: (i) Transformers are"heterogeneous": the Hessian spectrum across parameter blocks vary dramatically, a phenomenon we call"block heterogeneity"; (ii) Heterogeneity hampers SGD: SGD performs worse than Adam on problems with block heterogeneity. To validate (i) and (ii), we check various Transformers, CNNs, MLPs, and quadratic problems, and find that SGD can perform on par with Adam on problems without block heterogeneity, but performs worse than Adam when the heterogeneity exists. Our initial theoretical analysis indicates that SGD performs worse because it applies one single learning rate to all blocks, which cannot handle the heterogeneity among blocks. This limitation could be ameliorated if we use coordinate-wise learning rates, as designed in Adam.

View on arXivView PDF

Code Implementations(1)

Code for the paper: Why Transformers Need Adam: A Hessian Perspective

658Shell, PythonFeb 26, 20241 years ago

Similar Papers

Cite this paper

@article{zhang2026transformers,
  title  = {Why Transformers Need Adam: A Hessian Perspective},
  author = {Yushun Zhang and Congliang Chen and Tian Ding and Ziniu Li and Ruoyu Sun and Zhimin Luo},
  year   = {2026},
  eprint = {2402.16788},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2402.16788},
  url    = {https://arxiv.org/abs/2402.16788},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.16788.svg)](https://codeofpaper.com/paper/2402.16788)

Discussion