Skip to content

[None][fix] Fix Qwen3.5 weight-load memory growth and MTP CUTLASS fallback - #16936

Merged
Wanli-Jiang merged 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/fix-qwen35-bugs
Jul 29, 2026
Merged

[None][fix] Fix Qwen3.5 weight-load memory growth and MTP CUTLASS fallback#16936
Wanli-Jiang merged 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/fix-qwen35-bugs

Conversation

@Wanli-Jiang

@Wanli-Jiang Wanli-Jiang commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Weights were never released during load, so host RSS grew for the whole load and OOM-killed ranks packed onto one node. Three causes: preprocess_weights dropped the ConsumableWeightsDict wrapper, making mark_consumed a no-op; mark_consumed(name) then over-consumed the whole subtree, leaving descendant modules uninitialized (garbage output); and the source dict pinned the tensors the derived dict aliases. Peak host RSS per rank: ~212 -> ~133 GiB.

Also narrow Qwen3NextMTP's unquantized-MoE probe to exclusions that actually cover the routed experts; checkpoints keeping them in FP8 block scales were forced onto the SM90-only CUTLASS fp8_blockscale GEMM and aborted on Blackwell.

Dev Engineer Review

  • Preserves ConsumableWeightsDict through Qwen3.5 weight preprocessing, preventing premature loss of consumable-memory behavior.
  • Extends ConsumableWeightsDict with thread-safe helpers: clear() (drop remaining underlying references under lock) and mark_consumed_keys(keys) -> int (consume only explicitly provided exact keys under lock).
  • Improves weight-loading correctness by tracking and consuming only the parameter keys actually copied/loaded per module:
    • Avoids broad subtree consumption after the manual-copy path.
    • Uses a sentinel to indicate full-subtree coverage when a module’s own load_weights handles the load.
  • Prevents lingering references to potentially aliased/routed-expert tensors by clearing the original weights object after weight_mapper.preprocess_weights returns.
  • Refines Qwen3NextMTP MTP exclude_modules matching so routed experts (mlp.experts) are correctly considered covered by exclusions, avoiding unsupported CUTLASS FP8 block-scale GEMM fallback on Blackwell.
  • No configuration changes identified in the provided diff summary; test handling changes are limited to loader logic.

QA Engineer Review

No test changes.

Description

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-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.

@Wanli-Jiang
Wanli-Jiang requested a review from a team as a code owner July 28, 2026 07:08
@Wanli-Jiang
Wanli-Jiang requested a review from aswinvisva July 28, 2026 07:08
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 5f24cb6c-854e-4348-ba94-a3afdf065982

📥 Commits

Reviewing files that changed from the base of the PR and between f230ad5 and 350848c.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/models/checkpoints/base_weight_loader.py
  • tensorrt_llm/_torch/models/checkpoints/hf/qwen3_5_weight_mapper.py
  • tensorrt_llm/_torch/models/modeling_qwen3_next.py
  • tensorrt_llm/_torch/models/modeling_utils.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • tensorrt_llm/_torch/models/checkpoints/base_weight_loader.py
  • tensorrt_llm/_torch/models/modeling_qwen3_next.py
  • tensorrt_llm/_torch/models/checkpoints/hf/qwen3_5_weight_mapper.py
  • tensorrt_llm/_torch/models/modeling_utils.py

Walkthrough

Weight loading now supports thread-safe clearing and exact-key consumption, preserves consumable wrappers through Qwen3.5 preprocessing, refines MTP expert exclusion matching, and releases original preprocessed weight references.

Changes

Weight consumption and Qwen3.5 loading

Layer / File(s) Summary
Consumable weight operations and wrapper preservation
tensorrt_llm/_torch/models/checkpoints/base_weight_loader.py, tensorrt_llm/_torch/models/checkpoints/hf/qwen3_5_weight_mapper.py
Adds locked clearing and exact-key consumption, and preserves ConsumableWeightsDict through Qwen3.5 preprocessing.
Exact-key consumption during module loading
tensorrt_llm/_torch/models/modeling_utils.py
Tracks manually copied parameters and consumes either full subtrees or only the loaded parameter keys.
Qwen3.5 MTP handling and input cleanup
tensorrt_llm/_torch/models/modeling_qwen3_next.py
Refines routed-expert quantization exclusion matching and clears original weights after preprocessing when supported.

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

