[论文解读] The Stability-Efficiency Dilemma: Investigating Sequence Length Warmup for Training GPT Models
本文提出序列长度预热(Sequence Length Warmup, SLW),一种通过在预训练过程中逐步增加序列长度来提升GPT类模型训练稳定性和效率的方法。SLW使训练在高达8倍更大的批量大小和40倍更大的学习率下保持稳定,将实际运行时间减少3.7倍,数据使用量减少10倍,同时在GPT-3 125M模型实验中保留99%的零样本准确率。
Recent works have demonstrated great success in pre-training large-scale autoregressive language models on massive GPUs. To reduce the wall-clock training time, a common practice is to increase the batch size and learning rate. However, such practice is often brittle and leads to a so-called stability-efficiency dilemma: increasing the batch sizes and learning rates leads to better training efficiency but can also result in training instability, leading to poor generalization accuracy or failed runs. To better understand this phenomenon, we conduct an in-depth analysis on large-scale pre-training experiments replicating the GPT-2 model. We find that there is a strong correlation between training instability and extreme values of gradient variance, and that samples with long sequence lengths contribute to these extreme gradient variance values, especially at the beginning of the training, indicating that long sequence length can be a main source of training instability. Based on the analysis, we present a Sequence Length Warmup method that aims to solve the training stability-efficiency dilemma. Experiments replicating GPT-2 models show that our approach enables stable training with 8x larger batch size and 4x larger learning rate, whereas the baseline approach struggles with training instability. To achieve the same or better zero-shot evaluation results, our method reduces the required number of training tokens and wall clock time by up to 2.2x and 3.7x, respectively. Experiments replicating GPT-3 model (125M) show that our approach enables stable training with 8x larger batch size and 40x larger learning rate, and retains 99% of the zero-shot accuracy on 11 tasks using 10x less data and 17x less time compared to the original GPT-3 training recipe, while the baseline diverges under the same settings and only retain 95% of accuracy under lower learning rate.
研究动机与目标
- 解决大规模GPT预训练中的稳定性-效率困境,即增加批量大小和学习率可提升效率,但会导致训练不稳定。
- 探究训练不稳定的根源,特别是早期训练中梯度方差异常值的作用。
- 探究序列长度是否影响训练稳定性,以及类似课程的训练调度是否能改善收敛性。
- 开发一种轻量级、可调参的方法,使模型在不需大规模重新训练的前提下,稳定使用激进的超参数。
- 在GPT-2和GPT-3模型复现中展示数据和时间效率的提升,证明其在大规模模型训练中的实际优势。
提出的方法
- 提出序列长度预热(SLW),一种训练调度方法,从较短序列(如128个token)开始,经过预定步数逐步增加至目标长度(如2048个token)。
- 引入一个预热阶段,先在较短序列上训练模型,以减少模型权重随机初始化时早期训练的梯度方差异常值。
- 采用线性或分段式调度,在固定训练步数内逐步增加序列长度,避免突然跳至长序列。
- 将该方法应用于GPT-2(117M和1.5B)和GPT-3(125M)模型,且仅需极少的超参数调优。
- 将SLW与标准训练方案结合,包括学习率和批量大小的缩放,以评估稳定性和效率之间的权衡。
- 通过梯度方差分析验证SLW可降低极端梯度方差值,尤其是在早期训练阶段,从而解释其对稳定性的提升作用。
实验结果
研究问题
- RQ1在GPT类模型的早期训练中,序列长度与训练不稳定性之间存在何种关系?
- RQ2梯度方差异常值与训练发散之间的相关性如何?能否通过调整训练调度来缓解?
- RQ3是否可以通过类似课程的方法——从较短序列开始——来提升训练稳定性,同时不牺牲收敛速度?
- RQ4SLW在多大程度上能支持更大的批量大小和学习率,同时保持或提升模型性能?
- RQ5SLW在大规模预训练中如何影响数据和时间效率,特别是与基线方案相比?
主要发现
- 训练不稳定性与梯度方差的极端值密切相关,尤其是在使用长序列进行早期训练时。
- 长序列长度是梯度方差异常值的主要来源,当批量大小和学习率增加时,会导致训练发散。
- SLW使GPT-2 1.5B模型在8倍更大的批量大小和4倍更大的学习率下实现稳定训练,将实际运行时间减少3.7倍,训练token数减少2.2倍。
- 在GPT-3 125M模型上,SLW使学习率提升40倍仍能保持稳定训练,实现10倍数据减少和17倍时间减少,同时保留99%的原始零样本准确率。
- 基线方法在40倍学习率下发散,而在30倍学习率下仅保留95%准确率;而SLW在相同激进设置下仍保持99%准确率。
- 在1.3B GPT-3模型实验中,SLW在相同3000亿token预算下,将平均零样本准确率从41.6提升至41.9,少样本准确率从44.8提升至45.3,证明了其数据效率的提升。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。