Skip to content

[None][fix] Use HND mapping for MiniMax-M3 MSA KV cache - #17374

Merged
peihu-nv merged 6 commits into
NVIDIA:mainfrom
peihu-nv:codex/port-pr17011-main-20260806
Sep 4, 2026
Merged

[None][fix] Use HND mapping for MiniMax-M3 MSA KV cache#17374
peihu-nv merged 6 commits into
NVIDIA:mainfrom
peihu-nv:codex/port-pr17011-main-20260806

Conversation

@peihu-nv

@peihu-nv peihu-nv commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Dev Engineer Review

  • MiniMax-M3 MSA uses HND cache views with the INDEXED mapper.
  • Triton continues to use NHD.
  • Index-K remains REPLICATED.
  • Optional layout arguments default to the selected backend layout.
  • NVFP4 scale-pool handling remains restricted to Triton/NHD.
  • No configuration or test-list files changed.
  • Python compilation and changed-file pre-commit checks passed.
  • CUDA transfer validation requires GPU CI and runtime bindings.

QA Engineer Review

Test functions added or modified:

  • test_minimax_m3_msa_hnd_head_mismatch_transfer
  • test_minimax_disagg_role_mapper_kinds
  • Layout-aware MiniMax-M3 KV-transfer coverage
  • MiniMax pool-matching test description

tests/integration/test_lists/test-db/l0_h100.yml includes unittest/disaggregated/test_minimax_m3_kv_transfer.py, which covers the KV-transfer test module. No separate qa/ entry covers these tests.

Verdict: sufficient. GPU CI is still required to validate the TP1-to-TP4 transfer path.

Description

MiniMax-M3 MSA stores its main paged K/V cache in HND layout, but disaggregated KV transfer declared the cache as NHD. This causes head-mismatched context and generation parallelism to use the wrong transfer mapping.

Select the INDEXED mapper and HND cache views for MSA while preserving the existing NHD behavior for the Triton backend. Add focused TP1-to-TP4 transfer coverage for the MSA path. MiniMax-M3 MSA uses FP8 rather than NVFP4 KV cache, so NVFP4 scale-pool handling remains explicitly scoped to the Triton/NHD path.

Test Coverage

  • Added MSA HND FP8 KV-transfer coverage for TP1 context to TP4 generation, with request metadata updated both before and after transfer.
  • Added mapper-selection coverage for Triton/NHD and MSA/INDEXED.
  • Homebrew Python 3.12 syntax compilation passed for all changed Python files.
  • Changed-file pre-commit checks passed, including Ruff, Ruff format, codespell, and repository validation hooks.
  • CUDA transfer test not run locally; requires GPU CI and TensorRT-LLM runtime bindings.

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-compatible or api-breaking. For api-breaking, include BREAKING in 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.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 315cf155-e803-4fe3-8097-f6d53ee03d59

📥 Commits

Reviewing files that changed from the base of the PR and between 42903f9 and f760363.

📒 Files selected for processing (5)
  • tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.py
  • tensorrt_llm/_torch/disaggregation/resource/page.py
  • tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
  • tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py
  • tests/unittest/disaggregated/test_pool_matching.py
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/unittest/disaggregated/test_pool_matching.py
  • tensorrt_llm/_torch/disaggregation/resource/page.py
  • tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
  • tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py
  • tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.py

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


Walkthrough

MiniMax M3 cache management now selects NHD or HND layouts from the attention implementation. Mapper kinds, buffer access, KV-transfer test setup, and verification follow the selected layout.

Changes

MiniMax M3 KV layout handling

Layer / File(s) Summary
Backend layout and mapper selection
tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.py, tensorrt_llm/_torch/disaggregation/resource/page.py, tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
The manager selects HND for MSA and NHD otherwise. MapperKind.HND aliases the existing indexed mapping. Mapper kinds, documentation, and optional buffer-layout arguments follow the selected layout.
Layout-aware test setup and verification
tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py
Test managers, cache data, NVFP4 scales, and KV comparisons now support HND and NHD layouts.
Backend-specific transfer coverage
tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py, tests/unittest/disaggregated/test_pool_matching.py
Tests cover Triton/NHD and MSA/HND mappings, FP8 MSA/HND transfers, and the MiniMax M3 Triton shape description.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to f7603

This PR narrows MiniMax-M3 MSA KV-cache transfers to the correct HND mapping while preserving existing Triton behavior; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant ContextManager
  participant GenerationManager
  participant KVTransferTest
  ContextManager->>GenerationManager: transfer layout-specific KV buffers
  GenerationManager->>KVTransferTest: expose transferred buffers
  KVTransferTest->>KVTransferTest: compare HND or NHD slices
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 5 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 and concisely describes the main change: using HND mapping for MiniMax-M3 MSA KV cache.
Description check ✅ Passed The description explains the issue, solution, test coverage, and known GPU test limitation. The checklist is included and marked as reviewed. The API-change checklist item does not state whether an ap…
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 issue, solution, test coverage, and known GPU test limitation. The checklist is included and marked as reviewed. The API-change checklist item does not state whether an api-compatible label was added, but the description is otherwise 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py`:
- Around line 101-109: Add type annotations to all newly changed functions:
annotate the parametrized arguments of test_minimax_disagg_role_mapper_kinds and
the parameters of its nested fake_base_init, then annotate
update_before_transfer as bool in
tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py at lines 101-109 and
660 respectively.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f3f6b46b-52f1-4280-9113-7c8a73bd351d

📥 Commits

Reviewing files that changed from the base of the PR and between f12c5e5 and a435608.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.py
  • tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
  • tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py
  • tests/unittest/disaggregated/test_pool_matching.py

Comment thread tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py
@peihu-nv

peihu-nv commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64698 [ run ] triggered by Bot. Commit: 7245457 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64698 [ run ] completed with state SUCCESS. Commit: 7245457
/LLM/main/L0_MergeRequest_PR pipeline #52553 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@peihu-nv

peihu-nv commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Removed the "ci: full pre-merge approved" label because @peihu-nv could not be verified as an active member of NVIDIA/trt-llm-ci-approvers. Ask a member of that team to apply it.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64747 [ run ] triggered by Bot. Commit: 7245457 Link to invocation

@peihu-nv

peihu-nv commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --only-multi-gpu-test

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64748 [ run ] triggered by Bot. Commit: 7245457 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64747 [ run ] completed with state ABORTED. Commit: 7245457

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64748 [ run ] completed with state FAILURE. Commit: 7245457
/LLM/main/L0_MergeRequest_PR pipeline #52598 (Partly Tested) completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

Comment thread tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.py Outdated
Signed-off-by: peihengh <259410613+peihu-nv@users.noreply.github.com>
Signed-off-by: peihengh <259410613+peihu-nv@users.noreply.github.com>
Signed-off-by: peihengh <259410613+peihu-nv@users.noreply.github.com>
@peihu-nv
peihu-nv force-pushed the codex/port-pr17011-main-20260806 branch from 7245457 to df50617 Compare August 17, 2026 20:20
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@peihu-nv

Copy link
Copy Markdown
Collaborator Author

/bot run --add-multi-gpu-test

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #66852 [ run ] triggered by Bot. Commit: df50617 Link to invocation

@peihu-nv

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68921 [ run ] triggered by Bot. Commit: fbc95d7 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68921 [ run ] completed with state FAILURE. Commit: fbc95d7
/LLM/main/L0_MergeRequest_PR pipeline #56306 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@peihu-nv

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69231 [ run ] triggered by Bot. Commit: fbc95d7 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69231 [ run ] completed with state SUCCESS. Commit: fbc95d7
/LLM/main/L0_MergeRequest_PR pipeline #56599 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@peihu-nv

peihu-nv commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70757 [ run ] triggered by Bot. Commit: fbc95d7 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70757 [ run ] completed with state FAILURE. Commit: fbc95d7
/LLM/main/L0_MergeRequest_PR pipeline #57949 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@peihu-nv

peihu-nv commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70796 [ run ] triggered by Bot. Commit: fbc95d7 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70796 [ run ] completed with state SUCCESS. Commit: fbc95d7
/LLM/main/L0_MergeRequest_PR pipeline #57982 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@peihu-nv

peihu-nv commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70817 [ run ] triggered by Bot. Commit: fbc95d7 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70817 [ run ] completed with state SUCCESS. Commit: fbc95d7
/LLM/main/L0_MergeRequest_PR pipeline #58000 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@peihu-nv

peihu-nv commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71028 [ run ] triggered by Bot. Commit: f760363 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71028 [ run ] completed with state FAILURE. Commit: f760363
/LLM/main/L0_MergeRequest_PR pipeline #58183 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@peihu-nv

peihu-nv commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71066 [ run ] triggered by Bot. Commit: f760363 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71066 [ run ] completed with state FAILURE. Commit: f760363
/LLM/main/L0_MergeRequest_PR pipeline #58219 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@peihu-nv

peihu-nv commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71193 [ run ] triggered by Bot. Commit: f760363 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71193 [ run ] completed with state SUCCESS. Commit: f760363
/LLM/main/L0_MergeRequest_PR pipeline #58332 completed with status: 'SUCCESS'

CI Report

Link to invocation

@peihu-nv
peihu-nv enabled auto-merge (squash) September 3, 2026 15:12
@peihu-nv
peihu-nv merged commit 8da2ed1 into NVIDIA:main Sep 4, 2026
11 checks passed
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.

6 participants