Can We Remove the Square-Root in Adaptive Gradient Methods? A Second-Order Perspective

Wu Lin, Felix Dangel, Runa Eschenhagen, Juhan Bae, Richard E. Turner +1 more
2/1/2024
28 citations
transformer-attention

Official code: f-dangel/sirfshampoo (15 stars, Python, MIT, last commit 2024-11-04). 1 more implementation below.

Abstract

Adaptive gradient optimizers like Adam(W) are the default training algorithms for many deep learning architectures, such as transformers. Their diagonal preconditioner is based on the gradient outer product which is incorporated into the parameter update via a square root.

Show full abstract

While these methods are often motivated as approximate second-order methods, the square root represents a fundamental difference. In this work, we investigate how the behavior of adaptive methods changes when we remove the root, i.e., strengthen their second-order motivation. Surprisingly, we find that such square-root-free adaptive methods close the generalization gap to SGD on convolutional architectures, while maintaining their root-based counterpart's performance on transformers. The second-order perspective also has practical benefits for developing non-diagonal methods that can incorporate arbitrary curvature approximations through the concept of preconditioner invariance. In contrast to root-based methods like Shampoo, root-free counterparts work well and fast with half-precision since they do not require numerically unstable matrix root decompositions and inversions. Overall, our findings provide new insights into the development of adaptive methods and raise important questions regarding the overlooked role of adaptivity in their success. (experiment code: https://github.com/yorkerlin/remove-the-square-root optimizer code: https://github.com/f-dangel/sirfshampoo)

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
f-dangel/sirfshampooOfficial15PythonMIT2024-11-04
yorkerlin/remove-the-square-rootOfficial3Python–2024-07-19
MIT

[ICML 2024] SIRFShampoo: Structured inverse- and root-free Shampoo in PyTorch (https://arxiv.org/abs/2402.03496)

151Python, MakefileApr 5, 20242 years agoMIT

Square-root-free Adaptive Methods; Experiment code for ICML 2024 paper on Can We Remove the Square-Root in Adaptive Gradient Methods? A Second-Order Perspective

31Python, ShellJun 13, 20242 years ago

Similar Papers

Cite this paper

@article{lin2024remove,
  title  = {Can We Remove the Square-Root in Adaptive Gradient Methods? A Second-Order Perspective},
  author = {Wu Lin and Felix Dangel and Runa Eschenhagen and Juhan Bae and Richard E. Turner and Alireza Makhzani},
  year   = {2024},
  eprint = {2402.03496},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2402.03496},
  journal = {ICML 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.03496.svg)](https://codeofpaper.com/paper/2402.03496)

Discussion