Skip to content

[rl] MTP verify steps: run verify rows on FA4's decode kernel - #6364

Closed
felipemello1 wants to merge 2 commits into
felipemello1/vllm-mtp-spec-decodefrom
felipemello1/mtp-verify-steps
Closed

felipemello1 wants to merge 2 commits into
felipemello1/vllm-mtp-spec-decodefrom
felipemello1/mtp-verify-steps

Conversation

@felipemello1

@felipemello1 felipemello1 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Agent details

Needs retesting on B200 (SM100): every number below is from one GB300 (SM103). FA4's split heuristics are tuned per GPU, so B200 timings can differ.

Stack, bottom to top:

  1. "[rl] GDN builder: stage steps with drafts in fixed buffers"
  2. "[rl] MTP: replay the verify CUDA graph only when every row verifies"
  3. "[rl] GDN layer: run steps with drafts from TorchTitan's builder"
  4. "[rl] MTP speculative decoding in the vLLM generator"
  5. this PR
  6. "[rl] MTP on GDN models: FULL CUDA graphs for steps with prefill"
  7. "[rl] vLLM generator: fp8 KV cache through FA4's fp8 forward, MTP verify steps included"

The stack lands after the vLLM 0.33 PRs ("[rl] generator: vLLM 0.33 API fixes and TP padding in the model wrapper", "[rl] Install vLLM 0.33.0 on the torch nightly"). "[rl] generator: run on vLLM's model runner V2 (vLLM 0.34)" rebases on it.

TLDR: MTP verify rows (1 + k tokens each) now run on SwapAB, FA4's decode kernel for one query token per row, instead of its prefill kernel. On agent loads with long shared prompts, attention per 26-row verify step drops from 25.5 to 14.9 ms, plus 1.2 ms for the fp32 tail's kernels. Qwen3.8-27B, one GB300, 26 multi-turn sessions, MTP-3 with FULL_DECODE_ONLY: 1,008 output tok/s, vs 857 before this PR and 892 without MTP (an earlier version of the stack, NOTE).

With 3 drafts, each verify row's 4 query tokens become extra query heads of one decode row on FA4's SwapAB kernel, and the last 3 keys run in fp32 and merge by logsumexp, so attention per 26-row verify step takes 14.9 ms plus 1.2 ms instead of 25.5 ms, for 1,008 output tok/s vs 857.

verify step, row of seq_len L, k = 3 drafts (4 query tokens):
before:  4-token rows    -> FA4 prefill kernel
after:   keys 0 .. L-4   -> SwapAB, 4x query heads per row, KV splits
         keys L-3 .. L-1 -> fp32, causal among the row's tokens; logsumexp merge with the SwapAB part

Problem

  1. With num_speculative_tokens = k, each decode step verifies 1 + k tokens per request.
  2. FA4 runs SwapAB only for one query token per row, so 4-token verify rows take its prefill kernel.
  3. Cost: 23.9 ms of a 46.4 ms verify step's GPU time (26 rows sharing 3 prompts, profiled engine). MTP-3 ran at 857 output tok/s on a 26-session multi-turn load, 0.96x no MTP (892).

Solution

  1. _verify_rows_as_decode (vllm/attention/attention.py): each row's tokens become extra query heads of one decode row over the keys all of them see. The last k keys are added in fp32, causally, and merged by logsumexp.
  2. It runs only where SwapAB takes the rows: SM100/SM103, head dim 64/96/128/256, query heads per KV head x (1 + k) <= 32. It also needs a uniform verify step of 8+ rows, padded rows included: below that, the tail costs more than SwapAB saves (grid below). A FULL graph fixes the row count, so the check is graph-safe.
  3. A step whose rows all hold the same number of tokens (> 1) makes one FA4 varlen call: it has no 1-token decode row to split off. Before, such steps (verify steps under 8 rows, equal prefill rows) also launched an empty decode call. The remaining call has the same arguments, so the output is unchanged.
  4. The B200 RL workflow runs test_vllm_verify_attention.py.
  5. Unchanged: k = 0, and every graph mode.

Results

Numerics: not bitwise vs the prefill-kernel path (other kernels, other summation order).
  GPU test vs an fp32 causal reference: atol 2e-3, rtol 2e-2, at max_seq_len 262144 (Qwen3.8-27B's max_model_len).
  Graph vs eager, 24 greedy requests of 256 tokens: FULL_DECODE_ONLY vs NONE, 16/24 identical streams,
  mean logprob diff 2.24e-3.

Verify-path grid: forward on a uniform MTP-3 verify step, this PR's path vs the parent's FA4 varlen call (max_seqlen_q 4). Qwen3.5 attention configs (head dim 256), rows 1-64 x context 1k-128k, 128-token pages, max_seq_len 131072, CUDA graphs, FA4 4.0.0b40, one GB300, one run per point:

Heads (q/KV), hd256 KV pages Time vs parent: median (best .. worst) Points faster rel L2 vs parent (max)
24/4 unique per row +57% (+9% .. +153%) 0/35 3.5e-3
16/2 unique per row +73% (+12% .. +135%) 0/35 3.5e-3
16/4 unique per row +50% (+2% .. +126%) 0/35 3.5e-3
24/4 8-row groups share 3/4 +56% (-20% .. +156%) 7/35 3.5e-3
16/2 8-row groups share 3/4 +90% (-16% .. +158%) 5/35 3.5e-3
16/4 8-row groups share 3/4 +57% (-27% .. +151%) 8/35 3.5e-3
  • The path wins when 8+ rows share long prompts: SwapAB reads the shared pages from L2, and FA4's prefill kernel does not. 19 of the 20 faster points have 8+ rows and 64k+ context (0.73-0.99x).
  • Small steps pay a fixed cost: the tail's ~15 small kernels add 53-71 us per layer at 1-4 rows and up to 4k context (the parent's whole call: 44-60 us). So steps under 8 rows keep the varlen call.
  • With unique contexts of one length, the path loses. With mixed lengths, as an engine's rows have, it wins at 32-64 rows x 64k-128k:
24/4, hd256, unique KV per row, max_seq_len 262144, FA4 4.0.0b40, one GB300, CUDA graphs, us per layer:
                   one length per row              lengths 0.25x .. 1.75x of the mean
rows   mean ctx    parent   this PR   ratio        parent   this PR   ratio
32     64k         1,246    1,414     1.13         1,680    1,416     0.84
64     64k         2,466    2,703     1.10         2,871    2,730     0.95
32     128k        2,406    2,686     1.12         3,303    2,696     0.82
64     128k        4,843    5,245     1.08         5,665    5,300     0.94
Qwen3.8-27B, one GB300, TP1, bf16 KV, 26 multi-turn sessions in 3 groups (27k / 55k / 77k shared prompts),
180 s window, output tok/s:
  no MTP, FULL                                     892
  MTP-3, FULL_DECODE_ONLY, before this PR          857     0.96x
  MTP-3, FULL_DECODE_ONLY, this PR                 1,008   1.13x
Engine profile, one verify step (26 rows x 4 tokens): GPU 46.4 -> 37.2 ms; attention (target + drafter)
25.5 -> 14.9 ms, plus 1.2 ms for the verify tail's kernels.

On a unique-context load the path ties: 128 agent sessions in groups of 16 that share only a 4k first prompt, MTP-3, 761 output tok/s vs 763 for the varlen call. Its decode steps are 22% faster (p50 49.7 vs 63.7 ms), but the two arms' prefix-cache hits drifted apart (73% vs 82% of prompt tokens), so they ran different prefill work.

NOTE:

  • The engine numbers ran on a development branch: the MTP PR's earlier GDN path (a port of vLLM's mixed-step GDN code, replaced in this stack by the GDN builder and layer PRs), plus generator changes not in this stack. Its attention file differs from this PR's only in comments, keyword arguments, a head-dim term in the gate and the 8-row cutoff, which the 26-session run predates. The unique-context load ran FULL graphs with piecewise graphs for steps with prefill, in both arms. One run per arm. Not re-measured on this stack.
  • MTP pays only while the KV cache has room. 32 sessions sharing one 27k prompt, then each its own history: MTP-3 1,305 vs 903 tok/s without MTP (1.45x, with the earlier FULL piecewise graphs). At 46 sessions: 210 vs 572 (0.37x); both arms are KV-bound there, and MTP-3 evicts more history. The fp8 KV cache PR (7) fits 2x the tokens.
  • Two open PRs edit vllm/attention/attention.py; the one that lands second rebases: the vLLM V2 model runner PR and the ROCm paged-KV gather PR.

You may ask: why not vLLM's merge_attn_states for the merge? It takes token-major outputs of one dtype: three layout copies and a bf16 tail, for ~5 fewer kernels.

