使用MXFP4训练大语言模型
Training LLMs with MXFP4
AI总结:
本文提出首个近似无损的MXFP4低精度训练方案,通过随机舍入与随机Hadamard变换控制梯度方差,在6.7B参数GPT模型上实现比FP8快1.3倍、比BF16快1.7倍的训练加速。
摘要:
诸如MXFP4这样的低精度(LP)数据类型可以加速矩阵乘法(GEMM)并降低训练成本。然而,在训练过程中直接使用MXFP4替代BF16会显著降低模型质量。在这项工作中,我们提出了首个近似无损的训练方案,该方案使用MXFP4 GEMM,在支持的硬件上比FP8快2倍。我们的关键见解是利用随机舍入(SR)计算无偏梯度估计,从而实现更准确的模型更新。然而,直接将SR应用于MXFP4可能会因块级离群值而产生高方差,损害收敛性。为克服这一问题,我们使用随机Hadamard变换从理论上限制SR的方差。我们训练了参数量高达6.7B的GPT模型,发现我们的方法相比混合精度BF16训练仅引起极小的性能下降。我们的方案在MXFP4中计算了超过1/2的训练FLOPs,在反向传播期间估计比FP8加速超过1.3倍,比BF16加速超过1.7倍。
英文摘要:
Low precision (LP) datatypes such as MXFP4 can accelerate matrix multiplications (GEMMs) and reduce training costs. However, directly using MXFP4 instead of BF16 during training significantly degrades model quality. In this work, we present the first near-lossless training recipe that uses MXFP4 GEMMs, which are $2\times$ faster than FP8 on supported hardware. Our key insight is to compute unbiased gradient estimates with stochastic rounding (SR), resulting in more accurate model updates. However, directly applying SR to MXFP4 can result in high variance from block-level outliers, harming convergence. To overcome this, we use the random Hadamard tranform to theoretically bound the variance of SR. We train GPT models up to 6.7B parameters and find that our method induces minimal degradation over mixed-precision BF16 training. Our recipe computes $>1/2$ the training FLOPs in MXFP4, enabling an estimated speedup of $>1.3\times$ over FP8 and $>1.7\times$ over BF16 during backpropagation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。