SWAN: SGD with Normalization and Whitening Enables Stateless LLM Training

Chao Ma, Wenbo Gong, Meyer Scetbon, Edward Meeds
12/17/2024
cs.LGcs.AI

No official code found. Best implementation: ethansmith2000/SWANOptimizer (2 stars, MIT, last commit 2024-12-20).

Abstract

Adaptive optimizers such as Adam (Kingma & Ba, 2015) have been central to the success of large language models. However, they often require to maintain optimizer states throughout training, which can result in memory requirements several times greater than the model footprint. This overhead imposes constraints on scalability and computational efficiency. Stochastic Gradient Descent (SGD), in contrast, is a stateless optimizer, as it does not track state variables during training. Consequently, it achieves optimal memory efficiency. However, its capability in LLM training is limited (Zhao et al., 2024b). In this work, we show that pre-processing SGD in a stateless manner can achieve the same performance as the Adam optimizer for LLM training, while drastically reducing the memory cost. Specifically, we propose to pre-process the instantaneous stochastic gradients using normalization and whitening. We show that normalization stabilizes gradient distributions, and whitening counteracts the local curvature of the loss landscape. This results in SWAN (SGD with Whitening And Normalization), a stochastic optimizer that eliminates the need to store any optimizer states. Empirically, SWAN has the same memory footprint as SGD, achieving $\approx 50\%$ reduction on total end-to-end memory compared to Adam. In language modeling tasks, SWAN demonstrates comparable or even better performance than Adam: when pre-training the LLaMA model with 350M and 1.3B parameters, SWAN achieves a 2x speedup by reaching the same evaluation perplexity using half as many tokens.

View on arXivView PDF

Code Implementations(1)

MIT

Unofficial implementation of https://arxiv.org/abs/2412.13148

20PythonDec 20, 20241 years agoMIT

Similar Papers

Cite this paper

@article{ma2024swan,
  title  = {SWAN: SGD with Normalization and Whitening Enables Stateless LLM Training},
  author = {Chao Ma and Wenbo Gong and Meyer Scetbon and Edward Meeds},
  year   = {2024},
  eprint = {2412.13148},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.13148v3},
  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/2412.13148.svg)](https://codeofpaper.com/paper/2412.13148)

Discussion