Repository navigation
Fix OOB in paged MQA logits metadata scheduler - #353
Merged
RayWang96 merged 1 commit intoJun 4, 2026
Merged
Conversation
When all context_lens are zero (e.g. warmup decode with kv_lens=1 and indexer_compress_ratio=4 giving gen_seq_lens=0), the binary search pushes lo to batch_size. The subsequent prefix_sum[q_idx] access is OOB when q_idx == batch_size == kAlignedBatchSize, since prefix_sum only has indices [0, batch_size). This causes a deterministic IMA during DSv4-Pro disagg GEN warmup at batch_size=32 (warmup step: 32 tokens, 32 gen). Fix: clamp q_idx to batch_size - 1. When the binary search lands past all queries (total work = 0), num_segs_q correctly evaluates to 0, and the existing guards (num_segs_q > 0 ? ...) produce the sentinel values (atom_idx=0, kv_split_idx=0). Signed-off-by: Barry Kang <[email protected]>
Barry-Delaney
added a commit
to Barry-Delaney/TensorRT-LLM
that referenced
this pull request
Jun 4, 2026
Update DeepGEMM pin to include fix for an out-of-bounds shared memory access in the paged MQA logits metadata scheduler kernel (smxx_paged_mqa_logits_metadata). When all context_lens are zero (warmup decode with kv_lens=1 and indexer_compress_ratio=4), the binary search result reaches batch_size, causing prefix_sum[batch_size] to read past the shared memory array. This triggers a deterministic IMA during DSv4-Pro disagg GEN warmup at batch_size=32. Fix: clamp the binary search result to batch_size - 1. DeepGEMM PR: deepseek-ai/DeepGEMM#353 Signed-off-by: Barry Kang <[email protected]>
jiaganc
pushed a commit
to jiaganc/TensorRT-LLM
that referenced
this pull request
Jun 4, 2026
Update DeepGEMM pin to include fix for an out-of-bounds shared memory access in the paged MQA logits metadata scheduler kernel (smxx_paged_mqa_logits_metadata). When all context_lens are zero (warmup decode with kv_lens=1 and indexer_compress_ratio=4), the binary search result reaches batch_size, causing prefix_sum[batch_size] to read past the shared memory array. This triggers a deterministic IMA during DSv4-Pro disagg GEN warmup at batch_size=32. Fix: clamp the binary search result to batch_size - 1. DeepGEMM PR: deepseek-ai/DeepGEMM#353 Signed-off-by: Barry Kang <[email protected]>
jiaganc
pushed a commit
to jiaganc/TensorRT-LLM
that referenced
this pull request
Jun 4, 2026
Update DeepGEMM pin to include fix for an out-of-bounds shared memory access in the paged MQA logits metadata scheduler kernel (smxx_paged_mqa_logits_metadata). When all context_lens are zero (warmup decode with kv_lens=1 and indexer_compress_ratio=4), the binary search result reaches batch_size, causing prefix_sum[batch_size] to read past the shared memory array. This triggers a deterministic IMA during DSv4-Pro disagg GEN warmup at batch_size=32. Fix: clamp the binary search result to batch_size - 1. DeepGEMM PR: deepseek-ai/DeepGEMM#353 Signed-off-by: Barry Kang <[email protected]>
Barry-Delaney
added a commit
to Barry-Delaney/TensorRT-LLM
that referenced
this pull request
Jun 4, 2026
Update DeepGEMM pin to include fix for an out-of-bounds shared memory access in the paged MQA logits metadata scheduler kernel (smxx_paged_mqa_logits_metadata). When all context_lens are zero (warmup decode with kv_lens=1 and indexer_compress_ratio=4), the binary search result reaches batch_size, causing prefix_sum[batch_size] to read past the shared memory array. This triggers a deterministic IMA during DSv4-Pro disagg GEN warmup at batch_size=32. Fix: clamp the binary search result to batch_size - 1. DeepGEMM PR: deepseek-ai/DeepGEMM#353 Signed-off-by: Barry Kang <[email protected]>
leavelet
pushed a commit
to leavelet/DeepGEMM
that referenced
this pull request
Jun 5, 2026
Brings in 9 upstream nv_dev commits: paged-MQA metadata OOB fix (deepseek-ai#353), IMA guard in the paged-MQA scheduler (deepseek-ai#342), the FP16-weights FP8 MQA logits kernel, the mega-MoE refactor (deepseek-ai#347), and assorted updates. Conflicts resolved (3 files): - csrc/apis/attention.hpp (dense MQA dispatch): union of both sides — keep SM120 FP4 (sm120_fp4_mqa_logits) and SM120 FP8 (arch 12) arms, and add nv_dev's FP16-weights arm (sm100_fp8_mqa_logits_f16_weights, SM100-only, already guarded by the arch==10 host assert). - deep_gemm/include/deep_gemm/scheduler/paged_mqa_logits.cuh: take nv_dev's refactored scheduler. SM120's one-line OOB guard is subsumed by nv_dev's reversed-metadata allocation (the deepseek-ai#342/deepseek-ai#353 fix). The refactor replaces get_num_kv/get_atom_advance with refresh_num_kv_and_advance + get_last_advance. - tests/test_attention.py: keep SM120 small-S split-KV MQA shapes and add the upstream large-KV/32-head regime; next_n = (1..6) on SM120, (1,2,4,5,6) on SM100, (1,2,4) on SM90; take nv_dev's paged test body (memory caps + peak-mem reset). Semantic fixes required by the merge (no textual conflict, would not compile/run otherwise): - sm120_fp8/fp4_paged_mqa_logits.cuh: migrate the scheduler call get_atom_advance(next_q_idx, batch_size) -> get_last_advance() to match nv_dev's refactored scheduler API (same migration nv_dev applied to the SM100 paged kernel). - tests/test_attention.py: gate the FP16-weights path to arch 10. Upstream set FP16 weights unconditionally, which dispatches to the SM100-only kernel and trips the arch==10 host assert when test_attention runs on SM90/SM120. Validated on H200 (sm90): clean build; test_bf16, test_fp8_fp4, test_attention all pass. SM120 (arch 12) kernels are JIT and arch-gated, so they are neither compiled nor run on H200 — they require an RTX 6000 run before the final PR.
Closed
1 task done
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When all context_lens are zero (e.g. warmup decode with kv_lens=1 and indexer_compress_ratio=4 giving gen_seq_lens=0), the binary search pushes lo to batch_size. The subsequent prefix_sum[q_idx] access is OOB when q_idx == batch_size == kAlignedBatchSize, since prefix_sum only has indices [0, batch_size).
Fix: clamp q_idx to batch_size - 1. When the binary search lands past all queries (total work = 0), num_segs_q correctly evaluates to 0, and the existing guards (num_segs_q > 0 ? ...) produce the sentinel values (atom_idx=0, kv_split_idx=0).