Skip to content

[TRTLLM-14879][feat] qualify Qwen2 dense for MX - #16974

Merged
chienchunhung merged 7 commits into
NVIDIA:mainfrom
chienchunhung:codex/mx-qwen2-dense
Aug 19, 2026
Merged

[TRTLLM-14879][feat] qualify Qwen2 dense for MX#16974
chienchunhung merged 7 commits into
NVIDIA:mainfrom
chienchunhung:codex/mx-qwen2-dense

Conversation

@chienchunhung

@chienchunhung chienchunhung commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a fail-closed post-transform qualification profile for Qwen2 and Qwen2.5 dense target models.
  • Qualify BF16, unquantized TRT-LLM attention configurations for TP1 and TP2 while rejecting unsupported runtime topologies and features.
  • Add rank-local lifecycle equivalence, support-matrix, missing-runtime, and source-identity ABI coverage.
  • Bound the existing Llama profile to the same evidence-backed BF16 TP1/TP2 envelope instead of leaving its runtime dimensions unconstrained.
  • Preserve the lazy model-zoo import path added on main; Qwen2 is imported only when the post-transform profile registry is first used.

Scope

  • Supports exact Qwen2ForCausalLM roots, including Qwen2.5 dense checkpoints using that architecture.
  • Supports target-model post-transform transfer with BF16, no weight or KV-cache quantization, TRT-LLM attention, TP1 or TP2, and PP1/CP1/EP1 on one node.
  • Unsupported combinations fail closed, including FP16, quantization, speculative decoding, LoRA, sparse attention, attention data parallelism, multi-node execution, tied embeddings, YaRN, unfused RoPE, and parallel dimensions outside the qualified matrix.
  • Does not change ModelExpress transport, discovery, publication, cleanup, or dependency versions.

Merge Order

  1. Merge the independent GPU qualification harness in [TRTLLM-14727][test] Create MX donor-receiver qualification test harness #17222.
  2. Rebase this PR onto the resulting main, add representative Qwen2 TP1/TP2 MxE2ECase rows, and run both dedicated ModelExpress stages.
  3. Merge this PR before [MX-299][feat] Delegate MX loading to ModelExpress strategies #17029 so the adapter migration must preserve both Llama and Qwen2 qualification profiles and revalidate them against the released upstream client.

Validation

  • Full pre-commit suite over all eight changed files - passed after rebasing onto main at ac54855177.
  • Python syntax compilation for all changed Python modules and tests - passed.
  • Code-owner self-review - clean after adapting the registry and tests to lazy model imports and requiring explicit runtime constraints for every profile.
  • Focused unit execution - pending PR CI because the local Python environment does not contain the TRT-LLM runtime dependencies.
  • Qwen2 real-GPU donor/receiver TP1 and TP2 qualification - pending [TRTLLM-14727][test] Create MX donor-receiver qualification test harness #17222 merge and harness enrollment.

Dev Engineer Review

  • Added fail-closed runtime qualification for Qwen2 and Qwen2.5 dense BF16 models.
  • Restricted Llama and Qwen2 profiles to supported unquantized TRT-LLM configurations.
  • Added runtime constraint matching, mismatch reporting, overlap validation, and Qwen2 ABI identity support.
  • Preserved lazy model-zoo imports and ModelExpress transport behavior.
  • No configuration or test-list files changed.
  • Pre-commit and syntax checks passed.
  • CI runs failed, including the partly tested package-sanity run. The failures require investigation.
  • Focused unit tests and GPU qualification remain pending because local runtime dependencies and the GPU harness are unavailable.

QA Engineer Review

Test-code changes were made in:

  • tests/unittest/_torch/executor/test_model_loader_gms.py
    • Modified the tiny profile fixture to include runtime constraints.
  • tests/unittest/_torch/executor/test_model_loader_mx.py
    • Added Llama and Qwen2 lifecycle qualification tests.
    • Added dense and TP2 fixtures.
    • Added rejection tests for unsupported runtime settings.
    • Added coverage for dense profiles with MoE-only settings.
  • tests/unittest/_torch/weight_sharing/test_post_transform_profiles.py
    • Added runtime matching, mismatch, missing-configuration, profile-selection, overlap, topology, and constraint-validation tests.
  • tests/unittest/_torch/weight_sharing/test_source_identity.py
    • Added Llama and Qwen2 transform-ABI identity tests.

No files under tests/integration/test_lists/ were changed. Coverage in test-db/ and qa/ was not provided. The failed CI runs and pending GPU qualification require follow-up.

Verdict: needs follow-up

@chienchunhung chienchunhung changed the title [TRTLLM-12352][feat] qualify Qwen2 dense for MX [TRTLLM-14747][feat] qualify Qwen2 dense for MX Jul 29, 2026
@chienchunhung chienchunhung changed the title [TRTLLM-14747][feat] qualify Qwen2 dense for MX [TRTLLM-14727][feat] qualify Qwen2 dense for MX Jul 29, 2026
@chienchunhung
chienchunhung force-pushed the codex/mx-qwen2-dense branch from 0be1ea9 to 5d670c8 Compare July 31, 2026 19:36
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63111 [ run ] triggered by Bot. Commit: 5d670c8 Link to invocation

@chienchunhung chienchunhung changed the title [TRTLLM-14727][feat] qualify Qwen2 dense for MX [TRTLLM-14879][feat] qualify Qwen2 dense for MX Jul 31, 2026
@chienchunhung
chienchunhung force-pushed the codex/mx-qwen2-dense branch from 5d670c8 to 9a24d26 Compare July 31, 2026 23:35
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63111 [ run ] completed with state FAILURE. Commit: 5d670c8
/LLM/main/L0_MergeRequest_PR pipeline #51202 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

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: f7ff3e5a-4d52-43f7-9186-dfe193c2b2fb

📥 Commits

Reviewing files that changed from the base of the PR and between d9cf85a and 0e7dae7.

📒 Files selected for processing (1)
  • tests/unittest/_torch/executor/test_model_loader_mx.py

Walkthrough

Post-transform MX reception now qualifies exact dense BF16 Llama and Qwen2 profiles against normalized runtime constraints. ModelLoader passes runtime configuration, reports unsupported dimensions, and documents supported profiles and exclusions. Tests cover lifecycle, matching, and rejection paths.

Changes

Post-transform runtime qualification

Layer / File(s) Summary
Runtime configuration and qualification contracts
tensorrt_llm/_torch/weight_sharing/post_transform_profiles.py, tensorrt_llm/_torch/weight_sharing/__init__.py
Adds normalized runtime configuration, constraint matching, overlap validation, mismatch reporting, and the Qwen2 dense ABI export.
Constrained registry matching and MX wiring
tensorrt_llm/_torch/weight_sharing/post_transform_profiles.py, tensorrt_llm/_torch/pyexecutor/model_loader.py
Registers constrained Llama and Qwen2 profiles. ModelLoader passes runtime configuration to qualification and reports unsupported dimensions.
Qualification behavior tests
tests/unittest/_torch/weight_sharing/test_post_transform_profiles.py
Tests runtime extraction, matching, missing configuration, disjoint profiles, overlap rejection, topology detection, and constraint validation.
Llama and Qwen2 MX lifecycle coverage
tests/unittest/_torch/executor/test_model_loader_mx.py, tests/unittest/_torch/executor/test_model_loader_gms.py
Adds BF16 fixtures, tensor-parallel lifecycle tests, fused-layout checks, explicit runtime constraints, and unsupported-runtime rejection tests.
ABI validation and support documentation
tests/unittest/_torch/weight_sharing/test_source_identity.py, docs/source/features/model-express.md
Validates both transform ABI identifiers and documents supported profiles, exclusions, and fallback behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Mergeability Score: ⚪ Minimal · up to 0e7da

The PR adds narrowly scoped qualification behavior and test coverage; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: schetlur-nv

Sequence Diagram(s)

sequenceDiagram
  participant ModelLoader
  participant RuntimeConfig
  participant ProfileRegistry
  participant MXReceiver
  ModelLoader->>RuntimeConfig: derive normalized runtime dimensions
  ModelLoader->>ProfileRegistry: qualify model and runtime configuration
  ProfileRegistry-->>ModelLoader: return profile or unsupported dimensions
  ModelLoader->>MXReceiver: reject or skip publish with qualification details
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required ticket and feature format and clearly identifies the primary change: Qwen2 dense qualification for MX.
Description check ✅ Passed The description clearly explains the scope, supported and rejected configurations, validation status, merge order, and test coverage.
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: 4

🧹 Nitpick comments (2)
tests/unittest/_torch/executor/test_model_loader_mx.py (1)

664-670: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align the CPU-only marker between the new Llama and Qwen2 TP2 tests.

test_qwen2_dense_profile_qualifies_tp2_rank_lifecycle has @pytest.mark.cpu_only, but the new Llama TP2 test does not. Both fixtures build models on CPU and stub the distributed pieces. If the Llama path is also CPU-only, add the marker so both tests select the same CI stage.

🤖 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/_torch/executor/test_model_loader_mx.py` around lines 664 -
670, Determine whether
test_default_profile_qualifies_real_tiny_llama_tp2_rank_lifecycle uses the same
CPU-only setup as test_qwen2_dense_profile_qualifies_tp2_rank_lifecycle; if so,
add pytest.mark.cpu_only to the Llama test decorator so both TP2 lifecycle tests
run in the same CI stage.
tensorrt_llm/_torch/pyexecutor/model_loader.py (1)

369-424: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the shared BF16 dense constraint set.

The two PostTransformRuntimeConstraints blocks are identical. A future envelope change must be edited in two places, and a partial edit silently diverges the Llama and Qwen2 profiles. Define the envelope once at module or class scope and reference it from both profiles.

Note the profiles constrain moe_tp_sizes and moe_ep_sizes but no moe_backend dimension. If that omission is intentional for dense models, a short comment on the shared constant records the decision.

♻️ Proposed refactor sketch
+_BF16_DENSE_TP2_RUNTIME_CONSTRAINTS = PostTransformRuntimeConstraints(
+    dtypes=frozenset({"bfloat16"}),
+    quant_algorithms=frozenset({"none"}),
+    kv_cache_quant_algorithms=frozenset({"none"}),
+    layerwise_quantization=frozenset({False}),
+    force_dynamic_quantization=frozenset({False}),
+    lora_enabled=frozenset({False}),
+    sparse_attention_enabled=frozenset({False}),
+    attention_backends=frozenset({"TRTLLM"}),
+    tp_sizes=frozenset({1, 2}),
+    pp_sizes=frozenset({1}),
+    cp_sizes=frozenset({1}),
+    moe_tp_sizes=frozenset({1, 2}),
+    moe_ep_sizes=frozenset({1}),
+    attention_tp_sizes=frozenset({1, 2}),
+    attention_cp_sizes=frozenset({1}),
+    attention_dp=frozenset({False}),
+    multi_node=frozenset({False}),
+    tied_word_embeddings=frozenset({False}),
+    rope_types=frozenset({"default"}),
+    rope_fusion=frozenset({True}),
+)

Then each profile uses runtime_constraints=_BF16_DENSE_TP2_RUNTIME_CONSTRAINTS.

🤖 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/pyexecutor/model_loader.py` around lines 369 - 424,
Extract the identical BF16 dense runtime constraint set into a shared module- or
class-level constant, such as _BF16_DENSE_TP2_RUNTIME_CONSTRAINTS, and reference
it from both Llama and Qwen2 PostTransformProfile definitions. Preserve every
existing constraint value; add a brief comment documenting the intentional
absence of a moe_backend dimension if applicable.
🤖 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 `@docs/source/features/model-express.md`:
- Around line 55-60: Update the exclusion-list wording in the Llama and Qwen2
profiles section to specify that only PP, CP, and EP values greater than 1
require separate qualification, preserving support for the documented default
value of 1.
- Around line 23-29: Update the Qwen2 qualification profile documentation to
explicitly include Qwen2.5 only if it uses the same Qwen2ForCausalLM/qwen2 root
and configuration profile; otherwise narrow the stated support to the variants
actually implemented. Align the table’s model/config identity and the Qwen2
fallback limitation so they provide consistent guidance, using the verified
mapping and existing QWEN2_DENSE_POST_TRANSFORM_LAYOUT_ABI_V1 support as the
reference.

In `@tensorrt_llm/_torch/pyexecutor/model_loader.py`:
- Around line 1235-1244: Update the logger.info call in the MX post-transform
publish skip path to pass a single preformatted f-string, preserving the
existing model name, qualification reason, and unsupported-runtime-dimensions
values while removing printf-style placeholders.

