Skip to content

[#20969][fix] Qwen3.5/3.8: default dense NVFP4 checkpoints to Marlin on Ada/Hopper - #21434

Merged
karljang merged 1 commit into
NVIDIA:mainfrom
Smallfu666:fix-qwen35-dense-nvfp4-marlin
Nov 7, 2026
Merged

karljang merged 1 commit into
NVIDIA:mainfrom
Smallfu666:fix-qwen35-dense-nvfp4-marlin

Conversation

@Smallfu666

@Smallfu666 Smallfu666 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #20969: with default settings, RadixArk/Qwen3.8-27B-NVFP4 loads its weights on H200 and then fails at warmup with Arch unsupported for CUTLASS FP4 GEMM. The same defaults apply to every dense Qwen3.5-family NVFP4 or MIXED_PRECISION checkpoint on SM89-99.

#17293 gave the Qwen3.5 MoE classes nvfp4_gemm_config.allowed_backends = ["marlin"] on SM89-99 for NVFP4 / MIXED_PRECISION checkpoints. The dense Qwen3_5ForCausalLM and the VLM wrapper _Qwen3_5VLModel still return the Qwen3-Next defaults, so their NVFP4 linears keep the W4A4 backends that need Blackwell.

This PR splits the helper. _get_qwen35_dense_model_defaults sets the Marlin linear default under the same condition as #17293; the MoE helper calls it and adds moe_config.backend = "MARLIN", so MoE defaults are unchanged. The two dense classes use the dense helper. Other quant algos, Blackwell and a user-set allowed_backends are unchanged.

On 1x H200 (1.4.0rc1.dev202610201007 container, trtllm-serve, TP 1, the reproduction in #20969), with the container's modeling_qwen3_5.py replaced by a copy with this change applied, and no backend setting in the config: the server starts, the NVFP4 linears run MarlinNVFP4LinearMethod, and a small client script scores 92/100 on the first 100 GSM8K test questions (5-shot chat, greedy); in the same job, the same command without the change fails as above.

Not run: H100, Ada, Blackwell, TP > 1, image or video inputs, the nvidia/ and Inferact/ checkpoints on GPU (config files only), accuracy against a BF16 baseline, and the tests on a full checkout of current main with and without this PR.

Test Coverage

  • tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py::test_qwen35_dense_model_defaults (new): NVFP4 on SM89/SM90 and MIXED_PRECISION on SM90 get ["marlin"]; FP8 on SM90, NVFP4 on SM100 and MIXED_PRECISION on SM120 keep the default; both dense classes.
  • ...::test_qwen35_dense_model_defaults_keep_explicit_backends (new): a user-set allowed_backends is kept.
  • ...::test_qwen38_nvfp4_checkpoint_load_applies_hopper_defaults (new): a synthetic 2-layer checkpoint with an hf_quant_config.json cut from the RadixArk (MIXED_PRECISION) and Inferact (NVFP4) checkpoints, loaded through ModelLoader with SM patched to 90, gets ["marlin"]; a user-set value is kept.
  • tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl_moe.py::test_qwen35_moe_model_defaults (existing) still passes.

On CPU (SM monkeypatched, release:1.4.0rc3.dev202611010007 container, whose modeling_qwen3_5.py is main's before #20815, which changed other methods of that file): without the change, the 5 cases that expect ["marlin"] by default fail and the 9 that check unchanged behaviour pass; with it, all 14 pass.

pytest -q tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py::test_qwen35_dense_model_defaults \
  tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py::test_qwen35_dense_model_defaults_keep_explicit_backends \
  tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py::test_qwen38_nvfp4_checkpoint_load_applies_hopper_defaults \
  tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl_moe.py::test_qwen35_moe_model_defaults

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.

Dev Engineer Review

  • Dense Qwen3.5 defaults now select the Marlin NVFP4 GEMM backend for NVFP4 and MIXED_PRECISION checkpoints when the GPU supports NVFP4 Marlin. The dense text model and shared VLM wrapper use these defaults.
  • The MoE helper reuses the dense defaults and retains its MoE backend selection. The reported change preserves other quantization defaults, Blackwell defaults, and explicit allowed_backends.
  • The author reports that an H200 server start and NVFP4 linear warmup succeeded after the change; GSM8K scored 92/100 in the described run. Other GPU architectures and configurations remain unverified.

QA Engineer Review

  • Modified tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py. Added CPU tests for dense and VLM defaults across quantization algorithms and SM versions, explicit backend preservation, and Qwen3.8 NVFP4 checkpoint defaults. The reported test set includes test_qwen35_dense_model_defaults, test_qwen35_dense_model_defaults_keep_explicit_backends, test_qwen38_nvfp4_checkpoint_load_applies_hopper_defaults, and the existing test_qwen35_moe_model_defaults.
  • The author reports that all 14 CPU/SM-monkeypatched cases passed with the change. GPU execution, BF16-baseline accuracy, and a full current-main test run were not reported.
  • No changed integration test or test-list file is reported. Test-list membership does not apply to these unit tests.
  • Coverage verdict: sufficient for default selection and preservation behavior; hardware coverage remains limited.

Per-File QA Perspective

  • tensorrt_llm/_torch/models/modeling_qwen3_5.py: Verify that dense text and VLM defaults select Marlin for NVFP4 and MIXED_PRECISION only on supported SMs, and preserve explicit backends. Verify that MoE defaults retain their existing MoE backend.
  • tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py: Covers dense/VLM defaults, explicit backend preservation, checkpoint quantization configuration, and Hopper defaults. This is a unit-test file, not an integration test-list entry.

Dense Qwen3.5/3.6/3.8 text and VL models inherit the Qwen3-Next
defaults, so NVFP4 and mixed-precision checkpoints keep the default
W4A4 backends on SM89-99, where the CUTLASS FP4 GEMM is unsupported.
Apply the nvfp4_gemm_config Marlin default that the MoE classes already
get.

Signed-off-by: Han-Yin Chang <[email protected]>
@Smallfu666
Smallfu666 requested a review from a team as a code owner November 2, 2026 09:25
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between bdcb577 and c5e8264.

Files selected for processing: 2
  • tensorrt_llm/_torch/models/modeling_qwen3_5.py
  • tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py

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

Walkthrough

Dense Qwen3.5 model defaults now select the Marlin NVFP4 GEMM backend for supported quantization algorithms and SM versions. The shared VLM wrapper uses these defaults. Tests cover default resolution, explicit backend settings, and checkpoint loading.

Changes

Qwen3.5 defaults

Layer / File(s) Summary
Dense model defaults and VLM wiring
tensorrt_llm/_torch/models/modeling_qwen3_5.py
Shared helpers apply dense NVFP4 Marlin defaults when the algorithm and SM support them. MoE defaults extend the dense defaults with the Marlin MoE backend. The dense causal-LM and shared VLM wrapper return the dense defaults.
Default and checkpoint coverage
tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py
CPU tests cover quantization and SM combinations, preservation of explicitly configured GEMM backends, and HF quant-config checkpoint loading.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: moraxu

Merge Risk: Minimal · up to c5e82

Supported Qwen3.5-family NVFP4 checkpoints now default to Marlin; no merge-blocking risk was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the Qwen3.5/3.8 dense NVFP4 default change and the Marlin backend on Ada/Hopper.
Description check Passed The description includes the required sections, explains the issue and solution, documents test coverage and limitations, and includes the repository checklist.
Linked Issues check Passed Directly linked issue #20969 is the only active target. Its coding requirement: dense Qwen3.5-family NVFP4 and MIXED_PRECISION checkpoints on SM89-99 must use Marlin for NVFP4 linears by default, matc…
Out of Scope Changes check Passed All changes at the reviewed head relate to the #20969 objective.

- The modeling change refactors the NVFP4 Marlin condition into _use_nvfp4_marlin. It adds the dense helper and the dense `get_model…
Full details: Linked Issues check

Explanation

Directly linked issue #20969 is the only active target. Its coding requirement: dense Qwen3.5-family NVFP4 and MIXED_PRECISION checkpoints on SM89-99 must use Marlin for NVFP4 linears by default, matching the MoE behavior from #17293.

Code at the reviewed head (tensorrt_llm/_torch/models/modeling_qwen3_5.py):

  • New _use_nvfp4_marlin applies the same quant-algo and is_nvfp4_marlin_supported_sm condition that the MoE helper used before.
  • New _get_qwen35_dense_model_defaults sets nvfp4_gemm_config = {"allowed_backends": ["marlin"]} when that condition holds. It does not set moe_config.
  • New Qwen3_5ForCausalLM.get_model_defaults returns the dense helper output. This covers the dense text class.
  • _Qwen3_5VLModel.get_model_defaults now returns the dense helper output. This covers Qwen3_5VLModel, which the issue reports as the resolved class for RadixArk/Qwen3.8-27B-NVFP4.
  • _get_qwen35_moe_model_defaults calls the dense helper and adds moe_config = {"backend": "MARLIN"} under the same condition. MoE output is unchanged.

Tests at the reviewed head (tests/unittest/_torch/modeling/test_modeling_qwen3_5_vl.py) cover: default selection by quant algo and SM for both dense classes; preservation of a user-set allowed_backends; and a synthetic NVFP4 and MIXED_PRECISION checkpoint loaded through ModelLoader with SM patched to 90. The H200 run and GSM8K score are author-reported. I did not run them. Not verified: GPU behavior on H100, Ada, Blackwell, and the nvidia/ and Inferact/ checkpoints. The issue marks those as not run, and the code path does not depend on them.

No unmet coding requirement found. The issue's non-coding items and the related PR #12591 and bug #20965 are not requested outcomes.

Full details: Out of Scope Changes check

Explanation

All changes at the reviewed head relate to the #20969 objective.

  • The modeling change refactors the NVFP4 Marlin condition into _use_nvfp4_marlin. It adds the dense helper and the dense get_model_defaults override. It repoints _Qwen3_5VLModel.get_model_defaults to the dense helper. These changes implement the requirement directly.
  • The MoE helper now calls the dense helper and adds only the moe_config backend. Its effective output matches the prior MoE helper for every input, so the refactor does not change MoE behavior.
  • The VLM wrapper change does not reach Qwen3_5MoeVLModel. Before this PR, the base wrapper returned Qwen3-Next defaults with no MARLIN MoE backend. The unchanged test_qwen35_moe_model_defaults expects MARLIN for Qwen3_5MoeVLModel, so that class must override get_model_defaults. This is inferred from the existing test. I did not read the MoE class body to confirm it.
  • The test changes add coverage for the dense defaults, explicit-backend preservation, and checkpoint loading. They support the objective and contain no unrelated changes.

No change was found that falls outside the issue scope.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements.

@karljang

karljang commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #83122 [ run ] triggered by Bot. Commit: c5e8264 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #83122 [ run ] completed with state SUCCESS. Commit: c5e8264
/LLM/main/L0_MergeRequest_PR pipeline #68674 completed with status: 'SUCCESS'

CI Report

Link to invocation

@karljang
karljang merged commit bcb64e1 into NVIDIA:main Nov 7, 2026
ziyixiong-nv added a commit to ziyixiong-nv/TensorRT-LLM that referenced this pull request Nov 8, 2026
…in's Qwen3.5-VL test

Main renamed _construct_checkpoint_loader to construct_checkpoint_loader
(NVIDIA#20703), while NVIDIA#21434 added a Qwen3.5-VL test that still imports the old
name, so the whole test module fails to import. The pre-merge H100 stage
runs it, and an x86 single-GPU failure keeps the x86 multi-GPU stages from
running. The renamed helper takes the same keyword arguments.

Signed-off-by: ziyixiong-nv <[email protected]>
ziyixiong-nv added a commit to ziyixiong-nv/TensorRT-LLM that referenced this pull request Nov 8, 2026
…in's Qwen3.5-VL test

Main renamed _construct_checkpoint_loader to construct_checkpoint_loader
(NVIDIA#20703), while NVIDIA#21434 added a Qwen3.5-VL test that still imports the old
name, so the whole test module fails to import. The pre-merge H100 stage
runs it, and an x86 single-GPU failure keeps the x86 multi-GPU stages from
running. The renamed helper takes the same keyword arguments.

Signed-off-by: ziyixiong-nv <[email protected]>
dc3671 added a commit to dc3671/TensorRT-LLM that referenced this pull request Nov 8, 2026
…loader

NVIDIA#20703 renamed _construct_checkpoint_loader; NVIDIA#21434 still imported the old
name, so every unittest/_torch/modeling run failed collection on main.

Signed-off-by: Zhenhuan Chen <[email protected]>
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.

[Bug]: Dense Qwen3.8-27B NVFP4 fails to start on Hopper with default settings (no Marlin default for dense Qwen3.5 classes)

6 participants