Follow up / TODO (the # TODO is in forward)

  • Drop the fp32 tail once FA4's floor has SwapAB token mode (an open FA4 PR): the plain varlen call then serves verify rows. Keep this path only for shapes token mode refuses, e.g. 6 query heads per KV head at k = 4. If FA4 declines token mode, fuse the tail and the merge into one Triton kernel: its ~15 small kernels per layer add 1.2 ms per verify step (~3%).

Test plan

pytest tests/rl/unit_tests/cpu
pytest tests/rl/unit_tests/gpu/test_vllm_verify_attention.py   # 1 GPU (GB300); also in the B200 RL workflow
pre-commit run --files <changed files>
RL CPU suite   788 passed, 0 failed, 8 skipped on the pinned vLLM (1.0.0.dev20261107; the MTP PR: the same), main
               merged in.
GPU            test_vllm_verify_attention.py: 3 passed (40 s). Verify, few-row and mixed batches through `forward`,
               against an fp32 reference; it counts FA4 calls: one for verify and few-row, two for mixed.
pre-commit     all hooks pass (pyrefly and lychee skipped)

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 6m 11s —— View job


Approve -- please address the items before merging (empty human-written summary; link the upstream issues in the torch and vLLM TODOs). Review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the items below before merging. The two problems are real on the parent (FULL + drafts raises; verify rows take FA4's prefill kernel), the fix stays in the vLLM generator, and the remaining items are small edits. A maintainer still needs to review.

What this PR does.

  • A verify step's attention runs as one decode row per request when every row has 1 + k tokens and there are 8 or more rows. The row's tokens become extra query heads over the keys all of them see. The last k keys are added in fp32 and merged by logsumexp.
  • cuda_graph.mode="FULL" with drafts now maps to vLLM's FULL_AND_PIECEWISE instead of raising. The speculative GDN call becomes an eager graph break.

Example. One row, seq_len L = 1000, k = 3 (tokens at positions 996..999):

before: FA4 varlen, max_seqlen_q 4               -> prefill kernel
after:  FA4 decode, 4 x 24 query heads over keys 0..996   (seqused_k = 997)
        fp32: token j also sees keys 997..996+j  (token 0: none, lse -inf)
        out = exp(lse_a - lse) * out_a + exp(lse_b - lse) * out_b
cuda_graph.mode="FULL", k=3:
before: ValueError in VLLMEngine.Config.__post_init__
after:  uniform verify steps -> FULL graph; steps with prefill and the drafter -> piecewise, attention + GDN eager

I checked the causal split against the reference: token j at position L-n+j sees shared keys 0..L-n plus tail keys i < j. It is correct for any uniform n-token row whose queries are the row's last n positions, so a prefill step whose rows all happen to have n tokens is also handled correctly.

Must fix

  1. PR description: "Summary (human-written)" is empty. The author needs to fill it in. Agents don't write it.
  2. attention.py:294-296, engine.py:157-158 -- the upstream-workaround TODOs say "no torch issue filed yet" and "no vLLM issue filed yet". File both issues and link them (inline).

Should consider

  • attention.py:376 -- use shape suffixes in _verify_rows_as_decode (inline).
  • test_vllm_verify_attention.py:152 -- the second max_seq_len value doubles the B200 cases. Keep it only if it guards a distinct FA4 split path (inline).

Questions

  • Your grid times this path slower at all 35 unique-context points, including 1.08-1.14x at the unique-context engine load's shapes, yet that load's decode steps were 22% faster. The cutoff counts only rows, so every 8+-row verify step takes this path whether or not its rows share pages. Can one of the four listed differences be checked before landing? Otherwise we keep a dispatch rule whose own microbenchmark disagrees with it, and the cause is unexplained (CLAUDE.md principle 1). GRPO groups usually share prompts, so the default is plausibly right for RL. The ask is to confirm it, not to change it.
  • _enable_breakable_cuda_graphs raises if anything imported vLLM's attention module before VLLMEngine.__init__. The only engine runs are on the dev branch, and no test builds a VLLMEngine with FULL + k > 0. Was the engine built end to end at this commit with the env var unset at process start (e.g. through torchtitan/rl/generate.py)?
  • FULL_AND_PIECEWISE captures piecewise graphs for every capture size, up to max_num_batched_tokens in FULL mode, on top of the FULL uniform-decode graphs. What do capture time and graph memory cost vs. FULL_DECODE_ONLY on Qwen3.8-27B?
Details
  • Gate: both problems reproduce on the parent: the __post_init__ raise, and max_seqlen_q > 1 sending verify rows to FA4's prefill kernel. The layer is right: TorchTitan's CUSTOM backend owns these FA4 calls, and the kernel-side fix is upstream (Dao-AILab/flash-attention#3217) with a TODO. No overlapping PR changes the dispatch; the V2-runner and ROCm PRs only conflict textually, as the description says.
  • Graph safety: inside a FULL graph the branch is decided at capture from Python ints (max_query_len, num_actual_tokens, seq_lens.shape[0]). Under piecewise replay, attention runs eagerly and re-reads live metadata (get_attention_context, attention.py:224), so mixed steps fall back to the varlen call. No host syncs in the new path.
  • Padded rows (seq_len 0): the shared part has seqused_k 0. The tail reads block-table column 0, a valid page id, and the merge's nan_to_num_ gives finite garbage for those rows. Their output is discarded, so this is fine.
  • Model coverage: only Qwen3.5-architecture drafts are accepted (worker.py:262). KDA rejects speculative decoding (kda.py:91), and out_transform (sinks) is excluded by the gate, so there is no other attention/linear-attention layer that would need a graph break under FULL_AND_PIECEWISE.
  • mode="FULL" now means "FULL where vLLM's GDN builder allows it". That is documented on VLLMCudaGraphConfig, so it isn't a silent fallback. The alternative is a separate FULL_AND_PIECEWISE mode value, which would add a knob only MTP uses. Keeping the mapping seems right.

Not verified: vLLM's eager_break_during_capture / BreakableCUDAGraphCapture semantics, and whether vLLM accepts FULL_AND_PIECEWISE with CompilationMode.NONE. vLLM isn't installed in this runner, so I'm relying on the PR's GPU tests and engine runs.

Comment thread torchtitan/rl/generator/vllm/engine.py Resolved
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: Round 1 fixes are in e85f0c0. The two issue links wait on the author (see their threads). The questions are answered below.

max_seq_len doubles the cases. I dropped 131072. The test runs at 262144 only (Qwen3.8-27B's max_model_len). Both widths give FA4's per-sequence splits, so the second value guarded nothing new.

Q1: grid vs engine. Checked. The grid gave every row one context length, and the engine's rows have mixed lengths. With the same mean but rows spread from 0.25x to 1.75x of it, this path takes 0.82-0.95x the parent's time, vs 1.08-1.13x with one length. The parent's prefill kernel gets 16-37% slower on uneven rows. This path stays within 1%. The table is in the body. The 8-row cutoff stays.

Q2: an engine built with the variable unset? Not at this exact commit. An RL run on a development branch did it through the RL launcher, and nothing set VLLM_USE_BREAKABLE_CUDAGRAPH at process start: only engine.py sets it. With FULL and 3 MTP drafts, all 16 generators logged "Breakable CUDA graph enabled" and FULL_AND_PIECEWISE. That branch's _enable_breakable_cuda_graphs matches this PR's except for the TODO comment.

Q3: capture cost. Qwen3.8-27B on one GB300, now in the body:

no MTP, FULL                               63 s      4.69 GiB
MTP-3, FULL (vLLM's FULL_AND_PIECEWISE)    57-58 s   4.00 GiB
MTP-3, FULL_DECODE_ONLY                    29 s      0.78 GiB

So with drafts, FULL costs ~28 s and ~3.2 GiB more than FULL_DECODE_ONLY, and no more than FULL without MTP.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 3s —— View job


Approve -- please address the items before merging (round 1 is resolved except the human-written summary and the torch/vLLM issue links in the two TODOs). Review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the items below before merging. Round 1 is resolved except for the two upstream-issue links and the human-written summary, and e85f0c0 adds no new problems. A maintainer still needs to review.

What this PR does. Verify steps with 8 or more uniform rows of 1 + k tokens run their attention on FA4's decode kernel: each row's tokens act as extra query heads over the keys they all see, and the last k keys are added in fp32 and merged by logsumexp. cuda_graph.mode="FULL" with drafts now maps to vLLM's FULL_AND_PIECEWISE and no longer raises. The speculative GDN call becomes an eager graph break.

Example. One row, L = 1000, k = 3:

before: FA4 varlen, max_seqlen_q 4 -> prefill kernel
after:  FA4 decode, 4 x 24 heads over keys 0..996; fp32 tail keys 997..999, token j sees the first j
FULL + k=3: before ValueError; after verify-only steps -> FULL graph, steps with prefill and the drafter -> piecewise

Round 1, resolved

  • Shape suffixes in _verify_rows_as_decode: done, legend in the docstring. I checked the rename against the old code. The views and permutes are unchanged, and shared_out_RKJGV is allocated in 5-D and viewed to 3-D for FA4, the same memory as before. The old rikd->rkjgd value einsum is now correctly labelled rikv->rkjgv.
  • The second max_seq_len value was dropped, which halves the B200 cases.
  • Q1 (the grid disagreed with the engine load): answered. Mixed row lengths flip the grid to 0.82-0.95x, and that table is now in the body. The 8-row cutoff is justified.
  • Q2 (an engine built with the env var unset): answered with an RL-launcher run on the dev branch, whose _enable_breakable_cuda_graphs matches this one.
  • Q3 (capture cost): answered. FULL with drafts costs ~28 s and ~3.2 GiB more than FULL_DECODE_ONLY, and no more than FULL without MTP.
  • The mixed case is now [1, 4, 4]. It exercises the leading-single-token split in forward (decode call for row 0, varlen call for rows 1-2), which the old [4, 4, 1] didn't.

Must fix (still open)

  1. PR description: "Summary (human-written)" is still empty. The author fills it in.
  2. attention.py:294-296, engine.py:157-158: the upstream-workaround TODOs still say "no torch issue filed yet" / "no vLLM issue filed yet". File both issues and link them (CLAUDE.md principle 3). Per the replies, this waits on the author.

Uniform verify steps of 8 rows or more run on FA4's decode kernel; fewer rows keep one
varlen call. The B200 RL job runs test_vllm_verify_attention.py.
@felipemello1
felipemello1 removed this pull request from stack #6404 November 28, 2026 17:44
@felipemello1
felipemello1 force-pushed the felipemello1/mtp-verify-steps branch from dc7ca75 to 974dde2 Compare November 28, 2026 17:45
@felipemello1 felipemello1 changed the title [rl] MTP verify steps: verify rows on FA4's decode kernel, piecewise graphs for steps with prefill [rl] MTP verify steps: run verify rows on FA4's decode kernel Nov 28, 2026
@felipemello1
felipemello1 added this pull request to stack #6434 November 28, 2026 17:50
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 2m 11s —— View job


Approve: every earlier must-fix item is resolved at 974dde2, and the reworked commit adds no new problems. One open question: this PR's TODO and the one in #6366 give different removal conditions. Review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- every earlier must-fix item is resolved at 974dde2, and the reworked commit adds no new problems. A maintainer still needs to review.

What this PR does. A uniform verify step runs its attention on FA4's SwapAB decode kernel. Every row must have 1 + k tokens, there must be 8 or more rows (padded rows count), and the layer must pass the SM100/SM103, head-dim and heads x tokens <= 32 gate. Each row's tokens become extra query heads over the keys they all see. The last k keys are added in fp32 and merged by logsumexp. Any step whose rows all hold the same number of tokens now makes one FA4 call instead of a real call plus an empty decode call. The FULL_AND_PIECEWISE / breakable-graph change is gone from this PR (it now lives in #6403), so this diff no longer touches engine.py.

Example. 26 rows, k = 3, one row with L = 1000:

before: FA4 varlen, max_seqlen_q 4               -> prefill kernel (decode call empty)
after:  FA4 decode, 4 x 24 heads, seqused_k 997  -> SwapAB
        fp32 tail: keys 997..999, token j sees the first j; logsumexp merge
3 rows (< 8):    one varlen call, as before minus the empty decode call
[1, 4, 4] rows:  decode call for row 0 + varlen call for rows 1-2 (unchanged)

Earlier items

  • Upstream-workaround TODO (attention.py:303-307): resolved. It now links Dao-AILab/flash-attention#3217 and gives a removal condition, which is FA4 token mode serving the plain varlen call. The vLLM TODO left with the engine.py change.
  • Shape suffixes, the second max_seq_len value, and the [1, 4, 4] mixed case: still in place.
  • Q2/Q3 (breakable graphs, FULL_AND_PIECEWISE capture cost): no longer apply here. They belong to #6403.

Questions

  • The stacked fp8 PR #6366 still carries the old TODO ("once torch's varlen API passes FA4's query_len_in_heads"). That PR passes the knob explicitly to _flash_attn_fwd. This PR's TODO says the plain varlen call will serve verify rows once FA4 has token mode, with no torch change. Which removal condition is right? Make the two TODOs agree when #6366 rebases.
Details
  • Gate: the problem is still real on the parent. max_seqlen_q > 1 sends verify rows to FA4's prefill kernel. The fix is in the layer that owns these FA4 calls (TorchTitan's CUSTOM backend), and the kernel-side fix is upstream with a link.
  • is_uniform (attention.py:302): each row holds at most max_query_len tokens, so num_actual_tokens == max_query_len * num_rows holds only if every row is full. In a FULL graph the decision uses Python ints fixed at capture. Under eager/piecewise it uses the live metadata. Skipping the split for uniform steps drops only the call whose seqused_k is all zeros, so output is unchanged.
  • Uniform prefill steps: a prefill step of >= 8 rows that each happen to have 1 + k tokens also takes the decode path. That is still correct, because vLLM's queries are always the last n positions of each row.
  • Padded rows (seq_len 0): the shared part has seqused_k 0, the tail reads block-table column 0, and nan_to_num_ keeps the result finite. The output is discarded.
  • DiffKV: head_dim_v comes from value_cache.shape[-1], so the path handles it. No MTP-capable model reaches DiffKV today: Qwen3.5 full attention has equal K/V head dims, and KDA refuses drafts.
  • Overlap search: "MTP", "SwapAB", "verify attention.py". Found the author's own stack (#6287, #6365, #6366, #6402, #6403, #6432, #6433) and #5956 (V2 runner, a textual conflict only).

Not verified: FA4 #3217's token-mode behavior, and the GPU test and timings (no GPU or vLLM in this runner).

Before merge: fill in the human-written summary.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: This PR's condition is the right one: with FA4 token mode, the plain varlen call serves verify rows, with no torch change. If the stacked fp8 verify-rows PR stays open, its TODO gets the same condition when it rebases.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 0s —— View job


Approve: the PR's diff is unchanged since my full review at 974dde2, and the base-branch merge doesn't touch the verify path. Review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- the PR's diff at fa1ea64 matches the one I reviewed in full at 974dde2, line for line. The only new commit is a merge of the base branch, and it doesn't touch the verify path. A maintainer still needs to review.

What this PR does. A uniform verify step runs its attention on FA4's SwapAB decode kernel. Every row must have 1 + k tokens, there must be 8 or more rows, and the layer must pass the SM100/SM103, head-dim and heads x tokens <= 32 gate. Each row's tokens become extra query heads over the keys they all see. The last k keys are added in fp32 and merged by logsumexp. A step whose rows all have the same token count makes one FA4 varlen call instead of a real call plus an empty decode call.

Example. 26 rows, k = 3, one row with L = 1000:

before: FA4 varlen, max_seqlen_q 4               -> prefill kernel (decode call empty)
after:  FA4 decode, 4 x 24 heads, seqused_k 997  -> SwapAB
        fp32 tail: keys 997..999, token j sees the first j; logsumexp merge
3 rows (< 8):    one varlen call
[1, 4, 4] rows:  decode call for row 0 + varlen call for rows 1-2 (unchanged)

Since the last review

  • Earlier must-fix items: all were resolved at 974dde2 and are still in place.
  • The question about the TODO in #6366: answered. The removal condition in this PR is FA4 token mode serving the plain varlen call, and #6366 takes the same wording when it rebases. Nothing more is needed here.
  • New commits: c8c6e08 and the merge fa1ea64 come from the base branch. They change worker.py, registry.py, the GDN builder's TODO, and the KV-offload and Mooncake code. None of these files is in this PR's diff, and none changes what forward or _verify_rows_as_decode receives.
Details
  • Diff identity: compared the added and removed lines of git diff 9265203 974dde2 with gh pr diff 6364 at HEAD. They are identical.
  • Overlap search: searched "verify attention.py" and "SwapAB". Found only the author's own stack (#6365, #6366, #6432) and the PRs already named in the description (#5956, #4866), which conflict only in text.

Not verified: the GPU test and the timings (this runner has no GPU and no vLLM).

Before merge: fill in the human-written summary.

@liangel-02

Copy link
Copy Markdown
Contributor

Superseded by #6477

@liangel-02 liangel-02 closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants