potentialpaper

DualKV: Shared-Prompt Flash Attention for Efficient RL Training with Large Rollouts and Long Contexts

Keep the title, authors and abstract in paper.json

potentialpaper · 2026-11-23 20:40 UTC · 553e52267b59 ·

.potentialpaper/metadata.json modified

+++ b/.potentialpaper/metadata.json
@@ -1,25 +1,5 @@
{
- "layout": 5,
- "identifiers": [
- {
- "scheme": "openreview",
- "value": "viyAwqIA4H"
- }
- ],
- "title": "DualKV: Shared-Prompt Flash Attention for Efficient RL Training with Large Rollouts and Long Contexts",
- "authors": [
- "Jiading Gai",
- "Shuai Zhang",
- "Xiang song",
- "Bernie Wang",
- "George Karypis"
- ],
- "abstract": "Modern RL post-training methods such as GRPO and DAPO train on $N$ response sequences of $R$ tokens sampled from a shared prompt of $P$ tokens, but standard FlashAttention replicates all $P$ prompt tokens $N$ times across both forward and backward passes — duplicating compute and memory on identical hidden states. In large-rollout, long-context RL training ($N{\\geq}16$, $P{\\geq}8\\text{K}$), this redundancy dominates the policy update cost. We observe that in decoder-only models, causal masking makes prompt representations invariant across sequences at every layer, so all per-token operations (norms, projections, MLP) and attention can process the prompt once — a property not yet exploited at the kernel level for RL training. We propose DualKV, the first FlashAttention kernel variant that eliminates shared-prompt replication during RL training, via (1) fused CUDA forward and backward kernels that iterate over two disjoint KV regions — shared context and per-sequence response — in a single kernel launch, and (2) a data-pipeline redesign in veRL that repacks $N(P{+}R)$ tokens into $P{+}NR$ tokens per micro-batch, extending the token reduction from attention to the entire model by a factor $\\rho = N(P{+}R)/(P{+}NR)$. DualKV is mathematically equivalent to standard attention and introduces no approximation. On Qwen3-8B GRPO training with 8$\\times$H100 GPUs ($N{=}32$, 8K-context), DualKV achieves $1.63$–$2.09\\times$ policy-update speedup, enables $2\\times$ larger micro-batches, and raises MFU from $36\\%$ to $76\\%$. Similar gains hold for DAPO ($2.47\\times$ speedup, $77\\%$ MFU). At 30B MoE scale on 16$\\times$H100, DualKV achieves $3.82\\times$ policy-update and $3.38\\times$ end-to-end step speedup over FlashAttention (which requires 4-way Ulysses sequence parallelism to avoid OOM). DualKV also extends to hybrid sliding/global attention with head dimension 512 (which FA2 does not support) and integrates with Ulysses sequence parallelism, demonstrated on Gemma-4-31B GRPO at 64K context.",
- "year": 2026,
- "venue": "NeurIPS 2026",
- "source": "openreview",
- "license": {
- "metadata": "CC0-1.0",
- "abstract": "CC0-1.0"
- }
+ "layout": 6,
+ "kind": "paper",
+ "key": "062dab9e-9c7f-4dbe-94a1-2d31bf75c9d0"
}

paper.json added

+++ b/paper.json
@@ -0,0 +1,15 @@
+{
+ "title": "DualKV: Shared-Prompt Flash Attention for Efficient RL Training with Large Rollouts and Long Contexts",
+ "authors": [
+ "Jiading Gai",
+ "Shuai Zhang",
+ "Xiang song",
+ "Bernie Wang",
+ "George Karypis"
+ ],
+ "abstract": "Modern RL post-training methods such as GRPO and DAPO train on $N$ response sequences of $R$ tokens sampled from a shared prompt of $P$ tokens, but standard FlashAttention replicates all $P$ prompt tokens $N$ times across both forward and backward passes — duplicating compute and memory on identical hidden states. In large-rollout, long-context RL training ($N{\\geq}16$, $P{\\geq}8\\text{K}$), this redundancy dominates the policy update cost. We observe that in decoder-only models, causal masking makes prompt representations invariant across sequences at every layer, so all per-token operations (norms, projections, MLP) and attention can process the prompt once — a property not yet exploited at the kernel level for RL training. We propose DualKV, the first FlashAttention kernel variant that eliminates shared-prompt replication during RL training, via (1) fused CUDA forward and backward kernels that iterate over two disjoint KV regions — shared context and per-sequence response — in a single kernel launch, and (2) a data-pipeline redesign in veRL that repacks $N(P{+}R)$ tokens into $P{+}NR$ tokens per micro-batch, extending the token reduction from attention to the entire model by a factor $\\rho = N(P{+}R)/(P{+}NR)$. DualKV is mathematically equivalent to standard attention and introduces no approximation. On Qwen3-8B GRPO training with 8$\\times$H100 GPUs ($N{=}32$, 8K-context), DualKV achieves $1.63$–$2.09\\times$ policy-update speedup, enables $2\\times$ larger micro-batches, and raises MFU from $36\\%$ to $76\\%$. Similar gains hold for DAPO ($2.47\\times$ speedup, $77\\%$ MFU). At 30B MoE scale on 16$\\times$H100, DualKV achieves $3.82\\times$ policy-update and $3.38\\times$ end-to-end step speedup over FlashAttention (which requires 4-way Ulysses sequence parallelism to avoid OOM). DualKV also extends to hybrid sliding/global attention with head dimension 512 (which FA2 does not support) and integrates with Ulysses sequence parallelism, demonstrated on Gemma-4-31B GRPO at 64K context.",
+ "license": {
+ "metadata": "CC0-1.0",
+ "abstract": "CC0-1.0"
+ }
+}