Repository navigation
[https://nvbugs/6902355][fix] Keep TopK rows in the DSA sparse MLA test KV pool - #20283
Conversation
|
@yunruis, could you help to review this PR as trt-llm-torch-attention-devs? Thanks~ Assignment explanation
Affinity and workload are snapshots at selection, not live counters. Existing reservations on this PR are counted once. |
|
/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1,DGX_B300-4_GPUs-PyTorch-Post-Merge-2" |
|
PR_Github #77816 [ run ] triggered by Bot. Commit: |
|
PR_Github #77816 [ run ] completed with state
|
582accb to
c56d2ce
Compare
|
/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1,DGX_B300-4_GPUs-PyTorch-Post-Merge-2" |
|
PR_Github #77860 [ run ] triggered by Bot. Commit: |
|
PR_Github #77860 [ run ] completed with state
|
|
/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1,DGX_B300-4_GPUs-PyTorch-Post-Merge-2" |
|
PR_Github #77897 [ run ] triggered by Bot. Commit: |
|
PR_Github #77897 [ run ] completed with state
|
|
/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1,DGX_B300-4_GPUs-PyTorch-Post-Merge-2" |
|
PR_Github #77926 [ run ] triggered by Bot. Commit: |
|
PR_Github #77926 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #78069 [ run ] triggered by Bot. Commit: |
|
PR_Github #78069 [ run ] completed with state |
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
|
/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1,DGX_B300-4_GPUs-PyTorch-Post-Merge-2" |
|
PR_Github #78336 [ run ] triggered by Bot. Commit: |
|
@yuxianq, thanks for picking up this PR! I’ve handed off the trt-llm-torch-attention-devs review from @yunruis to you. The 3 attention-review points now belong to @yuxianq; @yunruis’s attention reservation has been released. Your review is already submitted, so the points count as completed work; no new review request was added. @yunruis, no further attention review is requested from you. Thanks~ |
|
PR_Github #78336 [ run ] completed with state
|
…st KV pool test_sparse_attention_mla sized its KV cache to the blocks the short sequences need, so context_sequence_lengths=[10] got a single 64-token block. The static token-sparse context FMHA can load KV rows beyond the selected ones, and its TMA descriptor does not bound rows to the pool, so such a pool can be read past its end and faults whenever the following address range is unmapped. Keep at least TopK rows in the pool, as any real deployment does. Signed-off-by: Fanrong Li <23290157+lfr-0531@users.noreply.github.com>
c56d2ce to
45acc45
Compare
|
/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1,DGX_B300-4_GPUs-PyTorch-Post-Merge-2" |
|
PR_Github #78398 [ run ] triggered by Bot. Commit: |
|
PR_Github #78398 [ run ] completed with state
|
|
/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1,DGX_B300-4_GPUs-PyTorch-Post-Merge-2" |
|
PR_Github #78417 [ run ] triggered by Bot. Commit: |
|
PR_Github #78417 [ run ] completed with state
|
|
/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1,DGX_B300-4_GPUs-PyTorch-Post-Merge-2" |
|
PR_Github #78431 [ run ] triggered by Bot. Commit: |
|
PR_Github #78431 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #78504 [ run ] triggered by Bot. Commit: |
|
PR_Github #78504 [ run ] completed with state |
Description
Fixes the intermittent illegal memory access in
unittest/_torch/attention/sparse/dsa/test_dsa_sparse_mla.py::test_sparse_attention_mlareported inhttps://nvbugs/6902355 (LLM/main/L0_PostMerge #3009,
DGX_B300-4_GPUs-PyTorch-Post-Merge-2, FP8 KV,context_sequence_lengths=[10]). It recurs in CI pipelines (see CI impact), but the repair botcould not reproduce it standalone (75/75 passes).
Root cause. The test sizes its KV cache to the blocks the short sequences need. With
context_sequence_lengths=[10]that is a single 64-token block, so the primary pool is 36,864 B withFP8 KV and 73,728 B with BF16 KV. The trtllm-gen static-token-sparse context FMHA used by DSA on
SM100f/SM103 can load KV rows beyond the selected ones. Its token-sparse K TMA descriptor has
INT_MAXrows (KernelParams.h), and the dispatcher setsmNumPagesInMemPool = INT_MAX, so nothingclips those loads to the pool. Whether a load past the end faults depends only on whether the
address range after the pool happens to be mapped. That changes with the allocation history of a
long pytest process. That is why it fails in CI, for example about 1,430 tests into the #3009
process, but not standalone.
Fix. Keep at least
SPARSE_TOPK(2048) rows in the test's KV pool. Every real deployment hasfar larger pools (blocks × layers × 64 rows), and 2048 rows is the same TopK-row invariant the DSA
backend already enforces for its NVFP4 context scratch.
CI impact. The fault is not a one-off. In the last 30 days (2026-09-14 to 10-14), 40 CI runs
failed first on an FP8
context_sequence_lengths: [10]case with this exact signature:test_dsa_sparse_mla.py:154IMA, thencudaEventCreateIMA inBlockManager::releasePools.generation_seq_len_q: 4case and 8 thegeneration_seq_len_q: 1case.on setupwith an illegal memory access. For example, all 18 setup failures of
test_sparse_mla_forward.py::test_forward_sparse_mla_unified[deepseek_v4-auto-small_prefill]inthat window come from these runs.
Evidence (B300 / GB110, CI wheels of post-merge #3009
ec357dd9and #3018af469207):that ends right before reserved but unmapped VA, and rewrote
kv_cache_pool_pointers.CUDA_ERROR_ILLEGAL_ADDRESSatthe FMHA
cuLaunchKernelEx(CUDA_LAUNCH_BLOCKING=1).placed before the pool.
Warp illegal addressinfmhaSm100fKernel_QkvE4m3OBfloat16HQk576HV512HVPerCta256PagedKvDenseStaticTokenSparseP1VarSeqQ64Kv128Static2CtaKeepsAbForGen.The BF16 run reports the
QkvBfloat16variant of the same kernel.the end (FP8).
for ctx 10/100/1000 and FP8/BF16.
A kernel-side follow-up for the trtllm-gen owners is to bound the token-sparse KV descriptor rows to
the real pool, so short or tail requests can never load past the allocation. This PR only removes the
test's unrealistic 1-block pool.
Test Coverage
unittest/_torch/attention/sparse/dsa/test_dsa_sparse_mla.py, run in theunittest/_torch/attentionentries ofl0_b200,l0_b300andl0_dgx_b300.PR Checklist
🤖 Generated with Claude Code