Skip to content

[TRTLLM-13248][feat] Wave 3: migrate MoE staged hooks - #15386

Merged
chienchunhung merged 1 commit into
NVIDIA:mainfrom
chienchunhung:codex/staged-hooks-wave3-moe-mamba
Jul 6, 2026
Merged

[TRTLLM-13248][feat] Wave 3: migrate MoE staged hooks#15386
chienchunhung merged 1 commit into
NVIDIA:mainfrom
chienchunhung:codex/staged-hooks-wave3-moe-mamba

Conversation

@chienchunhung

@chienchunhung chienchunhung commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wave 3 of the staged post-load hooks rollout, built on merged Wave 2 / #15288 and rebased onto main.

This migrates the remaining MoE, Mamba, min-latency, and sparse attention post-load work into the staged hook protocol. Tensor-layout and irreversible MoE weight work now lives in transform_weights() behind _weights_transformed, while repeatable Python-side state refresh lives in cache_derived_state(). Existing full-load paths continue to use post_load_weights() as the backward-compatible shim.

What Changed

  • Added staged MoE hooks in MoE and ConfigurableMoE, with transform_weights() guarded by _weights_transformed and cache_derived_state() delegated to the quant method/backend.
  • Split fused-MoE quant-method work so shared-weight finalization and backend-specific transforms run in transform_weights(), while quant scales and load-balancer assignment refresh run in cache_derived_state().
  • Routed CUTLASS, Triton, TRTLLM-Gen, DenseGEMM, WideEP, and MegaMoE backend post-load shims through the staged module hooks.
  • Moved Mamba2, Llama min-latency, and DSA derived-state recomputation into cache_derived_state() while keeping post_load_weights() compatibility shims.
  • Added MoE hook idempotency coverage plus focused DSA and Mamba derived-state tests.

Dependency / prerequisite stack