Suggested reviewers: aswinvisva

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main changes and follows the required [None][fix] format.
Description check ✅ Passed The description clearly explains the issue and fix, but the Test Coverage section is empty.
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.

@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/checkpoints/base_weight_loader.py`:
- Around line 83-95: Update mark_consumed_keys by annotating keys as
Iterable[str] and documenting it with Google-style Args and Returns sections,
describing the exact keys consumed and the number of deleted weights; preserve
the existing deletion behavior.
🪄 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: 1bc44873-3c70-4a44-b564-0ae113b81ace

📥 Commits

Reviewing files that changed from the base of the PR and between 6219c2e and f230ad5.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/models/checkpoints/base_weight_loader.py
  • tensorrt_llm/_torch/models/checkpoints/hf/qwen3_5_weight_mapper.py
  • tensorrt_llm/_torch/models/modeling_qwen3_next.py
  • tensorrt_llm/_torch/models/modeling_utils.py

Comment thread tensorrt_llm/_torch/models/checkpoints/base_weight_loader.py
…lback

Weights were never released during load, so host RSS grew for the whole load
and OOM-killed ranks packed onto one node. Three causes: preprocess_weights
dropped the ConsumableWeightsDict wrapper, making mark_consumed a no-op;
mark_consumed(name) then over-consumed the whole subtree, leaving descendant
modules uninitialized (garbage output); and the source dict pinned the tensors
the derived dict aliases. Peak host RSS per rank: ~212 -> ~133 GiB.

Also narrow Qwen3NextMTP's unquantized-MoE probe to exclusions that actually
cover the routed experts; checkpoints keeping them in FP8 block scales were
forced onto the SM90-only CUTLASS fp8_blockscale GEMM and aborted on Blackwell.

Signed-off-by: Wanli Jiang <35160485+Wanli-Jiang@users.noreply.github.com>
@Wanli-Jiang
Wanli-Jiang force-pushed the user/williamj/fix-qwen35-bugs branch from f230ad5 to 350848c Compare July 28, 2026 07:13
@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62148 [ run ] triggered by Bot. Commit: 350848c Link to invocation

@yechank-nvidia yechank-nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we add test for loader change?

Comment thread tensorrt_llm/_torch/models/modeling_qwen3_next.py
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62148 [ run ] completed with state SUCCESS. Commit: 350848c
/LLM/main/L0_MergeRequest_PR pipeline #50324 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

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62200 [ run ] triggered by Bot. Commit: 350848c Link to invocation

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot --help

@github-actions

Copy link
Copy Markdown

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental) --high-priority]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Supports wildcard * for pattern matching (e.g., "*PerfSanity*" matches all stages containing PerfSanity). Examples: "A10-PyTorch-1, xxx", "PerfSanity". The patterns "*", "*Post-Merge*", and "*PerfSanity*", including equivalent escaped or repeated-star forms and their use in comma-separated lists, require the ci: post-merge approved PR label. Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline. Requires the ci: post-merge approved PR label applied by an active member of NVIDIA/trt-llm-ci-approvers. The approval label remains in place when new commits are pushed.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Supports wildcard * for pattern matching. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx", --extra-stage "Post-Merge". The patterns "*", "*Post-Merge*", and "*PerfSanity*", including equivalent escaped or repeated-star forms and their use in comma-separated lists, require the ci: post-merge approved PR label.

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

--high-priority (OPTIONAL) : Run the pipeline with high priority. This option is restricted to authorized users only and will route the job to a high-priority queue.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62428 [ run ] triggered by Bot. Commit: 350848c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62200 [ run ] completed with state ABORTED. Commit: 350848c

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62428 [ run ] completed with state SUCCESS. Commit: 350848c
/LLM/main/L0_MergeRequest_PR pipeline #50586 completed with status: 'SUCCESS'

CI Report

Link to invocation

@Wanli-Jiang
Wanli-Jiang merged commit 2341c70 into NVIDIA:main Jul 29, 2026
10 checks passed
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