Deconstructing What Makes a Good Optimizer for Language Models

Rosie Zhao, Depen Morwani, David Brandfonbrener, Nikhil Vyas, Sham Kakade
7/10/2024
cs.LGcs.AI

No official code found. Best implementation: rosieyzh/optimizers-llm (3 stars, Apache-2.0, last commit 2024-08-13).

Abstract

Training language models becomes increasingly expensive with scale, prompting numerous attempts to improve optimization efficiency. Despite these efforts, the Adam optimizer remains the most widely used, due to a prevailing view that it is the most effective approach. We aim to compare several optimization algorithms, including SGD, Adafactor, Adam, Lion, and Sophia in the context of autoregressive language modeling across a range of model sizes, hyperparameters, and architecture variants. Our findings indicate that, except for SGD, these algorithms all perform comparably both in their optimal performance and also in terms of how they fare across a wide range of hyperparameter choices. Our results suggest to practitioners that the choice of optimizer can be guided by practical considerations like memory constraints and ease of implementation, as no single algorithm emerged as a clear winner in terms of performance or stability to hyperparameter misspecification. Given our findings, we further dissect these approaches, examining two simplified versions of Adam: a) signed momentum (Signum) which we see recovers both the performance and hyperparameter stability of Adam and b) Adalayer, a layerwise variant of Adam which we introduce to study the impact on Adam's preconditioning for different layers of the network. Examining Adalayer leads us to the conclusion that, perhaps surprisingly, adaptivity on both the last layer and LayerNorm parameters in particular are necessary for retaining performance and stability to learning rate.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Code for "Deconstructing What Makes a Good Optimizer for Language Models"

30C, C++Aug 13, 20242 years agoApache-2.0

Similar Papers

Cite this paper

@article{zhao2024deconstructing,
  title  = {Deconstructing What Makes a Good Optimizer for Language Models},
  author = {Rosie Zhao and Depen Morwani and David Brandfonbrener and Nikhil Vyas and Sham Kakade},
  year   = {2024},
  eprint = {2407.07972},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2407.07972v2},
  journal = {ICLR 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/2407.07972.svg)](https://codeofpaper.com/paper/2407.07972)

Discussion