This PR is Wave 3 in the staged post-load hooks rollout. The foundation PRs and Waves 1-2 (#14770, #14878, #15014, and #15288) are merged. The remaining wave PRs should merge in sequence; after each upstream wave lands, rebase the next wave onto main so review and CI focus on that wave's delta.

Arrows point from prerequisite to dependent. PR numbers in graph nodes are clickable.

graph TD
    PR14770["<a href='https://github.com/NVIDIA/TensorRT-LLM/pull/14770'>#14770</a>: staged-hook contract (merged)"]
    PR14878["<a href='https://github.com/NVIDIA/TensorRT-LLM/pull/14878'>#14878</a>: GMS SourceIdentity gate (merged)"]
    PR15014["<a href='https://github.com/NVIDIA/TensorRT-LLM/pull/15014'>#15014</a>: Wave 1 aliases + GMS RO load (merged)"]
    PR15288["<a href='https://github.com/NVIDIA/TensorRT-LLM/pull/15288'>#15288</a>: Wave 2 Linear/Attention transforms (merged)"]
    PR15386["<a href='https://github.com/NVIDIA/TensorRT-LLM/pull/15386'>#15386</a>: Wave 3 MoE/Mamba staged hooks (this PR, ready for review)"]
    PR15387["<a href='https://github.com/NVIDIA/TensorRT-LLM/pull/15387'>#15387</a>: Wave 4 MX receiver cutover (open, ready for review)"]
    PR15432["<a href='https://github.com/NVIDIA/TensorRT-LLM/pull/15432'>#15432</a>: Wave 5 MX publisher + Llama receiver (open, ready for review)"]
    VERIFY["post-migration verification / demo (planned)"]

    PR14770 -->|satisfied| PR15014
    PR14878 -->|satisfied| PR15014
    PR15014 -->|satisfied| PR15288
    PR15288 -->|satisfied| PR15386
    PR15386 -->|blocking| PR15387
    PR15387 -->|blocking| PR15432
    PR15432 -.->|planned| VERIFY

    classDef merged fill:#dcfce7,stroke:#16a34a,color:#14532d;
    classDef inflight fill:#dbeafe,stroke:#2563eb,color:#1e3a8a;
    classDef current fill:#ede9fe,stroke:#7c3aed,color:#3b0764,stroke-width:3px;
    classDef downstream fill:#f3f4f6,stroke:#6b7280,color:#374151,stroke-dasharray:5 5;
    linkStyle 0,1,2,3 stroke:#16a34a,stroke-width:2px;
    linkStyle 4,5 stroke:#ea580c,stroke-width:3px;
    linkStyle 6 stroke:#6b7280,stroke-width:2px,stroke-dasharray:5 5;

    class PR14770,PR14878,PR15014,PR15288 merged;
    class PR15387,PR15432 inflight;
    class PR15386 current;
    class VERIFY downstream;
Loading

Immediate merge dependency satisfied: #15288 merged on 2026-06-26, and this branch is rebased onto main so the PR diff is the Wave 3 delta.

Test Plan

  • git diff --check origin/codex/staged-hooks-wave2-transform-weights..HEAD
  • python -m py_compile tensorrt_llm/_torch/attention_backend/sparse/dsa.py tensorrt_llm/_torch/models/modeling_llama_min_latency.py tensorrt_llm/_torch/modules/fused_moe/configurable_moe.py tensorrt_llm/_torch/modules/fused_moe/fused_moe_cute_dsl_b12x.py tensorrt_llm/_torch/modules/fused_moe/fused_moe_cutlass.py tensorrt_llm/_torch/modules/fused_moe/fused_moe_densegemm.py tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py tensorrt_llm/_torch/modules/fused_moe/interface.py tensorrt_llm/_torch/modules/fused_moe/mega_moe/mega_moe_deepgemm.py tensorrt_llm/_torch/modules/fused_moe/quantization.py tensorrt_llm/_torch/modules/mamba/mamba2_mixer.py tests/unittest/_torch/attention/sparse/test_dsa_indexer.py tests/unittest/_torch/modules/moe/test_moe_backend.py tests/unittest/_torch/modules/mamba/test_mamba2_mixer.py
  • Pre-commit on commit: isort, yapf, ruff, ruff-format, codespell, DCO, and other applicable hooks passed. waive list check and validate-test-lists were skipped because the hook runtime fails in scripts/check_test_list.py on str | None before inspecting this diff.
  • Focused pytest attempted but blocked in this macOS shell because transformers is not installed and the local torch package lacks nn / distributed.

Next Steps

Summary by CodeRabbit

  • Refactor

    • Restructured internal weight loading and model initialization lifecycle management across model backends for improved code organization and maintainability.
  • Tests

    • Added unit tests validating weight transformation and state caching behavior.

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54355 [ run ] triggered by Bot. Commit: e378d6d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54355 [ run ] completed with state SUCCESS. Commit: e378d6d
/LLM/main/L0_MergeRequest_PR pipeline #43426 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

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --stage-list "L0_Test-x86_64-Single-GPU, L0_Test-SBSA-Single-GPU"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54368 [ run ] triggered by Bot. Commit: e378d6d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54368 [ run ] completed with state FAILURE. Commit: e378d6d
/LLM/main/L0_MergeRequest_PR pipeline #43438 (Partly Tested) 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

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54372 [ run ] triggered by Bot. Commit: e378d6d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54372 [ run ] completed with state FAILURE. Commit: e378d6d
/LLM/main/L0_MergeRequest_PR pipeline #43442 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

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@chienchunhung
chienchunhung requested a review from Funatiq June 16, 2026 05:44
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54488 [ run ] triggered by Bot. Commit: 32646d9 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54488 [ run ] completed with state SUCCESS. Commit: 32646d9
/LLM/main/L0_MergeRequest_PR pipeline #43551 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

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --stage-list "A100X-PyTorch-1,DGX_B200-PyTorch-2,H100_PCIe-AutoDeploy-1,DGX_B200-8_GPUs-PyTorch-1,DGX_H100-2_GPUs-PyTorch-Others-2"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54633 [ run ] triggered by Bot. Commit: 32646d9 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54633 [ run ] completed with state SUCCESS. Commit: 32646d9
/LLM/main/L0_MergeRequest_PR pipeline #43665 (Partly Tested) completed with status: 'SUCCESS'

CI Report

Link to invocation

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54669 [ run ] triggered by Bot. Commit: 32646d9 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54669 [ run ] completed with state SUCCESS. Commit: 32646d9
/LLM/main/L0_MergeRequest_PR pipeline #43701 completed with status: 'SUCCESS'

CI Report

Link to invocation

@chienchunhung
chienchunhung marked this pull request as ready for review June 22, 2026 18:03
@chienchunhung
chienchunhung requested review from a team as code owners June 22, 2026 18:03
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57215 [ run ] triggered by Bot. Commit: 9a30e43 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57211 [ run ] completed with state ABORTED. Commit: 9a30e43

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57215 [ run ] completed with state SUCCESS. Commit: 9a30e43
/LLM/main/L0_MergeRequest_PR pipeline #45987 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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57267 [ run ] triggered by Bot. Commit: 9a30e43 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57267 [ run ] completed with state FAILURE. Commit: 9a30e43

Link to invocation

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

3 similar comments
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57275 [ run ] triggered by Bot. Commit: 9a30e43 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57275 [ run ] completed with state FAILURE. Commit: 9a30e43
/LLM/main/L0_MergeRequest_PR pipeline #46037 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

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung
chienchunhung force-pushed the codex/staged-hooks-wave3-moe-mamba branch from 9a30e43 to 7963f1a Compare July 4, 2026 17:38
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57571 [ run ] triggered by Bot. Commit: 7963f1a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57571 [ run ] completed with state SUCCESS. Commit: 7963f1a
/LLM/main/L0_MergeRequest_PR pipeline #46299 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

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57683 [ run ] triggered by Bot. Commit: 7963f1a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57683 [ run ] completed with state FAILURE. Commit: 7963f1a
/LLM/main/L0_MergeRequest_PR pipeline #46403 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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57801 [ run ] triggered by Bot. Commit: 7963f1a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57801 [ run ] completed with state SUCCESS. Commit: 7963f1a
/LLM/main/L0_MergeRequest_PR pipeline #46498 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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57809 [ run ] triggered by Bot. Commit: 7963f1a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57809 [ run ] completed with state SUCCESS. Commit: 7963f1a
/LLM/main/L0_MergeRequest_PR pipeline #46506 completed with status: 'SUCCESS'

CI Report

Link to invocation

@chienchunhung
chienchunhung merged commit 9f689ec into NVIDIA:main Jul 6, 2026
7 checks passed
BrianLi23 pushed a commit to BrianLi23/TensorRT-LLM that referenced this pull request Jul 9, 2026
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
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.

4 participants