[None][fix] Keep CuTe-DSL MLA decode for Kimi K3 H=96 speculative-verify batches - #18226
Conversation
…ify batches
The Kimi K3 MLA decode-backend policy kept a requested cute-dsl
backend only for plain single-token decode batches and for mixed
batches with 96 query heads; every other batch shape fell back to
trtllm-gen. Generation-only multi-token batches (speculative
verification, e.g. suffix-automaton drafting) at 96 heads -- K3's
per-rank head count under attention-DP -- were therefore routed to
trtllm-gen, whose decode gate rejects 64 < num_heads_q < 128, and
engine initialization failed:
ValueError: trtllm-gen MLA decode does not support
64 < num_heads_q < 128; got num_heads_q=96.
Apply the H=96 exception to every fallback candidate instead of only
mixed batches, so any batch shape trtllm-gen cannot serve stays on
cute-dsl. Smaller per-rank head counts keep the existing fallback.
Validated on a single B200 (SM100) with the SA harness
(tests/integration/defs/kimi_k3_sa_harness.py) at TP=1 with
attention-DP (96 heads per rank), a 4-layer truncated Kimi-K3,
KIMI_K3_SPEC_MODE=sa and logits-parity checking:
- without this change, the SA engine fails initialization with the
ValueError above (the baseline single-token engine is unaffected);
- with this change, the run passes spec-dec logits parity
(4 prompts, 0 drift).
The unit-test matrix in
tests/unittest/_torch/modules/test_kimi_k3_mla_backend.py passes
12/12 with this change.
Signed-off-by: Michal Guzek <mguzek@nvidia.com>
|
/bot run --disable-fail-fast |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe Kimi K3 MLA backend now keeps H=96 configurations on CuTe-DSL across mixed, attention-DP, and multi-token speculative-verification batches. Tests and developer guidance document this policy. ChangesKimi K3 MLA backend policy
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change is localized and has no actionable merge-blocking risk remaining after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
PR_Github #69336 [ run ] triggered by Bot. Commit: |
|
PR_Github #69336 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #69499 [ run ] triggered by Bot. Commit: |
|
PR_Github #69499 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #69529 [ run ] triggered by Bot. Commit: |
|
PR_Github #69529 [ run ] completed with state |
pengbowang-nv
left a comment
There was a problem hiding this comment.
The changes LGTM but I doubt there are some back-and-forth changes related to this affair. Please confirm with @SimengLiu-nv and @brnguyen2 . Thanks!
Dev Engineer Review
cute-dslfor all configurations with 96 query heads per rank.trtllm-genfallback for smaller per-rank head counts.QA Engineer Review
tests/unittest/_torch/modules/test_kimi_k3_mla_backend.py.cute-dsl.trtllm-gen.tests/integration/test_lists/coverage entry was reported.Description
Stack trace: L0_MergeRequest_PR/56537 → GB300-4_GPUs-PyTorch-Post-Merge-1 → test_kimi_k3_specdec → test_kimi_k3_sa_specdec_logits_parity
Blocks: #17921 — the 4-GPU SA spec-dec logits-parity test wired into the GB300 post-merge stage there fails deterministically with this error (builds 56259 and 56537).
Since the recent MLA decode backend changes on main, Kimi K3 with suffix-automaton (SA) speculative decoding + attention-DP fails deterministically at engine initialization on every rank with:
The non-speculative (baseline) engine with the identical configuration initializes and generates correctly. Only the SA spec-dec engine fails.
Root cause
Interaction of two recent main commits:
_kimi_k3_mla_decode_backend_policy()intensorrt_llm/_torch/modules/kimi_k3_mla/kimi_k3_mla_attention.py.64 < num_heads_q < 128.The policy kept the requested
cute-dslbackend for (a) generation-only single-token batches and (b) mixed batches withnum_heads == 96(its explicit "H=96 correctness exception"). However, for generation-only multi-token batches — which is exactly what SA speculative verification produces — it fell back totrtllm-geneven atnum_heads == 96:With attention-DP each rank keeps the full 96 query heads, so the trtllm-gen path raises the restored gate error at init. The H=96 correctness exception was simply never extended to the spec-verify case (the CuTe-DSL kernel itself accepts multi-token queries; the fallback is a decode-tuning-coverage preference, not a correctness requirement).
The
TLLM_K3_MLA_GEN_BACKENDenvironment variable cannot work around this: the policy downgradescute-dsltotrtllm-genafter the env value is read.Fix
Extend the existing H=96 exception to every fallback candidate: any batch shape with
num_heads == 96stays oncute-dsl— the gate's own error message recommends exactly that — while smaller per-rank head counts keep the existing decode-tuning fallback totrtllm-gen. Also updates the policy-contract paragraph inATTENTION_DEVELOPER_GUIDE.mdand the unit-test matrix (one pre-existing matrix row enshrined the buggy expectation).Impact if unfixed
saleg being added in [TRTLLM-15036][test] Add Kimi K3 GSM8K/MMMU accuracy tests and register them in QA's weekly multinode list #17922 as soon as it runs on a main tree containing the two commits above.Test Coverage
tests/unittest/_torch/modules/test_kimi_k3_mla_backend.py— policy matrix updated: generation-only multi-token at H=96 now expectscute-dsl; an H=12 row was added to prove smaller per-rank head counts keep thetrtllm-genfallback. 12/12 pass.tests/integration/defs/kimi_k3_sa_harness.pyatKIMI_K3_TP=1with attention-DP (96 heads per rank), a 4-layer truncated Kimi-K3,KIMI_K3_SPEC_MODE=sa, logits-parity mode:[sanity] PASS— spec-dec logits parity verified (4 prompts, 0 drift).tests/integration/defs/test_kimi_k3_specdec.py::test_kimi_k3_sa_specdec_logits_parity(the failing GB300 post-merge test from [TRTLLM-15035][test] Wire Kimi K3 spec-dec and suffix-automaton tests into L0 CI #17921) exercises this path on 4 GPUs.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.🤖 Generated with Claude Code