arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.01143cs.DC
收藏

面向LLM强化学习训练的调度级共享前缀复用

PrefixFlow: Training-Time KV Caching for Schedule-Level Prefix Reuse in LLM RL Training

The Hong Kong University of Science and Technology(香港科技大学);Tencent(腾讯);Shanghai University of Finance and Economics(上海财经大学);The University of Hong Kong(香港大学)

Pengbo Li, Feiyuan Zhang, Guangming Sheng, Guangxin He, Di Chai, Ziniu Li, Taiqiang Wu, Han Tian, Wenyu Mao, Binhang Yuan, Kai Chen

AI总结:

针对GRPO/PPO式LLM后训练中多轨迹共享前缀导致重复计算的问题,提出调度级复用机制,通过解耦前缀与后缀计算实现最高4.395倍加速和59.1%的峰值HBM降低。

摘要:

GRPO和PPO风格的LLM后训练通常从同一提示中采样多个轨迹,然后对生成的组进行训练。在长上下文强化学习工作负载中,这个共享的提示侧前缀可能包含检索到的段落、视觉标记、工具模式、系统指令或任务上下文,而完整的展开组仍然太大,无法打包到一个训练微批次中。因此,标准的密集训练器会对每个轨迹重复计算相同的前向和后向前缀。我们提出了一种调度级复用机制,将前缀和后缀计算解耦。该调度将前缀前向计算一次,执行后缀作为普通微批次,同时读取前缀K/V并累积前缀侧gK/gV,然后在累积的梯度缓存上运行一次前缀后向。这个重新排序的调度在实数运算上等同于基线训练,并在有限精度容差内数值对齐。由于在后缀计算期间只有K/V和gK/gV是活跃的,该方法卸载了休眠的前缀激活,在执行级别与TP/EP/CP/PP和DP风格放置集成,并通过逻辑前缀令牌计数保留了基于辅助损失的MoE路由器语义。在密集Llama3-8B、Qwen3-8B和MoE Qwen3-MoE-30B-A3B配置上,该调度在TP/CP/PP/EP组合上匹配优化器更新,在100步真实RL轨迹重放上对齐,随着前缀比率和展开组大小增长达到最高4.395倍加速(保守编译对比下为2.930倍),并将Phase-B峰值HBM降低高达59.1%,将Llama3-8B容量边界从17,920个总令牌扩展到29,696个。

英文摘要:

In reinforcement learning (RL) post-training, one prompt fans out into $N$ trajectories, yet standard trainers replay the shared prefix's forward and backward pass $N$ times; in long-context retrieval-augmented generation (RAG) and multimodal workloads, this repetition dominates training compute. Existing designs reuse the prefix within one computation graph (a packed sequence, fused kernel, or tree traversal); under the trainer's memory limits and parallelism, their compute savings do not reliably become shorter steps. We present PrefixFlow, which takes the prefix out of that graph and into the training schedule through a training-time KV cache: Phase A runs one prefix forward and caches its keys and values ($K/V$); Phase B trains suffixes as ordinary microbatches that read only $K/V$ and write back only their gradients ($gK/gV$); Phase C runs one delayed prefix backward on the accumulated $gK/gV$. Memory and parallelism then become manageable: dormant prefix activations are offloaded during Phase B to free high-bandwidth memory (HBM) for suffixes, and context, pipeline, and data parallelism each schedule the phases through a local rule while tensor and expert parallelism need no change, so saved compute becomes shorter steps under any microbatch split. On dense models, and on mixture-of-experts (MoE) models under Rollout Routing Replay, PrefixFlow matches full-sequence training within bfloat16 (BF16) tolerance. Against an identically configured baseline, it speeds up end-to-end verl RL training on a long-prefix RAG workload by $1.90\times$ ($6.1\times$ on the actor update). In controlled sweeps, actor-side speedup grows with prefix ratio and group size, reaching $4.4\times$ at an 83% prefix ratio, while suffix-dominated splits gain little; offloading dormant prefix activations lowers Phase-B peak HBM by up to 59% and extends trainable sequences by $1.66\times$.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