正确实现多Token预测
研究论文 · 2026/10/30
多令牌预测(MTP)是语言模型预训练中的常见技术,可提升下游性能并加速推理。本文指出标准MTP训练存在缺陷:MTP交叉熵梯度可分解为KL自蒸馏项(提升推测解码)和低信噪比的残差项,后者随规模增大而干扰学习。作者提出KL梯度恢复技巧,通过直通梯度路由组合交叉熵梯度来精确恢复KL散度梯度,无需词汇级logit矩阵,兼容标准融合交叉熵内核。基于此实现Soft-MTP,仅需一行代码修改,去除噪声残差,仅反向传播KL自蒸馏信号。Soft-MTP支持DeepSeek和Meta风格的MTP,不增加参数和开销。在167M到1.2B参数范围内,Soft-MTP在NTP困惑度、推测解码速度、零样本准确率上均优于标准MTP,并在689M后降低MTP困惑度,1.2B微调后数学和代码推理更强。Soft-MTP在多数指标上匹配或超过直接KL最小化,堪称MTP优化的免费午餐。
该研究揭示了MTP训练中的梯度缺陷,并提出一种简单高效的解决方案,在不增加计算成本的情况下显著提升模型性能和推理速度,对语言模型预训练具有重要实践价值。
Multi-Token Prediction (MTP) is now a common ingredient in language-model pre-training, as it improves downstream performance and enables faster inference through speculative decoding. We identify a flaw in standard MTP training, in which a residual component of the MTP gradient interferes with both next-token and multi-token learning, increasingly so with scale. Specifically, the MTP cross-entropy gradient can be decomposed exactly into a KL self-distillation term that pulls each MTP head toward the model's own next-token prediction (NTP) distribution and improves speculative decoding, and a residual that has a low signal-to-noise ratio and buries the useful KL signal. We introduce the KL gradient-recovery trick: when two distributions share a linear output head, the gradient of their KL divergence can be recovered exactly by combining their cross-entropy gradients through straight-through gradient routing. Unlike minimizing the KL directly, this trick requires no vocabulary-sized logit matrices and is compatible with standard fused cross-entropy kernels. This enables Soft Multi-Token Prediction (Soft-MTP), a one-line code change to MTP that removes the noisy residual and backpropagates only the KL self-distillation signal by reusing the existing NTP and MTP cross-entropy computations. Soft-MTP supports both DeepSeek- and Meta-style MTP, adds no parameters, and incurs no measurable overhead. From 167M to 1.2B parameters, Soft-MTP improves over standard MTP with lower NTP perplexity, faster speculative decoding and higher zero-shot accuracy at every scale, lower MTP perplexity from 689M onward, and stronger math and code reasoning after fine-tuning at 1.2B. Soft-MTP also matches, if not exceeds, direct KL divergence minimization on most metrics. Soft-MTP is, in effect, a free lunch for MTP optimization. Our code can be found at https://github.com/JaydenTeoh/Soft-MTP.