SPAM:具有动量重置的尖峰感知Adam,用于稳定的LLM训练
SPAM: Spike-Aware Adam with Momentum Reset for Stable LLM Training
AI总结:
针对LLM训练中的梯度尖峰问题,提出尖峰感知Adam优化器SPAM,通过动量重置和尖峰感知梯度裁剪提升稳定性,并在预训练、微调等任务中优于Adam等基线。
摘要:
大型语言模型(LLM)在多种任务中展现了卓越的性能,然而其训练过程仍然高度消耗资源,并且容易面临训练不稳定等关键挑战。这种不稳定的主要来源之一是梯度和损失尖峰,它们会干扰学习过程,常常导致代价高昂的干预措施,如检查点恢复和实验重启,进一步加剧了效率低下问题。本文对LLM训练中观察到的梯度尖峰进行了全面研究,揭示了它们在多种架构和数据集中的普遍性。我们的分析表明,这些尖峰可能比典型梯度大高达1000倍,显著损害模型性能。为解决这一问题,我们提出了尖峰感知Adam与动量重置(SPAM),这是一种新颖的优化器,旨在通过动量重置和尖峰感知梯度裁剪来对抗梯度尖峰。大量实验,包括预训练和微调,表明SPAM在各种任务上始终优于Adam及其变体,包括(1)从60M到1B规模的LLM预训练,(2)4位LLM预训练,(3)强化学习,以及(4)时间序列预测。此外,SPAM通过启用稀疏动量促进了内存高效的训练,其中仅维护和更新一部分动量项。在内存受限的情况下,SPAM优于最先进的内存高效优化器,如GaLore和Adam-Mini。我们的工作强调了在LLM训练中减轻梯度尖峰的重要性,并介绍了一种有效的优化策略,该策略在规模上增强了训练稳定性和资源效率。代码可在https://github.com/TianjinYellow/SPAM-Optimizer.git获取。
英文摘要:
Large Language Models (LLMs) have demonstrated exceptional performance across diverse tasks, yet their training remains highly resource-intensive and susceptible to critical challenges such as training instability. A predominant source of this instability stems from gradient and loss spikes, which disrupt the learning process, often leading to costly interventions like checkpoint recovery and experiment restarts, further amplifying inefficiencies. This paper presents a comprehensive investigation into gradient spikes observed during LLM training, revealing their prevalence across multiple architectures and datasets. Our analysis shows that these spikes can be up to $1000\times$ larger than typical gradients, substantially deteriorating model performance. To address this issue, we propose Spike-Aware Adam with Momentum Reset SPAM, a novel optimizer designed to counteract gradient spikes through momentum reset and spike-aware gradient clipping. Extensive experiments, including both pre-training and fine-tuning, demonstrate that SPAM consistently surpasses Adam and its variants across various tasks, including (1) LLM pre-training from 60M to 1B, (2) 4-bit LLM pre-training,(3) reinforcement learning, and (4) Time Series Forecasting. Additionally, SPAM facilitates memory-efficient training by enabling sparse momentum, where only a subset of momentum terms are maintained and updated. When operating under memory constraints, SPAM outperforms state-of-the-art memory-efficient optimizers such as GaLore and Adam-Mini. Our work underscores the importance of mitigating gradient spikes in LLM training and introduces an effective optimization strategy that enhances both training stability and resource efficiency at scale. Code is available at https://github.com/TianjinYellow/SPAM-Optimizer.git
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。