In `@tests/unittest/_torch/weight_sharing/test_post_transform_profiles.py`:
- Around line 354-357: Update the match pattern in the pytest.raises call around
the duplicate post-transform profile test to use a raw regular-expression
string, preserving the existing regex and error assertion.

---

Nitpick comments:
In `@tensorrt_llm/_torch/pyexecutor/model_loader.py`:
- Around line 369-424: Extract the identical BF16 dense runtime constraint set
into a shared module- or class-level constant, such as
_BF16_DENSE_TP2_RUNTIME_CONSTRAINTS, and reference it from both Llama and Qwen2
PostTransformProfile definitions. Preserve every existing constraint value; add
a brief comment documenting the intentional absence of a moe_backend dimension
if applicable.

In `@tests/unittest/_torch/executor/test_model_loader_mx.py`:
- Around line 664-670: Determine whether
test_default_profile_qualifies_real_tiny_llama_tp2_rank_lifecycle uses the same
CPU-only setup as test_qwen2_dense_profile_qualifies_tp2_rank_lifecycle; if so,
add pytest.mark.cpu_only to the Llama test decorator so both TP2 lifecycle tests
run in the same CI stage.
🪄 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: 118b4daf-a686-441c-ba01-d2628ac9208b

📥 Commits

Reviewing files that changed from the base of the PR and between ac54855 and a647578.

📒 Files selected for processing (8)
  • docs/source/features/model-express.md
  • tensorrt_llm/_torch/pyexecutor/model_loader.py
  • tensorrt_llm/_torch/weight_sharing/__init__.py
  • tensorrt_llm/_torch/weight_sharing/post_transform_profiles.py
  • tests/unittest/_torch/executor/test_model_loader_gms.py
  • tests/unittest/_torch/executor/test_model_loader_mx.py
  • tests/unittest/_torch/weight_sharing/test_post_transform_profiles.py
  • tests/unittest/_torch/weight_sharing/test_source_identity.py

Comment thread docs/source/features/model-express.md Outdated
Comment thread docs/source/features/model-express.md
Comment thread tensorrt_llm/_torch/pyexecutor/model_loader.py Outdated
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #65144 [ run ] triggered by Bot. Commit: bcfb6a7 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #65144 [ run ] completed with state FAILURE. Commit: bcfb6a7
/LLM/main/L0_MergeRequest_PR pipeline #52938 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>
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #66846 [ run ] triggered by Bot. Commit: 843b315 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #66846 [ run ] completed with state FAILURE. Commit: 843b315
/LLM/main/L0_MergeRequest_PR pipeline #54407 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 --stage-list "DGX_B200-PyTorch-6"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #66936 [ run ] triggered by Bot. Commit: 843b315 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #66936 [ run ] completed with state SUCCESS. Commit: 843b315
/LLM/main/L0_MergeRequest_PR pipeline #54488 (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 #66974 [ run ] triggered by Bot. Commit: 843b315 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #66974 [ run ] completed with state FAILURE. Commit: 843b315
/LLM/main/L0_MergeRequest_PR pipeline #54522 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ 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

Link to invocation

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67146 [ run ] triggered by Bot. Commit: 843b315 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67146 [ run ] completed with state FAILURE. Commit: 843b315
/LLM/main/L0_MergeRequest_PR pipeline #54679 completed with status: 'UNSTABLE'

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

Link to invocation

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --stage-list "GB200-4_GPUs-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67503 [ run ] triggered by Bot. Commit: 843b315 Link to invocation

@chienchunhung
chienchunhung enabled auto-merge (squash) August 19, 2026 16:49
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67503 [ run ] completed with state SUCCESS. Commit: 843b315
/LLM/main/L0_MergeRequest_PR pipeline #54998 (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 #67523 [ run ] triggered by Bot. Commit: 843b315 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67523 [ run ] completed with state SUCCESS. Commit: 843b315
/LLM/main/L0_MergeRequest_PR pipeline #55017 completed with status: 'SUCCESS'

CI Report

Link to invocation

@chienchunhung
chienchunhung merged commit b4ee1b4 into NVIDIA:main Aug 19, 2026
11 checks passed
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.

4 participants