Skip to content

[https://nvbugs/6417488][fix] Rename M3 override to _prepare_page_table_tensor(index_mapper_capacity) and… - #15984

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

[https://nvbugs/6417488][fix] Rename M3 override to _prepare_page_table_tensor(index_mapper_capacity) and…#15984
trtllm-agent wants to merge 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6417488

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: PR [None][feat] DSv4 follow-up: runtime KV and cache foundations #15633 renamed base hook _build_pool_mapping_tensors → _prepare_page_table_tensor; MiniMaxM3KVCacheManagerV2 override still used the old name, so it never ran and the base's exact_div asserted on M3's INDEX_KEY-coalesced 3x pool stride.
  • Fix: Rename M3 override to _prepare_page_table_tensor(index_mapper_capacity) and populate the base's full state contract (kv_cache_pool_pointers, kv_cache_pool_mapping, index_scales, kv_offset, host_kv_cache_block_offsets); compute per-layer offset from layer_grouping position instead of via the broken exact_div.
  • 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

Dev Engineer Review

  • Added MiniMaxVLLayerNorm, which skips reset_parameters.
  • Updated MiniMax M3 vision encoder layers and transformer pre-layer normalization to use the new class.
  • Removed the GB300 TestMiniMaxM3::test_nvfp4[use_msa=False] waiver for NVBug 6422502.
  • The source change is consistent with the stated LayerNorm initialization requirement.
  • The waiver removal expands GB300 test coverage, but the provided information does not confirm that the underlying issue is resolved on all supported configurations.
  • Comments report that the KV-cache fix still has a runtime incompatibility involving num_blocks_per_seq. This requires follow-up with the proper fix from PR #16218.

QA Engineer Review

  • Modified tests/integration/test_lists/waives.txt.
  • Removed the GB300 waiver for TestMiniMaxM3::test_nvfp4[use_msa=False].
  • No test functions were added, modified, or removed.
  • QA verification completed successfully.
  • CBTS coverage data was not provided.

Verdict: needs follow-up

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

MiniMax-M3 vision normalization now uses MiniMaxVLLayerNorm, which preserves nn.LayerNorm behavior while skipping parameter reset initialization. The related GB300 NVFP4 test waiver was removed.

Changes

MiniMax-M3 vision normalization

Layer / File(s) Summary
LayerNorm subclass and vision integration
tensorrt_llm/_torch/models/modeling_minimaxm3_vl.py
Adds MiniMaxVLLayerNorm and uses it in the vision encoder and vision transformer pre-layer normalization.
GB300 test waiver removal
tests/integration/test_lists/waives.txt
Removes the TestMiniMaxM3::test_nvfp4[use_msa=False] skip entry associated with NVBug 6422502.

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

Possibly related PRs

Suggested reviewers: brnguyen2, schetlur-nv, bowenfu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main fix: renaming the MiniMax M3 override to the new page-table preparation hook.
Description check ✅ Passed The description explains the root cause and fix, lists test verification, and links the bug, although it omits the template's formal checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

zheyuf added a commit to zheyuf/TensorRT-LLM that referenced this pull request Jul 8, 2026
Running upstream PR NVIDIA#15984's variant (which keeps the base V-K stride
derivation for kv_offset) against MiniMax-M3 at TP4 showed the
derivation does NOT assert on coalesced pools — our comment's claimed
justification was wrong. The real reason for pinning zero: no M3
consumer reads the value, and zero keeps init independent of the base's
stride assumptions.

Signed-off-by: Zheyu Fu <zheyuf@NVIDIA.com>
@liji-nv
liji-nv force-pushed the repair-bot-bug6417488 branch from 2f0c920 to b9d6414 Compare July 9, 2026 11:00
@liji-nv

liji-nv commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58453 [ run ] triggered by Bot. Commit: b9d6414 Link to invocation

@liji-nv

liji-nv commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

My local try shows this change does not solve all the problem.

MiniMaxM3KVCacheManagerV2._get_batch_cache_indices_by_pool_id()
got an unexpected keyword argument 'num_blocks_per_seq'

@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 `@tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.py`:
- Around line 435-443: The MinimaxM3 cache manager override is bypassing the
base SWA scratch-copy setup, so the scratch-reuse tensors are never initialized
when enable_swa_scratch_reuse is enabled. In CacheManager’s override where
host_kv_cache_block_offsets is allocated, make sure to preserve the base hook
behavior by calling _prepare_swa_scratch_copy_tensors(index_mapper_capacity) on
the enabled path, or otherwise delegate to the base initialization before
returning, so later scratch-reuse code in CacheManager and related SWA paths can
find the expected tensors.
🪄 Autofix (Beta)

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: 9dce3103-99a0-4840-98a3-6ed2447e3d1a

📥 Commits

Reviewing files that changed from the base of the PR and between d8c3ef4 and fa43f8d.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.py

Comment thread tensorrt_llm/_torch/attention_backend/sparse/minimax_m3/cache_manager.py Outdated
@liji-nv

liji-nv commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58461 [ run ] triggered by Bot. Commit: 59133cb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58453 [ run ] completed with state ABORTED. Commit: b9d6414

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58461 [ run ] completed with state SUCCESS. Commit: 59133cb
/LLM/main/L0_MergeRequest_PR pipeline #47072 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

@liji-nv

liji-nv commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Waiting #16218 for a more proper fix.

@liji-nv liji-nv self-assigned this Jul 13, 2026
@liji-nv
liji-nv force-pushed the repair-bot-bug6417488 branch from 59133cb to 339132d Compare July 16, 2026 07:34
@liji-nv
liji-nv requested review from a team as code owners July 16, 2026 07:34
@liji-nv
liji-nv force-pushed the repair-bot-bug6417488 branch from 4803c16 to 70034ff Compare July 16, 2026 07:55
liji-nv referenced this pull request Jul 16, 2026
Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
@liji-nv
liji-nv force-pushed the repair-bot-bug6417488 branch from 70034ff to 89ffcfd Compare July 17, 2026 02:46
@liji-nv

liji-nv commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59844 [ run ] triggered by Bot. Commit: 89ffcfd Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59844 [ run ] completed with state SUCCESS. Commit: 89ffcfd
/LLM/main/L0_MergeRequest_PR pipeline #48250 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

@BowenFu BowenFu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — the M3-specific override rename fixes a silently-dead hook (exact_div assert); the base kv_cache_manager_v2 change swaps try/except-KeyError for an all_buffer_ids membership check that is behavior-preserving — default non-sparse models still return None. Covered by a new unit test.

@nvpohanh
nvpohanh requested a review from yizhang-nv July 24, 2026 08:15
@nvpohanh

Copy link
Copy Markdown
Collaborator

[by Codex] @yizhang-nv Could you please review this PR? Thank you!

@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6417488 branch 2 times, most recently from 27dfb12 to ca863cf Compare July 29, 2026 05:20
@trtllm-agent
trtllm-agent requested a review from a team as a code owner July 29, 2026 05:20
@trtllm-agent
trtllm-agent requested a review from crazydemo July 29, 2026 05:20
@nvpohanh

Copy link
Copy Markdown
Collaborator

[by Codex] @yizhang-nv Friendly review reminder: this PR is awaiting your review. Thanks!

@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6417488 branch from ca863cf to d373326 Compare August 2, 2026 14:53
@trtllm-agent
trtllm-agent requested a review from a team as a code owner August 2, 2026 14:53
@crazydemo

Copy link
Copy Markdown
Collaborator

/bot run --only-qa-verify

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63371 [ run ] triggered by Bot. Commit: d373326 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63371 [ run ] completed with state SUCCESS. Commit: d373326
LLM_FUNCTION_AUTO_V2C #344 completed with status: 'SUCCESS'
QA verify (empty customized_test_list) (NVBug 6417488, branch repair-bot-bug6417488, fork tensorrt-cicd, dry_run_close=true)

Link to invocation

@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6417488 branch from d373326 to 41a28d1 Compare August 3, 2026 06:36
…tMode

MiniMaxVLVisionTransformer built plain nn.LayerNorm modules, whose
reset_parameters() calls init.ones_/init.zeros_ -> aten.fill_.Scalar.
That op is not on MetaInitMode's allowlist, so building the model raised
MetaInitException at pre_layrnorm and model_loader fell back to regular
init, materializing the whole 233 GB checkpoint on the host per rank.

Add MiniMaxVLLayerNorm, an nn.LayerNorm subclass whose reset_parameters()
is a no-op, and use it at all three vision-tower LN sites. This follows
the existing NemotronLayerNormPlus1 convention. All 130 vision LN tensors
are present in the checkpoint, so the loaded weights supply the values the
skipped init would have written; state_dict keys and forward numerics are
unchanged.

Meta-init now succeeds for the full model (params meta: 1290, cpu: 697 --
24.0 GB materialized of 233.1 GB total).

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6417488 branch from 41a28d1 to 1562764 Compare August 5, 2026 14:59
@coderabbitai

coderabbitai Bot commented Aug 5, 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.

@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 `@tensorrt_llm/_torch/models/modeling_minimaxm3_vl.py`:
- Around line 1184-1197: Update MiniMaxVLLayerNorm.reset_parameters to
initialize affine parameters during ordinary construction while skipping
initialization under MetaInitMode; use the existing mode-detection mechanism and
standard LayerNorm initialization behavior. Ensure incomplete strict=False VL
checkpoint loads cannot reach forward with undefined normalization weights, and
add coverage for both meta and non-meta construction paths.
🪄 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: e254b143-6671-4098-9133-1f2b7cbf890e

📥 Commits

Reviewing files that changed from the base of the PR and between d010c62 and 1562764.

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

Comment on lines +1184 to +1197
class MiniMaxVLLayerNorm(nn.LayerNorm):
"""``nn.LayerNorm`` whose parameter init is skipped under ``MetaInitMode``.

``nn.LayerNorm.reset_parameters`` calls ``init.ones_``/``init.zeros_``,
which lower to ``aten.fill_.Scalar``. That op is not on ``MetaInitMode``'s
allowlist, so a plain ``nn.LayerNorm`` anywhere in the module tree raises
``MetaInitException`` and forces the whole model onto the regular-init
path (a full host copy of the checkpoint). Every LN tensor here is
present in the checkpoint, so the loaded weights supply the values the
skipped init would have written.
"""

def reset_parameters(self) -> None:
pass

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Expected: every construction path reaches a complete checkpoint load
# before the first forward through MiniMaxVLLayerNorm.
rg -n -C 8 \
  'MiniMaxVLLayerNorm|MiniMaxVLVisionTransformer|load_state_dict|strict\s*=|MetaInitMode'

Repository: NVIDIA/TensorRT-LLM

Length of output: 157


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="tensorrt_llm/_torch/models/modeling_minimaxm3_vl.py"

printf '%s\n' '--- candidate symbols ---'
rg -n -C 6 'MiniMaxVLLayerNorm|MiniMaxVLVisionTransformer|MetaInitMode|load_state_dict|load_checkpoint|state_dict' "$file" || true

printf '%s\n' '--- repository references ---'
rg -n -C 4 'MiniMaxVLLayerNorm|MiniMaxVLVisionTransformer|MetaInitMode' tensorrt_llm tests examples || true

printf '%s\n' '--- relevant source ranges ---'
sed -n '1,80p' "$file"
sed -n '1140,1320p' "$file"

Repository: NVIDIA/TensorRT-LLM

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- tracked files related to MiniMaxM3 ---'
git ls-files | rg -i 'minimax|vl' | head -200

printf '%s\n' '--- LayerNorm construction and loading APIs ---'
rg -n -C 5 'LayerNorm|load_state_dict|load_checkpoint|from_pretrained|state_dict' tensorrt_llm/_torch/models tensorrt_llm/_torch | head -500

Repository: NVIDIA/TensorRT-LLM

Length of output: 47777


🏁 Script executed:

#!/bin/bash
set -euo pipefail

model="tensorrt_llm/_torch/models/modeling_minimaxm3_vl.py"
test="tests/unittest/_torch/models/test_minimax_m3_vl.py"

printf '%s\n' '--- MiniMax vision model and loader ---'
sed -n '1525,1720p' "$model"

printf '%s\n' '--- MiniMax VL tests ---'
rg -n -C 12 'MiniMaxVLLayerNorm|MiniMaxVLVisionModel|load_minimax_m3_vl_state_dict|load_state_dict|forward|missing|strict' "$test"

printf '%s\n' '--- all call sites of the custom loader ---'
rg -n -C 8 'load_minimax_m3_vl_state_dict|MiniMaxVLVisionModel' tensorrt_llm tests

Repository: NVIDIA/TensorRT-LLM

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- model loader integration for MiniMax M3 VL ---'
rg -n -C 12 'minimax|load_weights|vision_tower|load_state_dict' tensorrt_llm/_torch/pyexecutor/model_loader.py tensorrt_llm/_torch/models/modeling_minimaxm3.py tensorrt_llm/_torch/models/modeling_minimaxm3_vl.py

printf '%s\n' '--- MetaInitMode behavior and materialization ---'
sed -n '45,135p' tensorrt_llm/_torch/models/modeling_utils.py
rg -n -C 10 'is_meta_init|MetaInitMode|materialize|load_weights' tensorrt_llm/_torch/pyexecutor/model_loader.py

Repository: NVIDIA/TensorRT-LLM

Length of output: 50376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="tensorrt_llm/_torch/models/modeling_minimaxm3.py"

printf '%s\n' '--- VL-specific symbols in modeling_minimaxm3.py ---'
rg -n 'MiniMaxM3VL|vision_tower|MiniMaxVLVisionModel|load_minimax|split_multimodal|_VL_PREFIXES|load_weights' "$file"

printf '%s\n' '--- focused VL sections ---'
python3 - <<'PY'
from pathlib import Path

path = Path("tensorrt_llm/_torch/models/modeling_minimaxm3.py")
lines = path.read_text().splitlines()
needles = ("vision_tower", "MiniMaxVLVisionModel", "load_minimax_m3_vl_state_dict",
           "split_multimodal_weights", "def load_weights", "class MiniMaxM3")
for i, line in enumerate(lines, 1):
    if any(n in line for n in needles):
        start = max(1, i - 18)
        end = min(len(lines), i + 35)
        print(f"\n--- lines {start}-{end} ---")
        for j in range(start, end + 1):
            print(f"{j}: {lines[j-1]}")
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- production VL load path ---'
sed -n '2108,2160p' tensorrt_llm/_torch/models/modeling_minimaxm3.py
sed -n '2190,2245p' tensorrt_llm/_torch/models/modeling_minimaxm3.py

printf '%s\n' '--- construction and forward tests without a complete load ---'
sed -n '140,230p' tests/unittest/_torch/models/test_minimax_m3_vl.py
sed -n '298,370p' tests/unittest/_torch/models/test_minimax_m3_vl.py
sed -n '711,742p' tests/unittest/_torch/models/test_minimax_m3_vl.py

printf '%s\n' '--- source-only verifier for custom LayerNorm usage ---'
python3 - <<'PY'
import ast
from pathlib import Path

paths = [
    Path("tensorrt_llm/_torch/models/modeling_minimaxm3_vl.py"),
    Path("tests/unittest/_torch/models/test_minimax_m3_vl.py"),
]
for path in paths:
    tree = ast.parse(path.read_text(), filename=str(path))
    print(f"\n{path}")
    for node in ast.walk(tree):
        if isinstance(node, ast.ClassDef) and node.name == "MiniMaxVLLayerNorm":
            print("custom class:", node.lineno)
        if isinstance(node, ast.Call):
            func = node.func
            if isinstance(func, ast.Name) and func.id == "MiniMaxVLLayerNorm":
                print("construction:", node.lineno, "in", type(next(
                    (p for p in ast.walk(tree)
                     if isinstance(p, (ast.FunctionDef, ast.AsyncFunctionDef))
                     and p.lineno <= node.lineno <= getattr(p, "end_lineno", p.lineno)),
                    ast.Module
                )).__name__)
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 13610


Initialize MiniMaxVLLayerNorm outside MetaInitMode. reset_parameters() leaves torch.empty affine parameters undefined during normal construction. The VL loader also uses strict=False, so partial loads can reach forward() with missing normalization weights. Initialize non-meta parameters, or reject incomplete loads before forward. Add tests for both paths.

🤖 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 `@tensorrt_llm/_torch/models/modeling_minimaxm3_vl.py` around lines 1184 -
1197, Update MiniMaxVLLayerNorm.reset_parameters to initialize affine parameters
during ordinary construction while skipping initialization under MetaInitMode;
use the existing mode-detection mechanism and standard LayerNorm initialization
behavior. Ensure incomplete strict=False VL checkpoint loads cannot reach
forward with undefined normalization weights, and add coverage for both meta and
non-meta construction paths.

Source: MCP tools

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.

8 participants