2025-02-25 · 专家 · 机器学习

Stable-SPAM: How to Train in 4-Bit More Stably than 16-Bit Adam

本文提出了一种名为Stable-SPAM的优化器,通过增强的梯度归一化和剪裁技术,在4位精度下训练大型语言模型时,比16位Adam更稳定,并实现了更好的性能。

更新于 2025-02-25。作者:Tianjin Huang、Haotian Hu、Zhenyu Zhang、Gaojie Jin、Xiang Li、Li Shen、Tianlong Chen、Lu Liu、Qingsong Wen、Zhangyang Wang、Shiwei Liu。

中文摘要

本文全面评估了针对4位训练提出的几种优化器,发现低精度位数会加剧对学习率的敏感性,并经常导致梯度范数不稳定,在高学习率下引起发散。在这些优化器中,SPAM以其动量重置和尖峰梯度裁剪为特点,在各个位数级别上取得了最佳性能,但难以稳定梯度范数,需要仔细调整学习率。为了解决这些局限性,我们提出了Stable-SPAM,该优化器融合了改进的梯度归一化和裁剪技术。具体来说,Stable-SPAM(1)通过跟踪尖峰梯度的历史最大值自适应地更新裁剪阈值;(2)根据其历史l_2范数统计对整个梯度矩阵进行归一化;(3)从SPAM继承了动量重置,周期性地重置Adam的第一和第二矩,以减轻尖峰梯度的累积。广泛的实验表明,Stable-SPAM有效地稳定了4位LLM训练中的梯度范数,相比Adam和SPAM提供了更优越的性能。值得注意的是,我们使用Stable-SPAM训练的4位LLaMA-1B模型在困惑度方面比使用Adam训练的BF16 LLaMA-1B模型提高了高达2个百分点。此外,当两个模型都在4位下进行训练时,Stable-SPAM达到了与Adam相同的损失,但所需的训练步数仅为后者的一半左右。代码可在https://github.com/TianjinYellow/StableSPAM.git上获取。

英文摘要

This paper comprehensively evaluates several recently proposed optimizers for 4-bit training, revealing that low-bit precision amplifies sensitivity to learning rates and often causes unstable gradient norms, leading to divergence at higher learning rates. Among these, SPAM, a recent optimizer featuring momentum reset and spike-aware gradient clipping, achieves the best performance across various bit levels, but struggles to stabilize gradient norms, requiring careful learning rate tuning. To address these limitations, we propose Stable-SPAM, which incorporates enhanced gradient normalization and clipping techniques. In particular, Stable-SPAM (1) adaptively updates the clipping threshold for spiked gradients by tracking their historical maxima; (2) normalizes the entire gradient matrix based on its historical l_2-norm statistics; and (3) inherits momentum reset from SPAM to periodically reset the first and second moments of Adam, mitigating the accumulation of spiked gradients. Extensive experiments show that Stable-SPAM effectively stabilizes gradient norms in 4-bit LLM training, delivering superior performance compared to Adam and SPAM. Notably, our 4-bit LLaMA-1B model trained with Stable-SPAM outperforms the BF16 LLaMA-1B trained with Adam by up to 2 perplexity. Furthermore, when both models are trained in 4-bit, Stable-SPAM achieves the same loss as Adam while requiring only about half the training steps. Code is available at https://github.com/TianjinYellow/StableSPAM.git.

解读

一句话总结

本文提出了一种名为Stable-SPAM的优化器,通过增强的梯度归一化和剪裁技术,在4位精度下训练大型语言模型时,比16位Adam更稳定,并实现了更好的性能。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源

机器可读索引:llms.txt