Skip to content

[https://nvbugs/6691772][fix] Update trtllm-gen fmha autotuner to enable 96 head MLA (cherry-pick #18599) - #20469

Merged
pengbowang-nv merged 1 commit into
NVIDIA:release/1.3from
pengbowang-nv:dev-cherry-pick-pr18599-release-1.3
Oct 19, 2026

Conversation

@pengbowang-nv

@pengbowang-nv pengbowang-nv commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Cherry-pick 4dee061 from main (#18599) to release/1.3.

Enable Kimi K3 H96 MLA through the updated legacy TRTLLM-Gen path, reject unsupported FlashInfer TRTLLM-Gen head counts, and update CuTe DSL selection and regression coverage.

The required FMHA artifacts are already included in release/1.3 via #19956. No cubins or static libraries are changed.

Resolved one comment-only conflict in modeling_kimi_linear.py, preserving the release branch's cache-manager description.

Test Coverage

  • Backport: pre-commit checks, Python AST parsing, and git diff --check passed.
  • Main PR: CI #64551 passed. B200 validation passed 60 tests, including H96 Q1/Q3 with page sizes 32/64, numerical reference checks, and CUDA Graph execution.
  • Additional main validation: four FP8 KV8192 cases passed across B7/B8 with autotuning enabled/disabled.

PR Checklist

  • Description explains the change and cherry-pick origin.
  • Coding guidelines and static checks reviewed.
  • Regression tests included.
  • No public API, dependency, or ownership changes.
  • Documentation updated as needed.

GitHub Bot Help

Available CI commands: /bot help.

Dev Engineer Review

  • The backend now routes MLA workloads with 64 < num_heads < 128 away from FlashInfer TRTLLM-Gen. The fallback is the updated legacy TRTLLM-Gen path, which enables Kimi K3 H96 MLA. This range also includes H80, so verify that fallback support and performance are acceptable for other models in the range.
  • CuTe DSL MLA now allows H96 Q1 decode only at batch sizes of 8 or more. It rejects mixed context/generation batches for all head counts.
  • The Kimi K3 examples retain tokens_per_block: 64, but describe it as a validated setting rather than a hard requirement. The default remains unchanged.
  • The release backport’s GPU tests have not been rerun. The reported main-branch validation does not establish release-branch results.

QA Engineer Review

  • Modified tests: tests/unittest/_torch/attention/test_attention_backends.py adds test_trtllm_mla_kimi_k3_h96; tests/unittest/_torch/attention/test_fmha_page_index.py adds mixed-batch, unsupported-head-range, and range-boundary checks, and updates existing gate-test inputs.
  • The Kimi K3 regression covers H96, Q1/Q3, page sizes 32/64, batch size 32, and bfloat16; it is gated to SM100/SM103 and exercises TRTLLM backend selection. The page-index tests verify CuTe DSL mixed-batch rejection and FlashInfer TRTLLM-Gen head-count gating.
  • No matching test entries were found in tests/integration/test_lists/test-db/ or tests/integration/test_lists/qa/. These are unit tests, not integration tests; the existing Kimi K3 integration harness has no corresponding test-list change.
  • Coverage verdict: needs follow-up. The reported main-branch GPU coverage is useful, but the release backport still needs GPU validation.

Per-File QA Perspective

  • docs/source/deployment-guide/deployment-guide-for-kimi-k3-on-trtllm.md — Clarifies that 64 is validated, not a current hard requirement. QA should verify that instructions match the supported page-size behavior.
  • examples/kimi_k3/disagg/README.md — Separates current constraints from the historical page-size reason. No runtime setting changed.
  • examples/kimi_k3/disagg/benchmark_kimi_k3_dep16.yaml — Comments change only; tokens_per_block remains 64.
  • examples/kimi_k3/disagg/ctx_config.yaml — Comments change only; cache and scheduler settings remain unchanged.
  • examples/kimi_k3/disagg/gen_config.yaml — Comments change only; tokens_per_block remains 64.
  • examples/kimi_k3/disagg/gen_config_no_sa.yaml — Comments change only; tokens_per_block remains 64.
  • tensorrt_llm/_torch/attention/backends/fmha/cute_dsl_mla.py — H96 Q1 decode uses an increased batch threshold, and mixed context/generation batches now decline CuTe DSL for every head count.
  • tensorrt_llm/_torch/attention/backends/fmha/flashinfer_trtllm_gen.py — The support check now accepts num_heads and declines H65–H127 MLA generation so selection can use the legacy backend.
  • tensorrt_llm/_torch/models/modeling_kimi_linear.py — Updates the default-setting rationale; tokens_per_block=64 remains unchanged.
  • tests/integration/defs/kimi_k3_sa_harness.py — Updates the rationale for the established page size. The integration harness still uses 64.
  • tests/unittest/_torch/attention/test_attention_backends.py — Adds an SM100/SM103 H96 Kimi K3 regression for Q1/Q3 and page sizes 32/64. No matching entry was found in the integration test lists.
  • tests/unittest/_torch/attention/test_fmha_page_index.py — Adds mixed-batch and head-range checks, and updates existing support-gate test inputs. No matching entry was found in the integration test lists.

@pengbowang-nv

Copy link
Copy Markdown
Collaborator Author

/bot run

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/TensorRT-LLM/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 99b1adb6-6ccf-4d4d-b6a5-0e215d18a42a
📥 Commits

Reviewing files that changed from the base of the PR and between aca95ff and fdc983a.

📒 Files selected for processing: 12
  • docs/source/deployment-guide/deployment-guide-for-kimi-k3-on-trtllm.md
  • examples/kimi_k3/disagg/README.md
  • examples/kimi_k3/disagg/benchmark_kimi_k3_dep16.yaml
  • examples/kimi_k3/disagg/ctx_config.yaml
  • examples/kimi_k3/disagg/gen_config.yaml
  • examples/kimi_k3/disagg/gen_config_no_sa.yaml
  • tensorrt_llm/_torch/attention/backends/fmha/cute_dsl_mla.py
  • tensorrt_llm/_torch/attention/backends/fmha/flashinfer_trtllm_gen.py
  • tensorrt_llm/_torch/models/modeling_kimi_linear.py
  • tests/integration/defs/kimi_k3_sa_harness.py
  • tests/unittest/_torch/attention/test_attention_backends.py
  • tests/unittest/_torch/attention/test_fmha_page_index.py

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

Walkthrough

The change updates MLA backend support checks for Kimi K3’s 96 query heads, adds regression tests for backend selection and CuTe DSL batch handling, and revises documentation and example comments about the retained tokens_per_block: 64 setting.

Changes

Kimi K3 MLA backend support and page-size guidance

Layer / File(s) Summary
TRTLLM-Gen MLA generation support
tensorrt_llm/_torch/attention/backends/fmha/flashinfer_trtllm_gen.py, tensorrt_llm/_torch/models/modeling_kimi_linear.py, tests/integration/defs/kimi_k3_sa_harness.py, tests/unittest/_torch/attention/test_attention_backends.py
The FlashInfer TRTLLM-Gen check rejects MLA generation requests with more than 64 and fewer than 128 heads. The regression test covers Kimi K3 H96 cases across query lengths 1 and 3 and page sizes 32 and 64. Comments describe the H96 behavior.
CuTe DSL MLA gates
tensorrt_llm/_torch/attention/backends/fmha/cute_dsl_mla.py, tests/unittest/_torch/attention/test_fmha_page_index.py
The FP8 performance threshold for 96-head decode changes, and mixed context/generation batches are rejected. Tests cover mixed batches, head counts 80 and 96, and boundary counts 64 and 128.
Kimi K3 page-size guidance
docs/source/deployment-guide/deployment-guide-for-kimi-k3-on-trtllm.md, examples/kimi_k3/disagg/*
The documentation and example comments describe tokens_per_block: 64 as a retained, historically validated setting. The configured values remain unchanged.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Suggested reviewers: brnguyen2

Merge Risk: ⚪ Minimal · up to fdc98

The H96 regression exercises the intended fallback, and no actionable issue remains from the reviewed changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (6 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly identifies the fix, the NVBugs ticket, and the main change: enabling 96-head MLA through the TRTLLM-Gen FMHA autotuner. The cherry-pick reference adds useful context.
Description check Passed The description includes the required Description, Test Coverage, and PR Checklist sections. It explains the backport scope, testing results, regression coverage, and API, dependency, ownership, and d…
Full details: Description check

Explanation

The description includes the required Description, Test Coverage, and PR Checklist sections. It explains the backport scope, testing results, regression coverage, and API, dependency, ownership, and documentation impact. Minor template items are summarized rather than listed individually, but the description is complete enough for review.

Full details: Docstring Coverage

Explanation

Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (6 skipped: 6 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@yuxianq

yuxianq commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

@yihwang-nv, could you help to review this PR as trt-llm-torch-attention-devs? Thanks~

Assignment explanation
Componentsfmha/flashinfer-trtllm-gen (40%); fmha/cute-dsl-mla (30%); integration/attention-tests (30%)
Tagsrepresentation:mla (100%); phase:decode (100%); features:quantization (40%); features:paged-kv (30%); features:cuda-graphs (30%); context:llm (100%)
PR effort4 points — Moderate cross-component selection fix requiring review of head-count boundaries, legacy fallback compatibility, mixed-batch routing, and the FP8 threshold alongside numerical regressions. The visible changes introduce neither a model architecture nor a kernel algorithm.
ImportanceImportant — Sensitive correctness and performance routing changes: FlashInfer rejects intermediate MLA head counts, while CuTe DSL changes H96 mixed-batch eligibility and the FP8 batch threshold. These gates determine which implementation must safely execute affected workloads.
Affinity (0–1)0.631 component/tag match; 0.473 after PIC preference
Outstanding points at selection55 → 59 (+4)
Points already reserved on this PR0
Effective weight1
Completed review points (preceding 168 hours)39
Combined points after assignment98
Demand-derived target96.33 points (soft share)
Additional fair share before assignment2.33 points
Share explanationWhole PR / qualification or coverage constraint exceeds a soft share; assignment is allowed.
Selection ruleaffinity with 0.3-share guard
Assignment scope (yihwang-nv)all

Affinity and workload are snapshots at selection, not live counters. Existing reservations on this PR are counted once.

@yuxianq
yuxianq requested review from yihwang-nv and removed request for heyuhhh and lfr-0531 October 16, 2026 09:43
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #78452 [ run ] triggered by Bot. Commit: fdc983a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #78452 [ run ] completed with state SUCCESS. Commit: fdc983a
/LLM/release-1.3/L0_MergeRequest_PR pipeline #299 completed with status: 'SUCCESS'

CI Report

Link to invocation

@brnguyen2 brnguyen2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving — the comments below are optional touch-ups, not blockers.

The backport matches main, and the FMHA artifacts it depends on (#19956) are on release/1.3. Two things before merge:

  1. Run GPU CI on this branch. The description says GPU tests have not been rerun on the backport. release/1.3 and main differ in FMHA artifacts and selection code, so main's B200 results don't carry over. test_trtllm_mla_kimi_k3_h96 runs under the unittest/_torch/attention entries in l0_b200.yml/l0_b300.yml, so a /bot run covers it. Please also check that an FP8-KV H96 decode at batch < 8 now goes to the legacy TRTLLM-Gen path. That route is new with this PR (the old threshold was 1), and the new regression test doesn't cover it: the test is bf16 and excludes CuTe DSL from TLLM_FMHA_LIBS.

  2. The comment on the helix carve-out is now outdated. At [tensorrt_llm/_torch/attention/backends/fmha/cute_dsl_mla.py:321](https://github.com/NVIDIA/TensorRT-LLM/pull/20469/files#diff-c21c22ced2fdb7e5b7eed564c2e124bae7c684c997fdeb7ade581ff77654d448R321), it says "TRTLLM-Gen rejects 64 < num_heads_q < 128 outright", and gives that as the reason helix H96 multi-token verify skips the perf gate. With this PR, the legacy TRTLLM-Gen path serves H96 Q3, and the new test covers it. Either update the comment to the actual reason the carve-out stays (for example, the helix softmax-stats requirement), or decide whether the carve-out is still needed. Otherwise a later reader will go by the outdated reason.

@github-actions

Copy link
Copy Markdown

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.

@yuxianq

yuxianq commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

@yuxianq, thanks for picking up this PR! I’ve handed off the trt-llm-torch-attention-devs review from @yihwang-nv to you.

The 4 attention-review points now belong to @yuxianq; @yihwang-nv’s attention reservation has been released. Your review is already submitted, so the points count as completed work; no new review request was added.

@yihwang-nv, no further attention review is requested from you. Thanks~

@yuxianq
yuxianq removed the request for review from yihwang-nv October 19, 2026 03:35
@pengbowang-nv
pengbowang-nv merged commit 07bc962 into NVIDIA:release/1.3 Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants