提出自适应梯度裁剪方法AdaGC,解决大模型预训练中的损失突增问题。
AdaGC: Enhancing LLM Pretraining Stability via Adaptive Gradient Clipping
- 基于张量级指数移动平均,动态裁剪梯度以抑制异常值污染
- 在多个大模型上实现零损失突增,下游准确率提升1.27%~2.48%
- 兼容多种优化器,适合分布式训练场景下的稳定性需求
大规模语言模型预训练中,损失突增仍是顽固难题。我们发现,实际中此类突增通常由数据离群点、硬件或瞬时计算故障、数值精度问题及超参数设置等异质因素共同引发。无论根源为何,这些因素均表现为优化器更新不稳定,异常梯度污染一阶与二阶矩状态。本文提出一种以梯度为中心的系统性解决方案:AdaGC,一种自适应的逐张量梯度裁剪机制,通过将当前梯度范数与历史裁剪值的张量级指数移动平均相比进行约束,有效缓解污染。AdaGC与优化器无关,内存开销极小,相较于GlobalGC在混合并行分布式训练中显著降低通信成本。在Llama-2 7B、Mixtral 8x1B和ERNIE 10B-A1.4B上的实验表明,AdaGC能稳健消除训练不稳定性,使所有模型的突增评分归零,并分别提升下游准确率1.32%、1.27%和2.48%。此外,其可无缝集成至Muon和Lion等优化器,持续获得更高平均准确率与零突增表现。代码已开源于https://github.com/PaddlePaddle/PaddleFleet(见Research/AdaGC)。
原文摘要 · Abstract (English)
Loss spikes remain a persistent obstacle in large-scale language model pretraining. While previous research has attempted to identify the root cause of loss spikes by investigating individual factors, we observe that, in practice, such spikes are typically triggered by the confluence of heterogeneous factors. Empirically, loss spikes may arise from a combination of data outliers, hardware or transient computational faults, numerical precision issues, and hyperparameter settings. Regardless of the underlying cause, these spikes manifest as unstable optimizer updates, as abnormal gradients contaminate both first- and second-moment states. In this paper, we propose a principled gradient-centric remedy: AdaGC, an adaptive per-tensor gradient clipping scheme that mitigates such contamination by bounding gradient norms relative to a tensor-wise exponential moving average of their historical clipped values. AdaGC is optimizer-agnostic, introduces negligible memory overhead, and reduces communication costs compared to GlobalGC, particularly in hybrid-parallel distributed training. Experiments on Llama-2 7B, Mixtral 8x1B, and ERNIE 10B-A1.4B demonstrate that AdaGC robustly eliminates training instabilities, consistently reducing spike scores to zero for all models and improving downstream accuracy over GlobalGC by 1.32%, 1.27%, and 2.48%, respectively. Furthermore, AdaGC seamlessly integrates with optimizers such as Muon and Lion, consistently yielding higher average accuracy and zero spike scores. The code is available at https://github.com/PaddlePaddle/PaddleFleet (see Research/AdaGC).
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。