bf16舍入操作会悄悄丢弃大部分RL策略更新:一种隐藏的训练-推理不匹配问题及一行无偏修复方案
bf16 Rounding Silently Discards Most RL Policy Updates: A Hidden Training-Inference Mismatch and an Unbiased One-Line Fix
AI总结:
该研究发现bf16舍入会丢弃大部分RL策略更新的训练-推理不匹配问题,提出一行无偏Fair Cast修复方案,在多模型任务上显著提升性能。
摘要:
语言模型的强化学习(RL)后训练中,优化器会保留fp32主权重,而通过就近舍入(round-to-nearest)生成bf16副本用于rollout。在常用学习率下,大多数每步更新小于bf16的半个间距,导致转换时被丢弃:在Qwen3-1.7B上,每步仅有0.4-0.5%的服务权重发生变化,生成训练数据的策略比优化器滞后50-150步。现有不匹配修正方法无法察觉该滞后,因为它们比较的是同一舍入操作下游的两个副本。我们提出Fair Cast:采用无偏舍入规则(随机舍入或误差反馈)导出主权重,并在服务副本上计算训练损失。该修改仅需在导出调用处添加一行代码,无额外超参数,1.7B参数的每次导出耗时22-38ms。在Qwen3-0.6B至4B的25组匹配种子对(使用AdamW和Muon优化器)上,Fair Cast在18组中领先,6组持平,1组落后,平均增益6.1个百分点;在斑马谜题任务上,其性能达0.57±0.16,而就近舍入方案仅为0.33±0.10。此外,该方法使保存的fp32检查点与服务模型一致,还揭示了就近舍入作为正则化器的隐式滞后,可在任务需要时显式恢复。
英文摘要:
Reinforcement learning (RL) post-training of language models keeps fp32 master weights in the optimizer and serves rollouts from a bf16 copy produced by round-to-nearest conversion. At the learning rates in common use, most per-step updates are smaller than half a bf16 spacing and the conversion discards them: on Qwen3-1.7B only 0.4-0.5% of served weights change per step, and the policy that generates the training data lags the optimizer by 50-150 steps. Existing mismatch corrections cannot see this lag because they compare two copies downstream of the same rounding. We propose Fair Cast: export the master with an unbiased rounding rule (stochastic rounding or error feedback) and compute the training loss on the served copy. The change is one line at the export call, adds no hyperparameters and costs 22-38 ms per export of 1.7B parameters. Across 25 matched seed-pairs on Qwen3-0.6B to 4B with AdamW and Muon, Fair Cast is ahead on 18, tied on 6 and behind on 1, with a mean gain of 6.1 points; on zebra puzzles it reaches 0.57 +/- 0.16 over four runs where round-to-nearest collapses to 0.33 +/- 0.10. It also makes the saved fp32 checkpoint agree with the served model, and it exposes the implicit lag of round-to-nearest as a regularizer that can be restored explicitly when a task needs it.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。