用归一化与去相关预处理,让无状态SGD媲美Adam训练大模型。
SWAN: SGD with Normalization and Whitening Enables Stateless LLM Training
- 对梯度做归一化和去相关预处理,实现无状态优化器
- 内存仅需Adam的50%,训练速度提升2倍,达到相同困惑度
- 适合追求高内存效率的大模型训练场景
自适应优化器如Adam在大语言模型训练中至关重要,但需维护优化器状态,导致内存开销是模型本身的数倍,限制了可扩展性和效率。相比之下,随机梯度下降(SGD)无需存储状态,内存效率最优,但在大模型训练中表现有限。本文提出一种无状态的梯度预处理方法:通过归一化稳定梯度分布,通过去相关(whitening)抵消损失曲面的局部曲率。由此构建的SWAN(SGD with Whitening And Normalization)无需存储任何优化器状态。实验表明,SWAN内存占用与SGD相当,较Adam减少约50%的总内存开销;在语言建模任务中,预训练3.5亿和13亿参数的LLaMA模型时,使用一半的训练样本即可达到相同的评估困惑度,实现2倍加速。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。