DualKV: Shared-Prompt Flash Attention for Efficient RL Training with Large Rollouts and Long Contexts
Jiading Gai, Shuai Zhang, Xiang song, Bernie Wang, George Karypis
NeurIPS 2026
TL;DR. We propose DualKV, a shared-prompt flash attention kernel that removes redundant prompt compute across all policy update phases in sampling-based RL training (GRPO, DAPO), delivering 1.6–3.8× speedup and 2× larger micro-batches over FlashAttention.
Abstract. Modern RL post-training methods such as GRPO and DAPO train on response sequences of tokens sampled from a shared prompt of tokens, but standard FlashAttention replicates all prompt tokens times across both forward and backward passes — duplicating compute and memory on identical hidden states. In large-rollout, long-context RL training (, ), 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 tokens into tokens per micro-batch, extending the token reduction from attention to the entire model by a factor . DualKV is mathematically equivalent to standard attention and introduces no approximation. On Qwen3-8B GRPO training with 8$\times$H100 GPUs (, 8K-context), DualKV achieves – policy-update speedup, enables larger micro-batches, and raises MFU from to . Similar gains hold for DAPO ( speedup, MFU). At 30B MoE scale on 16$\times$H100, DualKV achieves policy-update and 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.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 4 reviews · OpenReview
Updated 25 Nov 2026, 03:49 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
DualKV proposes a new kernel designed to improve latency and memory efficiency when computing attention during RL rollouts with multiple responses sharing the same prompt. It does but addressing the inherent property of the prompt being the same and builds on top of the existing FlashAttention implementation to deliver practical solution.
The reviewers unanimously voice their support for the paper, praising it for clear problem statement, solid execution (both on the implementation side, as well as experimental rigour). Some minor complains relate to the fact the paper does not provide novel insights (reviewer dnLK), applicability being limited to short prompts (reviewers SFtP and TFxj), and similar downsides. However, all of these appear to be more of natural limitations arising from the problem statement and the scope of the paper, and do not seem to undermine the contributions proposed in the paper in their intended context. In that regard, the reviewers are mostly in agreement that the contributions of the paper are practical and timely. Notably, reviewers dnLK and SftP mention clear and strong performance gains, while reviewers TFxj and VC2r mention relevance for methods such as GRPO/DAPO and the fact the method is readily available to be used via veRL (reviewer TFxj).
Given all the above, I think the submitted paper has clear potential to have real impact and thus lean towards acceptance, as it stands now. I would still want the authors to comment on the questions raised but the reviewers, though.
Final justification
Both myself and the reviewers are satisfied with the replies provided by the authors. The paper is solid and of potential practical importance, thus I'd recommend its acceptance.
However, I'd urge the authors to correct the citation for veRL: it currently has a number of issues (to the point it was flagged as hallucinations).
Read meta-review
Meta-review
DualKV proposes a new kernel designed to improve latency and memory efficiency when computing attention during RL rollouts with multiple responses sharing the same prompt. It does but addressing the inherent property of the prompt being the same and builds on top of the existing FlashAttention implementation to deliver practical solution.
The reviewers unanimously voice their support for the paper, praising it for clear problem statement, solid execution (both on the implementation side, as well as experimental rigour). Some minor complains relate to the fact the paper does not provide novel insights (reviewer dnLK), applicability being limited to short prompts (reviewers SFtP and TFxj), and similar downsides. However, all of these appear to be more of natural limitations arising from the problem statement and the scope of the paper, and do not seem to undermine the contributions proposed in the paper in their intended context. In that regard, the reviewers are mostly in agreement that the contributions of the paper are practical and timely. Notably, reviewers dnLK and SftP mention clear and strong performance gains, while reviewers TFxj and VC2r mention relevance for methods such as GRPO/DAPO and the fact the method is readily available to be used via veRL (reviewer TFxj).
Given all the above, I think the submitted paper has clear potential to have real impact and thus lean towards acceptance, as it stands now. I would still want the authors to comment on the questions raised but the reviewers, though.
Final justification
Both myself and the reviewers are satisfied with the replies provided by the authors. The paper is solid and of potential practical importance, thus I'd recommend its acceptance.
However, I'd urge the authors to correct the citation for veRL: it currently has a number of issues (to the point it was flagged as hallucinations).
1 comment
- Rating
- 5/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 4/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes DualKV, a system optimization that eliminates redundant prompt KV computation in RL training where multiple responses are sampled from the same prompt. DualKV develops a custom CUDA kernel extending FlashAttention2 that performs two-phase tile iteration over disjoint KV regions, and resolves the resulting N-way concurrent gradient write via fp32 atomic accumulation. The method is mathematically exact and demonstrates up to 3.38x end-to-end training speedup on 30B MoE model.
Strengths and weaknesses
Strengths:
- Important and timely topic. RL training efficiency is critical as GRPO/DAPO become standard in LLM post-training.
- Mathematical exactness. DualKV is provably bit-wise equivalent to the FA2 baseline.
- Solid evaluation. Both kernel-level and end-to-end results across multiple model sizes.
Weaknesses:
- Tight coupling to FA2. The kernel is implemented as an FA2 extension, but FA3 (targeting Hopper/H100) is increasingly the standard for large-scale training.
- Data pipeline constraints. DualKV requires all N same-prompt responses to be co-located on the same GPU within the same micro-batch, which necessitates disabling load-balancing and intra-epoch shuffle.
Questions
- Could the authors discuss the feasibility of extending DualKV to FA3?
Limitations
YES
Final justification
The author's rebuttal addressed my main concerns. I think the paper is solid and meets publication standards.
Formatting concerns
NO
2 comments
Rebuttal
We sincerely thank the reviewer for the thoughtful and constructive assessment and for recognizing the importance and timeliness of this problem, DualKV's mathematical exactness, and the breadth of our evaluation.
W1/Q1. FA2 coupling and feasibility of an FA3 extension
During the rebuttal period, we implemented and validated the kernel-level DualKV-FA3 forward/backward path required for model training. The original Table 1 in the paper submission was measured on A100, where FA3 is unavailable. We therefore reran FA2, DualKV-FA2, FA3, and DualKV-FA3 on the same H100 SXM 80GB. For focus, the table below reports the directly relevant FA3 versus DualKV-FA3 comparison; we will include the complete four-method H100 panel in the next revision. Across the Table 1 workload configurations, DualKV-FA3 provides combined forward/backward speedup and 36--81% lower peak memory than FA3.
| N | P | FA3 Fwd+Bwd (ms) | DualKV-FA3 Fwd+Bwd (ms) | Speedup | FA3 peak (MB) | DualKV-FA3 peak (MB) | Mem. reduction |
|---|---|---|---|---|---|---|---|
| 28 | 4,096 | 55.60 | 45.83 | 10,818 | 6,891 | 36% | |
| 28 | 16,384 | 447.80 | 128.35 | 32,449 | 9,119 | 72% | |
| 16 | 32,768 | 891.48 | 168.30 | 35,021 | 7,993 | 77% | |
| 28 | 32,768 | 1,558.78 | 259.70 | 61,290 | 13,217 | 78% | |
| 16 | 65,536 | 3,304.50 | 422.85 | 67,982 | 13,117 | 81% |
Measurement protocol: All methods ran on a single H100 SXM 80GB GPU using FP16, , and Qwen3-8B GQA (32 query heads, 8 KV heads, head dimension 128). The table reports arithmetic means across four complete benchmark repetitions; within each repetition, latency is the median of 10 timed iterations after five warmups.
These results demonstrate that DualKV’s single-copy shared-prompt representation and exact shared-gradient accumulation generalize from FA2 to FA3.
The key DualKV-FA3 implementation and validation details are:
- Exact forward. DualKV-FA3 preserves one physical prompt and composes the shared-context and decoded-suffix FA3 computations exactly.
- Race-free backward. FA3 requires a different schedule from FA2 because its TMA epilogue cannot safely alias the batch dimension. Each response accumulates into a private FP32 context-gradient slice; a dedicated FP32 kernel reduces these slices before FA3's standard postprocessor performs one final output-dtype conversion. This avoids concurrent TMA writes to aliased storage and low-precision intermediate accumulation.
- Validation. At the H100 benchmark configurations, standard FA3 and DualKV-FA3 pass output-parity checks on identical inputs. We also verified DualKV-FA3's output, LSE, and all gradients against a straightforward FP32 PyTorch attention implementation using standard autograd. CUDA Compute Sanitizer reported no memory errors.
W2. Data-pipeline co-location, load balancing, and shuffling
We agree that this is a limitation of the current integration. Importantly, training prompts are still randomly shuffled before rollout. The restriction begins only after each prompt is expanded into responses: those responses must remain contiguous and on the same data-parallel rank. All responses need not fit in one microbatch. When exceeds the microbatch size, the implementation processes consecutive same-prompt chunks, sharing the prompt within each chunk and recomputing it across chunks. The current integration skips VeRL's existing per-sequence load balancer to preserve this grouping.
The current DualKV execution requires same-prompt responses to remain co-located so they can reuse one prompt representation. Under standard FA2, VeRL balances the expanded sequences independently using the workload estimate , where . This may scatter same-prompt responses across DP ranks. DualKV packs them as , requiring the complete prompt group to remain one scheduling unit. As future work, we plan to implement group-aware load balancing over these scheduling units. To evaluate feasibility, we simulated a greedy group-aware scheduler using the compact token count as its load proxy. In each of 500 deterministic batches, it sorts 64 stored multi-response groups by this proxy and assigns each group to the least-loaded of 8 workers:
| Dataset | Responses/group (P50/P90/P99; ) | Load excess (P50/P90/P99) |
|---|---|---|
| OpenR1-Math verified traces | 2 / 2 / 4 | 0.66% / 1.49% / 2.23% |
| UltraFeedback preference pairs | 2 / 2 / 2 | 0.66% / 1.29% / 1.96% |
| SWE-Gym agent trajectories | 2 / 10 / 10 | 0.41% / 1.59% / 27.90% |
Worker-load excess is , where is the sum of over all groups assigned to worker , and is the mean load across the eight workers; is perfect balance.
In summary, DualKV preserves prompt-level shuffling and only restricts post-rollout response-level reordering and redistribution; our reported DualKV end-to-end results already include this restriction. To further mitigate potential data-parallel imbalance, we propose group-aware placement of complete prompt groups. Our simulation shows P90 compact-layout token-load excess below 1.6% across all three datasets, while the SWE-Gym P99 tail motivates length bucketing or adaptive placement.
We greatly appreciate the reviewer's thoughtful questions and the opportunity to clarify these points. We will add the H100 FA3 results and clarify the group-level scheduling constraints in the revision. After completing end-to-end validation, we will open-source the DualKV-FA3 kernels in the same GitHub repository.
Thank the authors for the detailed rebuttal. This rebuttal addresses my main concerns. I look forward to the open-source release of the FA3 version. I have increased my score to 5.
- Rating
- 5/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 2/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper presents DualKV, a kernel that builds atop FlashAttention and aims to optimize long-prompt RL training, reducing the latency and memory consumption. DualKV processes the prompt only once via a fused forward/backward kernel that iterates over two disjoint KV regions (shared prompt and per-sequence response). It is mathematically equivalent to vanilla attention and empirically preserves most of the training accuracy curve.
Strengths and weaknesses
Thank you for submitting your paper to NeurIPS 2026! Overall, I enjoyed reading this paper, and I'm inclined toward accepting the paper. Although the conceptual techniques are not new, and this work serves a somewhat niche workload (i.e., high prompt-to-response ratio in post-training), I think the authors executed it well, and the paper was technical yet easy to understand. If the authors could address my questions, I'd be willing to support this paper more strongly.
Strength
- Quality: Strong latency and memory saving results
- Clarity: The main body of the paper was easy to understand, and the appendix contained detailed descriptions
Weaknesses
- Significance: Performance diminishes if the prompt length is short
Comment on the "originality" spectrum: Not really a weakness per se, but the core techniques in this work can all be traced to existing literature. Still, I gave a score of 3, because I appreciate the clever combination of existing ideas to solve a new problem.
Questions
- Questions regarding prompt sequence length. What is the prompt length distribution of popular, real datasets for post-training across domains (e.g., reasoning, agentic, etc.)? I like the token reduction ratio formulation ρ = N(P + R)/(P + NR), and it begs the question of how much utility DualKV will have across different post-training workloads. I have no doubt that it will lead to significant savings in agentic post-training workloads where the prompt includes long trajectories and detailed context (e.g., code snippets). I also appreciate the authors for transparently conducting a short-prompt validation experiment. That said, the main evaluation workload, LongReason, is somewhat of a niche workload. In section E.1, the authors were able to change P=1-3K. My two questions: (1) How did the authors expand the prompt? (2) What is in the prompt aside from a GSM8K question, which is typically under 100 tokens?
- Questions regarding baselines. In section 4.1 "Kernel-Level Speedup", why was FA3 not a baseline? I acknowledge the authors included FA3 in the end-to-end results, but given that the authors run experiments on H100, it seems like a relevant baseline that was omitted. One other minor question -- in a lot of experiments (e.g., Fig. 1&2), FA3 performs worse than FA2, which feels counterintuitive given that FA3 is specifically optimized for the Hopper architecture. Could the authors offer an explanation?
Minor feedback: Fig. 2 appears before Fig. 1.
Limitations
- Performance diminishes if the shareable segment of the prompt is not long
- I feel like there should be a kernel-level comparison with FA3, the state-of-the-art baseline.
- The accuracy preservation claim is somewhat shaky. E.g., Table 4 shows a ~3% val-acc gap (0.802 vs 0.774) in the MoE experiment. I get that there's an equivalence theorem -- could this be a result of the actual training run using both BF16 and FP32? I think a slightly more in-depth explanation is warranted here.
Final justification
I appreciate the authors for extensively answering my questions, and I'm recommending the paper for acceptance.
Formatting concerns
N/A
1 comment
Rebuttal
Thank you for the thoughtful and constructive review, and for recognizing the paper's strong latency and memory savings and technical clarity. We especially appreciate your question about prompt-length distributions across real post-training workloads; it motivated our six-dataset analysis and helped us substantially strengthen the paper's characterization of DualKV's practical scope.
W1/Q1. Short-prompt significance and utility across real workloads
Response. DualKV is broadly applicable whenever post-training processes multiple responses from the same prompt, while the magnitude of its savings varies predictably with the workload. Appendix C quantifies this opportunity through the token-reduction ratio . For fixed , increases with and approaches ; for fixed , it increases with prompt dominance and approaches . The lower-reduction boundary is also explicit: approaches only for response-dominated workloads () or when , where there is no cross-response redundancy to eliminate.
To ground this characterization in real workloads, we analyzed six publicly available datasets representative of reasoning, preference, code, and agentic workloads using Qwen3-8B tokenizer and chat template. We used the complete released splits of GSM8K (7,473 examples) and SWE-Gym (6,055 trajectories) and deterministic 10,000-source-row samples from each of the other four datasets. Every below is an actual stored reference solution, reasoning trace, preference completion, tested code solution, or full agent trajectory; we performed no inference and imputed no response lengths.
| Dataset and stored-response type | Median responses/prompt () | , P50/P90 | , P50/P90 | , P50 | , P50 |
|---|---|---|---|---|---|
| GSM8K — reference solutions | 1 | 79/112 | 117/201 | 1.55x | 1.61x |
| OpenThoughts-114K — teacher traces | 1 | 354/652 | 5,400/14,755 | 1.06x | 1.07x |
| Open-R1 Verifiable Coding Problems — Python solutions | 1 | 527/840 | 161/500 | 3.02x | 3.53x |
| OpenR1-Math-220K — verified reasoning traces | 2 | 87/160 | 4,652/11,157 | 1.02x | 1.02x |
| UltraFeedback Binarized — chosen/rejected pairs | 2 | 85/421 | 199/598 | 1.34x | 1.37x |
| SWE-Gym OpenHands — agent trajectories | 2 | 1,777/2,756 | 11,107/38,239 | 1.16x | 1.17x |
Here, is the median number of stored responses sharing the same tokenized prompt; the and columns evaluate grouped-RL scenarios rather than native dataset multiplicities. Across the six datasets, median token-volume reduction spans 1.02--3.53x. The contrast between long-response reasoning/agent workloads (1.02--1.17x) and the shorter-response code workload (3.02--3.53x) shows that absolute prompt length alone is insufficient: and govern the magnitude of savings. DualKV therefore applies broadly to same-prompt, multi-response workloads, with larger savings as prompt dominance or rollout multiplicity grows. In the next revision, we will add this table and the corresponding length distributions and clarify that measures physical token-volume reduction rather than guaranteed wall-clock speedup.
W2. Combination of existing techniques
Response. Thank you for recognizing the value of this combination. We agree that the high-level ingredients have precedents. DualKV's distinct contribution is the two-region training dataflow and specialized forward/backward kernels that preserve a single physical prompt end to end in the compact layout. Its response-parallel backward performs race-free FP32 accumulation of concurrent response contributions into shared scratch buffers, followed by one output-dtype conversion. Because this compact representation persists throughout the entire model, both attention and non-attention operations process the shared prompt once rather than times. We will clarify this positioning and expand the related-work discussion in the next revision.
As additional evidence of our design's generality, we implemented DualKV forward/backward support for Gemma-4's hybrid global/sliding-window attention and composed it with Ulysses sequence parallelism, enabling end-to-end GRPO on Gemma-4-31B through 64K context at SP=8 on one H200 node.
Q2-Q3. How was GSM8K expanded, and what content was added?
Response. Thank you for raising this; our description was too terse. The reported 1K–3K-token inputs are controlled prompt-length variants, not naturally long GSM8K questions. For each target, we retained the original question and prepended distinct, solved GSM8K examples until the tokenized prompt reached the requested length. To prevent leakage, we excluded candidates matching either the target task ID or its normalized question. The resulting prompt was shared by all responses, and FA2 and DualKV received identical inputs. In the next revision, we will clearly distinguish the original question from the added few-shot context.
Q4. Why was FA3 omitted from the Section 4.1 baseline?
Response. Thank you for highlighting this omission. The original Table 1 was measured on A100, which does not support FA3; therefore, standard FA3 could not be included in that panel. During the rebuttal period, we implemented and validated the kernel-level DualKV-FA3 forward/backward path required for model training. We then reran the Table 1 workloads on one H100 SXM 80GB using FA2, DualKV-FA2, FA3, and DualKV-FA3. For focus, the table below reports the complete four-kernel comparison. All entries are combined forward/backward latency in milliseconds (lower is better):
| FA2 | DualKV-FA2 | FA3 | DualKV-FA3 | ||
|---|---|---|---|---|---|
| 28 | 4,096 | 98.45 | 59.23 | 55.60 | 45.83 |
| 28 | 16,384 | 819.40 | 214.30 | 447.80 | 128.35 |
| 16 | 32,768 | 1,643.18 | 311.00 | 891.48 | 168.30 |
| 28 | 32,768 | 2,873.18 | 470.38 | 1,558.78 | 259.70 |
| 16 | 65,536 | OOM | 806.50 | 3,304.50 | 422.85 |
Each entry is the mean of four complete benchmark repetitions using FP16, , and the Qwen3-8B GQA topology. Where both fit, standard FA3 is 1.77–1.84× faster than FA2; DualKV-FA3 is 1.21–7.82× faster than FA3 and reduces peak memory by 36–81%. In the next revision, we will include the complete H100 latency-and-memory panel and clearly identify the original Table 1 results as A100 measurements.
Q5. Why does FA3 appear slower than FA2 end-to-end?
Response. Thank you for flagging this counterintuitive result. The FA3
slowdown is not systematic. In the GRPO phase breakdown (Figure 1), FA3 is
faster than FA2 in both forward-only phases: 124 versus 131 seconds for
old_log_prob and 123 versus 129 seconds for ref_log_prob. It is slower in
the policy update, which includes backpropagation (569 versus 518 seconds),
yielding total step times of 1,067 versus 1,017 seconds (Table 3). In DAPO,
FA3 is faster in both the policy update (543 versus 597 seconds) and the
overall step (919 versus 987 seconds), as shown in Table 11.
This FA2-versus-FA3 baseline difference occurs with DualKV disabled and is therefore orthogonal to DualKV's algorithm and correctness. The phase breakdown narrows the higher GRPO time to the full policy update, while source inspection points to FA3's packed-variable-length GQA backward path as one plausible contributor. However, the policy-update measurement covers the entire training update (checkpoint recomputation, FSDP communication, and optimizer work etc), and the results come from independent training trajectories. To pinpoint the cause, we are profiling FA2 and FA3 on the same training batch using CUDA events; this investigation is ongoing, and we will report its findings in the next revision.
L1. Table 4 validation-accuracy gap and mixed precision
Response. Thank you for identifying this discrepancy. Across all reported end-to-end experiments with stepwise accuracy or reward curves, we find no consistent DualKV disadvantage. The Table 4 gap is therefore an isolated single-run endpoint difference consistent with stochastic run-to-run variation, rather than a BF16/FP32 precision effect or systematic DualKV degradation.
FA2 and DualKV-FA2 use identical end-to-end data types: BF16 model tensors and gradient outputs, with FP32 accumulation internal to the attention kernels. DualKV's FP32 scratch buffer only performs the race-free summation of shared-prompt gradient contributions before the same BF16 writeback; it is not a different mixed-precision training regime. The equivalence theorem establishes the same mathematical computation. Controlled kernel tests confirm numerical agreement for outputs and gradients. Thus, the Table 4 gap is not caused by a BF16/FP32 precision mismatch.
Table 4 compares one DualKV/SP=1 run with one FA2/SP=4 run using independently sampled rollouts. Their per-step training curves track closely across all 29 steps, while the held-out difference is nine examples out of 318 (0.774 versus 0.802). This direction is not systematic: in the Qwen3-8B GRPO experiment, DualKV reaches 0.780 versus 0.777 for FA2, and both DualKV DAPO runs finish above FA2. The available evidence therefore shows no systematic DualKV accuracy degradation, although one run cannot determine the cause of this isolated endpoint difference. We will report both endpoints transparently.
M1. Figure ordering
Response. We will reorder the presentation so Figure 1 is introduced before Figure 2. Thanks a lot for pointing this out!
- Rating
- 5/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The authors propose a kernel for rollout phase of post-training phase.
It enables without duplication of tokens and compute sharing of prompts. The authors do a good job why a new kernel is needed for this purpose and what is unique about this setup. The results show significant improvement over baseline.
Strengths and weaknesses
Strengths:
-
Well written paper
-
Clear performance distinction on why a new kernel is needed.
-
Pretty good speedups over the baseline.
Weakness:
- This primarily is an implementation paper. There is not necessarily a novel insight.
Questions
“e observe that in decoder-only models, prompt hidden states are identical across all N sequences 50 at every layer: causal masking ensures each prompt token attends only to preceding prompt tokens, 51 never to the differing response tokens that follow, so the prompt representations are independent of 52 which response is generated.” -> How is this different from kernels in SGLang and now vLLM which use a shared prefix cache
“By packing the micro-batch with 58 a single prompt copy and decomposing attention into context self-attention (computed once) and 59 a fused DualKV kernel for decoded attention, DualKV eliminates redundant prompt computation 60 throughout the entire model — not just attention, but also norms, projections, and MLP layers 61 yielding both memory and compute savings without approximation” -> I am struggling with novelty, framework level microbatching prefix grouper provided and kernel design is present in prefix caching
Limitations
Yes.
Formatting concerns
None.
1 comment
Rebuttal
Thank you for the thoughtful review and for recognizing the paper's clarity, the motivation for a specialized CUDA kernel design, and its empirical gains. We especially appreciate the novelty question because it highlights a distinction that we should make more explicit.
Q1 — Difference from SGLang/vLLM. SGLang/RadixAttention and vLLM/PagedAttention reuse read-only prefix K/V during inference. By contrast, preserving the single-copy prompt during the policy update in sampling-based RL methods such as GRPO and DAPO requires an exact shared-prompt FlashAttention backward kernel, with every sampled response contributing to the same physical prompt buffers. SGLang/vLLM's prefix-caching kernels are inference-only: they provide no backward pass through the shared prompt and no mechanism to aggregate the cross-response required by policy updates.
Q2 — Difference from Prefix Grouper. Prefix Grouper avoids repeated prompt computation at the framework level. In its implementation, however, the prompt K/V is expanded for every sample immediately before standard FA2. Its compact representation therefore does not persist through the attention layer: FA2 still consumes the materialized K/V layout, and autograd later reduces the replicated prompt gradients.
As reported in Table 2 of our paper submission (reproduced below for convenience), our single-layer H100 forward+backward comparison using Prefix Grouper's released code gives:
| P | mb | FA2 (ms) | DualKV (ms) | PG (ms) | DK/FA2 | DK/PG | DK mem (GB) | PG mem (GB) |
|---|---|---|---|---|---|---|---|---|
| 5K | 32 | 597 | 180 | 626 | 13.7 | 69.8 | ||
| 8K | 16 | 549 | 128 | 465 | 9.9 | 50.7 | ||
| 16K | 8 | 553 | 125 | 435 | 9.0 | 45.9 | ||
| 32K | 4 | 810 | 246 | 514 | 12.5 | 43.0 | ||
| 65K | 4 | OOM | 654 | OOM | 22.7 | OOM | ||
| 131K | 8 | OOM | 2,097 | OOM | 44.5 | OOM |
This directly measures the consequence of losing physical sharing at the attention boundary: where both run, DualKV is -- faster and reduces peak memory by 71--80% relative to Prefix Grouper. At 65K and 131K prompts, both FA2 and Prefix Grouper OOM, while DualKV completes using only 22.7 GB and 44.5 GB, respectively.
W1 — Novel contribution. DualKV solves the kernel-level challenge of preserving a single physical prompt through exact attention forward and backward. It realizes this with one physical context buffer and packed response buffers in the layout. Its response-parallel backward performs race-free FP32 atomic accumulation of concurrent response contributions into shared scratch buffers, followed by one output-dtype conversion. Because this compact representation persists throughout the Transformer, RMSNorm, QKV/output projections, RoPE, and MLPs also process the shared prompt once rather than times. The key contribution is the two-region training dataflow and specialized forward/backward kernels that preserve a single-copy prompt end to end, without approximation, for sampling-based RL workloads such as GRPO and DAPO.
Additional evidence of generality. After paper submission, we further extended DualKV to Gemma-4 to demonstrate that its core design generalizes to modern hybrid architectures and composes with Ulysses sequence parallelism:
- Global attention at : new forward/backward kernel variants for Gemma-4's global layers.
- Kernel-native sliding-window attention at : causal windowing over the two-region layout for Gemma-4's local layers.
- Ulysses sequence-parallel composition: repacking before sequence slicing, standard all-to-alls around the per-head DualKV kernel, and exact reconstruction of the shared last-prompt states used for first-response-token logits.
We validated all three extensions together end to end on Gemma-4-31B using GRPO (, LongReason with thinking enabled, three epochs) on one H200 node (results below):
| Context | SP | Peak mem (GB) | old_log_prob (s) | ref_log_prob (s) | Policy update (s) |
|---|---|---|---|---|---|
| 16K | 1 | 96.8 | 140 | 140 | 549 |
| 16K | 4 | 77.0 | 157 | 178 | 638 |
| 32K | 4 | 79.8 | 315 | 319 | 1,242 |
| 64K | 8 | 78.9 | 782 | 791 | 3,073 |
Wall-clock values are per-step means; rollout generation is omitted. The SP=1 and SP=4 runs at 16K are otherwise identical. At 64K with SP=8, peak memory remains 78.9 GB. Numerical correctness was also verified: sliding-window forward and backward match windowed FA2 in kernel unit tests, first-token log-probabilities agree exactly with the SP=1 path () across , and held-out accuracy remains stable in every configuration.
Thank you again for these important questions. We will revise the introduction and related work to clarify that SGLang/vLLM cache read-only prefixes for inference, Prefix Grouper rematerializes full K/V before standard attention, and DualKV's two-region dataflow and specialized forward/backward kernels preserve a single-copy prompt throughout the training stack.
- Rating
- 5/6
- Confidence
- 2/5
- Quality
- 3/4
- Clarity
- 2/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper proposes DualKV, a method that deduplicates the prompt tokens and related hidden states to reduce the memory and compute cost of RLVR training. The main claim of the paper is that in RLVR settings with long prompts or a large number of rollouts, duplicated prompt tokens and associated hidden states cause excessive memory pressure and computational inefficiency. The paper proposes a kernel-level solution that reduces said memory pressure from , where is the number of rollouts, is the prompt length, and is the rollout length, to . The paper measures the speedup of the kernel relative to FlashAttention-2 as well as end-to-end memory and throughput improves of RLVR-based methods like GRPO and DAPO. Across all configurations, these custom kernels improve memory efficiency and throughput without sacrificing the accuracy of the update. Comparisons to prior baselines that also try to deduplicate the prompt tokens, specifically Prefix Grouper, are also favorable and show that in settings where Prefix Grouper OOMs, DualKV still sits comfortably within the device's memory. Scalability results are also shown for MoE training, demonstrating the method generalizes to larger models and multi-node training configurations.
Strengths and weaknesses
Strengths -
- Experimental Rigor - The effect of the kernels is tested first in isolation relative to FlashAttention-2 and Prefix Grouper. The impact on end-to-end training performance/efficiency is additionally measured making the kernel design more compelling. Plenty of ablations relating to model size, prompt length, and correctness are also provided demonstrating the method's robustness.
- Usability - Integration directly into packages like veRL makes the method directly usable in a contemporary training framework. The method has already been tested with RLVR training methods like GRPO/DAPO using veRL. This is a positive for reproducibility and general usability.
- Method Design - Elements like atomic writes and fp32 context contributions serve to prevent race conditions and performance degradation from bf16 rounding when using a shared context across all rollouts.
Weaknesses -
- Implementation Overhead - As it stands, the method requires kernel-level optimization and specifically builds on FlashAttention-2 for A100/H100. However, it is unclear whether or not these kernel optimizations are easily ported to other architectures. If similar kernels have to be written for every RLVR deployment configuration, this would add considerable implementation overhead and it is unclear whether or not the exact kernel details would generalize.
- Model Diversity - The method is tested on the Qwen3 class of models that all use GQAs. With many models adopting other attention variants (sliding attention, hybrid attention, etc.) it is again unclear whether or not these findings generalize to other model classes.
- Short Prompt Regime - GSM8K experiments show that in the short prompt regime, the improvements persist but are much more marginal. However, this regime still only uses rollouts of tokens. Many current RLVR training regimes use short prompt, long decoding horizon, such as OpenThoughts training. While GSM8K uses short prompts, it may not be the best representative or capture the effect of the method in the short prompt regime very broadly.
Questions
- Line 201 - The line mentions that fp16 is used to measure kernel-level speedup, but much of the rest of the paper uses bf16. Is there a reason this table uses fp16 instead?
- Tables 1 and 2 display similar results but change the regime slightly and add Prefix Grouper results. Is there a reason Prefix Grouper wasn't included in the Table 1 A100 results?
Limitations
Yes
Final justification
The authors provide additional valuable experiments in the rebuttal, demonstrating the method's robustness and effectiveness in a variety of settings.
Formatting concerns
N/A
2 comments
Rebuttal
Thank you for the thoughtful review and for recognizing the paper's experimental rigor, practical veRL integration, and race-free FP32 gradient design. Your questions about portability, model diversity, and short-prompt workloads identify important scope boundaries that we should make clearer.
W1. Implementation overhead and portability
Response. Since submission, we implemented and validated the kernel-level DualKV-FA3 forward/backward path on H100. We reran the Table 1 workloads using FA2, DualKV-FA2, FA3, and DualKV-FA3; all entries below are combined forward/backward latency in milliseconds:
| FA2 | DualKV-FA2 | FA3 | DualKV-FA3 | ||
|---|---|---|---|---|---|
| 28 | 4,096 | 98.45 | 59.23 | 55.60 | 45.83 |
| 28 | 16,384 | 819.40 | 214.30 | 447.80 | 128.35 |
| 16 | 32,768 | 1,643.18 | 311.00 | 891.48 | 168.30 |
| 28 | 32,768 | 2,873.18 | 470.38 | 1,558.78 | 259.70 |
| 16 | 65,536 | OOM | 806.50 | 3,304.50 | 422.85 |
These are four-run means on one H100 SXM 80GB using FP16 and . DualKV-FA3 achieves a -- combined forward/backward speedup and reduces peak memory by -- relative to FA3.
The port required backend-specific kernel work, but not a redesign of DualKV's execution abstraction. FA3's TMA epilogue cannot safely write concurrent response contributions into aliased context-gradient storage, so each response accumulates into a private FP32 slice; a dedicated FP32 kernel then reduces these slices before one output-dtype conversion. The two-region interface, logical masking, compact representation, exact shared-prompt gradient semantics, and surrounding model/veRL integration remain unchanged. Thus, support for a new attention backend is not zero engineering, but the backend-specific work is localized to the attention kernel. We will document the backend-independent invariants and integration points in the revision.
W2. Model and attention-pattern diversity
Response. After submission, we extended DualKV to Gemma-4-31B's hybrid 60-layer architecture and implemented three concrete capabilities:
- Global attention at : new forward/backward kernel variants for Gemma-4's 10 global-attention layers.
- Kernel-native sliding-window attention at : causal windowing over the two-region layout for its 50 local-attention layers.
- Ulysses sequence-parallel composition: repacking before sequence slicing, standard all-to-alls around the per-head DualKV kernel, and exact reconstruction of shared last-prompt states for first-response-token logits.
After verifying numerical correctness, we validated these extensions together in end-to-end GRPO on Gemma-4-31B (, LongReason with thinking enabled, three epochs) on one H200 node:
| Context | SP | Peak memory (GB) | old_log_prob (s) |
ref_log_prob (s) |
Policy update (s) |
|---|---|---|---|---|---|
| 16K | 1 | 96.8 | 140 | 140 | 549 |
| 16K | 4 | 77.0 | 157 | 178 | 638 |
| 32K | 4 | 79.8 | 315 | 319 | 1,242 |
| 64K | 8 | 78.9 | 782 | 791 | 3,073 |
Wall-clock values are per-step means. The two 16K runs differ only in SP and are directly comparable; the 32K and 64K rows demonstrate scaling to longer contexts. At 64K with SP=8, peak memory remains 78.9 GB. Together, these results demonstrate that DualKV's core design extends beyond Qwen3 GQA to modern hybrid global/sliding-window architectures and sequence-parallel training.
W3. Short prompts with long decoding horizons
Response. Thank you for highlighting this workload regime. DualKV applies whenever post-training processes multiple responses from the same prompt, while and predict the magnitude of its savings. Because GSM8K alone does not characterize current short-prompt/long-decoding workloads, we measured actual stored responses from reasoning, code, and agentic datasets using the Qwen3-8B tokenizer and chat template:
| Workload | , P50/P90 | , P50/P90 | Scenario , P50 |
|---|---|---|---|
| OpenThoughts-114K teacher traces | 354/652 | 5,400/14,755 | |
| OpenR1-Math-220K verified traces | 87/160 | 4,652/11,157 | |
| SWE-Gym OpenHands trajectories | 1,777/2,756 | 11,107/38,239 | |
| Open-R1 Verifiable Coding Problems — tested Python solutions | 527/840 | 161/500 |
Here, measures physical token-volume reduction, and is a separately labeled grouped-RL scenario rather than the datasets' native multiplicity. We generated no responses and imputed no response lengths. The first three response-dominated workloads yield -- median token-volume reduction, whereas the tested-code workload yields . These results quantify the response-dominated boundary highlighted by the reviewer while also showing that absolute prompt length alone is insufficient: and rollout multiplicity govern the available savings. We will add these distributions and make this boundary explicit in the revision.
Q1. Why does Table 1 use FP16 rather than BF16?
Response. Thank you for asking about this choice. We intentionally used FP16 for Table 1's isolated forward/backward kernel sweep across and , and BF16 for the end-to-end GRPO/DAPO training experiments, so that the evaluation covers both supported half-precision formats. DualKV-FA2 provides dedicated FP16 and BF16 forward/backward kernel instantiations for the supported head dimension. We will clarify this choice explicitly in the next revision.
Q2. Why was Prefix Grouper absent from the A100 Table 1?
Response. Thank you for pointing out this distinction. Table 1 deliberately isolates one attention-kernel call on A100. Prefix Grouper operates at the framework level and invokes standard FA2 after preparing its inputs, whereas Table 1 measures individual attention kernels. Before those calls, its prompt K/V must be materialized for each response. A kernel-only row would therefore time only the underlying FA2 calls while omitting Prefix Grouper's expansion and layout costs.
We instead compare Prefix Grouper in Table 2 by timing a complete Transformer decoder layer using its released code, including input preparation, attention, projections, normalization, and the MLP. We will clarify this in our next revision.
Thank you to the authors for providing a detailed response. While this response addresses many of my concerns, I believe that there are still two outstanding points based on the discussion. First, kernel implementation overhead does not seem to be negligible as the method required kernel-level changes when adapted to FA3 on an H100. Second, the benefits of the method seem limited when the decoding horizon significantly exceeds the prompt length. However, all things considered, the response provides additional valuable justification for the method, so I increase my score to a 5.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Dear Area Chair,
Thank you for the thoughtful and encouraging meta-review. We have responded to all questions raised by the reviewers, including new H100 DualKV-FA3 forward/backward benchmarks, Gemma-4 hybrid global/sliding-window and sequence-parallel validation, prompt/response-length analysis across six real post-training datasets, and clarifications regarding novelty, mixed precision, accuracy variation, and data-pipeline constraints.
We appreciate the reviewers’ constructive feedback and will incorporate these results and clarifications into the revision. We would be happy to clarify any remaining concern.