fix(xqa): fix PDL load ordering and SM90 fp8 draft-mask dispatch - #4199
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
📝 WalkthroughWalkthroughXQA speculative-decoding execution now computes launch state after ChangesXQA speculative decoding
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/attention/test_xqa_batch_decode.py (1)
1126-1141: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy liftCover the PDL ordering regression.
This call uses uniform Q and scalar scales, so it never exercises the moved
qCuSeqLens,qScalePtr, orkvScalePtrreads. Add an SM90a-gated ragged-Q test with tensor scales andenable_pdl=True; otherwise the pre-acqBulk()regression can return unnoticed. Confidence: high.As per coding guidelines, “Skip architecture-specific tests using the appropriate
flashinfer.utilschecks, such asis_sm90a_supported()orget_compute_capability().”🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/attention/test_xqa_batch_decode.py` around lines 1126 - 1141, Add an SM90a-gated regression test alongside the existing XQA batch decode coverage that uses ragged per-request Q lengths, tensor-based q/kv scales, and enable_pdl=True. Ensure the test exercises qCuSeqLens, qScalePtr, and kvScalePtr reads before the PDL acqBulk path, and skip it using the appropriate flashinfer.utils architecture check such as is_sm90a_supported().Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/attention/test_xqa_batch_decode.py`:
- Around line 1126-1141: Add an SM90a-gated regression test alongside the
existing XQA batch decode coverage that uses ragged per-request Q lengths,
tensor-based q/kv scales, and enable_pdl=True. Ensure the test exercises
qCuSeqLens, qScalePtr, and kvScalePtr reads before the PDL acqBulk path, and
skip it using the appropriate flashinfer.utils architecture check such as
is_sm90a_supported().
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c192fce8-0845-4a84-84a2-6e40eee66729
📥 Commits
Reviewing files that changed from the base of the PR and between 417bbd2 and dda315f5446acde347625a919add6cf31550d2b2.
📒 Files selected for processing (6)
csrc/xqa/mha.cuflashinfer/decode.pyflashinfer/jit/xqa.pyflashinfer/trace/templates/attention.pyflashinfer/xqa.pytests/attention/test_xqa_batch_decode.py
💤 Files with no reviewable changes (1)
- flashinfer/trace/templates/attention.py
|
Verified the three items from the #4137 thread on
Three things below: one small ask for this PR, one for the #4198 follow-up, one doc nit. The deterministic test never reaches
|
- Read qCuSeqLens and the q/kv scale tensors only after the PDL acquire in mha.cu; a producer kernel's writes are not visible before griddepcontrol.wait. - Route SM90 fp8 spec-dec with q_seq_len * head_group_ratio <= 32 to the generic kernel: mha_sm90.cu's SWAP_AB layout hardcodes a causal draft mask. - Add a deterministic mask-mode test that distinguishes causal from full draft masks exactly. - Drop the inert q_cu_seq_lens input from the xqa trace template. - Normalize the ragged-Q module key inside get_xqa_module and skip the redundant ragged build when no SM90 target is compiled. - Document the SM90 fp8 generic-kernel fallback in xqa() and decode.py. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add a q_len * head_grp_size > 32 shape so the test covers the one spec-dec configuration that stays on mha_sm90.cu, and document the SM90 fp8 fallback under window_left and the sinks condition in xqa(). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dda315f to
a674e01
Compare
|
@qsang-nv Thanks for the careful verification. All three items are handled:
|
|
/bot run tests/attention |
…k dispatch (#4232) ## Summary - Cherry-pick of #4199 onto `release-v0.6.16` - Fixes XQA PDL load ordering and SM90 fp8 draft-mask dispatch - Includes the follow-up test that reaches the SM90 fp8 kernel in the deterministic mask test ## Source - Upstream PR: #4199 - Cherry-picked squash merge: `6812ddb4` ## Test plan - [ ] `tests/attention/test_xqa_batch_decode.py` on SM90 / relevant arches Co-authored-by: yichengj <yichengj@nvidia.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
📌 Description
Follow-up to #4137, addressing the review feedback that arrived after auto-merge. Thanks @qsang-nv for the detailed analysis.
Issues:
csrc/xqa/mha.cu) readq_cu_seq_lensand the scale tensors before the acquire that makes a producer kernel's writes visible.q_cu_seq_lensdrives the output row offset, so a stale read could write into the wrong request's rows.csrc/xqa/mha_sm90.cu, used whenq_seq_len * head_group_ratio <= 32) hardcodes a causal draft mask, so a full draft mask silently returned causal results. Existing refchecks use random data and cannot tell the two modes apart within fp8 tolerance.q_cu_seq_lensinput that the trace reference silently dropped.Fixes:
q_cu_seq_lensand scale-tensor loads below the PDL acquire inmha.cu.q_cu_seq_lensfrom the trace template until the trace reference supports ragged Q.xqa(),xqa_batch_decode_with_kv_cache, andtrtllm_batch_decode_with_kv_cachedocstrings.🔍 Related Issues
#4198 (restore the Hopper fp8 fast path for speculative decode). Review thread: #4137.
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
test_xqa_batch_decode_mask_mode_deterministic(causal/full mask, bf16/fp8 KV, two head-group shapes) with exact expected outputs.head_grp_size=16shape exercises the Hopper kernel and thehead_grp_size=4shape exercises the widened fallback.Reviewer Notes
SPEC_Q_SEQ_LENbuild specialization is no longer reachable at run time but is kept: the fast-path restoration in [Bug] mha_sm90.cu: spec-dec draft mask ignored in the SWAP_AB layout, wrong sliding-window masking for full masks, no ragged Q, scale loads before the PDL acquire #4198 re-enables it.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation
Tests