[None][fix] Use HND mapping for MiniMax-M3 MSA KV cache - #17374
Conversation
Signed-off-by: peihengh <259410613+peihu-nv@users.noreply.github.com>
WalkthroughMiniMax M3 cache management now selects NHD or HND layouts from the attention implementation. Mapper kinds, buffer access, KV-transfer test setup, and verification now follow the selected layout. ChangesMiniMax M3 KV layout handling
Estimated code review effort: 3 (Moderate) | ~20 minutes 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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.pytensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.pytests/unittest/disaggregated/test_minimax_m3_kv_transfer.pytests/unittest/disaggregated/test_pool_matching.py
| def test_minimax_disagg_role_mapper_kinds( | ||
| monkeypatch, implementation, expected_main_mapper | ||
| ) -> None: | ||
| def fake_base_init(self, *args, **kwargs): | ||
| self.is_disagg = kwargs.get("is_disagg", False) | ||
| self.dtype = kwargs.get("dtype", DataType.BF16) | ||
| self.layer_offsets = {} | ||
| self.max_batch_size = 1 | ||
| self.max_seq_len = 1 |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add required annotations to new test functions.
Both changed test functions add unannotated parameters. fake_base_init is also new without annotations.
tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py#L101-L109: Annotate the parametrized test arguments andfake_base_init.tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py#L660-L660: Annotateupdate_before_transferasbool.
As per coding guidelines, annotate every function.
📍 Affects 1 file
tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py#L101-L109(this comment)tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py#L660-L660
🤖 Prompt for 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.
In `@tests/unittest/disaggregated/test_minimax_m3_kv_transfer.py` around lines 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.
Source: Coding guidelines
Dev Engineer Review
INDEXEDmapper.REPLICATED.QA Engineer Review
Test functions added or modified:
test_minimax_msa_hnd_head_mismatch_transfertest_minimax_disagg_role_mapper_kindsThese tests are not covered by
tests/integration/test_lists/test-db/orqa/entries in this change.Verdict: needs follow-up. GPU CI coverage is required to validate the TP1 context-to-TP4 generation 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
INDEXEDmapper 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
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.