Skip to content

[https://nvbugs/6695563][fix] Densify the bmm LHS with a.contiguous() gated on get_sm_version() in (120… - #18678

Open
trtllm-agent wants to merge 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6695563
Open

[https://nvbugs/6695563][fix] Densify the bmm LHS with a.contiguous() gated on get_sm_version() in (120…#18678
trtllm-agent wants to merge 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6695563

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: On SM120/121 the non-densified head-major LHS of MLA._bmm_bf16_out makes cuBLAS select a TMA-based nvjet kernel whose layout cuTensorMapEncodeTiled cannot describe, causing a warp MMU page fault reported asynchronously as an illegal memory access.
  • Fix: Densify the bmm LHS with a.contiguous() gated on get_sm_version() in (120, 121) so a non-TMA kernel is selected, mirroring the existing SM120 branch in fp8_block_scaling_bmm_out; kept the host_total_kv_lens .item() value-copy and removed the 2 waivers.
  • Original test: pytest tests/integration/defs/accuracy/test_llm_api_pytorch.py::TestDeepSeekV3Lite::test_guided_decoding_4gpus[xgrammar-mtp_nextn=2] -v
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Reproduction comparison

  • Failed commit: error_on_failed_commit at c7b8ec2
  • ToT: repro_on_tot at c2023c9
    Signature: tensorrt_llm.executor.utils.RequestError: Event loop terminated with error: Fatal error: CUDA error: an illegal memory access was encountered
  • Signature relation: not_comparable

Dev Engineer Review

  • MLA._bmm_bf16_out now calls a.contiguous() on SM120/121 GPUs. This avoids the incompatible TMA-based cuBLAS kernel layout.
  • Chunked-prefill now stores host_total_kv_lens as a value copy. This prevents aliasing with values modified by the chunk loop.
  • The changes are limited to the affected GPU architectures and preserve the existing workaround pattern.
  • Two RTX PRO 6000 Blackwell guided-decoding waivers were removed. The entries target the intended DeepSeekV3Lite four-GPU tests.

QA Engineer Review

  • Modified test-list file: tests/integration/test_lists/waives.txt.
  • Removed the RTX_PRO_6000_Blackwell_Server_Edition waivers for DeepSeekV3Lite four-GPU guided-decoding tests using llguidance and xgrammar.
  • No test code was added, modified, or removed.
  • The waiver changes have the intended scope and use the existing test-list format.
  • Verdict: sufficient.

… chunked-prefill path

TestDeepSeekV3Lite::test_guided_decoding_4gpus[*-mtp_nextn=2] died on
RTX PRO 6000 Blackwell (SM120) with an illegal memory access surfacing inside
MLA.forward_context_with_chunked_prefill. A CUDA core dump identified the
faulting kernel as nvjet_sm120_tst_mma_32x16x128_8_16x8x128_tmaAB_alignCD4_bz_TNNN
with CUDBG_EXCEPTION_WARP_MMU_FAULT -- a cuBLAS GEMM, not an attention kernel.

MLA._bmm_bf16_out passes its LHS as a head-major transpose of a
[tokens, heads, dim] buffer, so the batch stride is the token count rather than
the tile extent. On SM120/121 cuBLAS selects a TMA-based nvjet kernel for that
layout, which cuTensorMapEncodeTiled cannot describe; the kernel faults with an
MMU page fault that surfaces asynchronously at the next synchronize -- here
inside the chunked-prefill loop, which is why the reported stack pointed at
kv_b_proj rather than at the bmm. This is the same root cause as
https://nvbugs/6700707, which reached it via generation CUDA-graph capture.
Densify the LHS on those architectures so a non-TMA kernel is selected,
mirroring the existing SM120 accommodation in fp8_block_scaling_bmm_out.

Also keep the host_total_kv_lens save as a value copy: host_total_kv_lens[0]
returns a 0-d view aliasing the element the chunk loop overwrites in place, so
the post-loop restore wrote the last chunk's value back into itself and left the
context total-KV length under-reported.

Unwaive the two guided_decoding_4gpus mtp_nextn=2 cases the fault was masking.

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4f68f237-bbb7-4270-823f-cf258fac25dc

📥 Commits

Reviewing files that changed from the base of the PR and between 01dc618 and 01b13ab.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/modules/mla.py
  • tests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

The change fixes KV-length restoration during chunked prefill, makes BF16 BMM inputs contiguous on SM120/121, and removes two DeepSeekV3Lite guided-decoding test waivers.

Changes

MLA attention validation

Layer / File(s) Summary
MLA runtime fixes
tensorrt_llm/_torch/modules/mla.py
The chunked-prefill loop snapshots host_total_kv_lens[0] as a scalar. SM120/121 paths make BF16 BMM inputs contiguous before fallback BMM execution.
Guided-decoding test enablement
tests/integration/test_lists/waives.txt
The skip waivers for four-GPU DeepSeekV3Lite tests using llguidance and xgrammar are removed.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 01b13

The change restores chunked-prefill KV-length state correctly and applies the SM120/121 BF16 BMM layout workaround, with no remaining merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the NVBugs fix and the main change: making the BMM LHS contiguous on SM120/121. It is specific and related to the primary code change.
Description check ✅ Passed The description explains the root cause, fix, affected GPUs, test command, regression checks, and bug link. It does not use the template's exact Description, Test Coverage, and PR Checklist headings, …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the root cause, fix, affected GPUs, test command, regression checks, and bug link. It does not use the template's exact Description, Test Coverage, and PR Checklist headings, and it does not include the formal checklist, but the required technical context is mostly complete.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants