Skip to content

[None][feat] Delegate MX loading to ModelExpress strategies - #17029

Open
zhengluo-nv wants to merge 3 commits into
NVIDIA:mainfrom
zhengluo-nv:zheluo/mx-strategy-chain-bridge
Open

[None][feat] Delegate MX loading to ModelExpress strategies#17029
zhengluo-nv wants to merge 3 commits into
NVIDIA:mainfrom
zhengluo-nv:zheluo/mx-strategy-chain-bridge

Conversation

@zhengluo-nv

@zhengluo-nv zhengluo-nv commented Jul 29, 2026

Copy link
Copy Markdown

Description

TensorRT-LLM already owns the checkpoint_format="MX" entry point, compatibility
identity, Llama post-transform qualification, and post-load lifecycle. Its MX
checkpoint loader still duplicated source discovery, NIXL transfer, fallback,
publication, and cleanup behavior that ModelExpress shares with vLLM and
SGLang.

This change keeps the TensorRT-LLM-owned lifecycle and delegates the transport
workflow to modelexpress.engines.trtllm.MxModelLoader:

TensorRT-LLM keeps ModelExpress owns
Model construction and native HF mapping Shared load-strategy ordering
Authoritative SourceIdentity Compatible source discovery and retry
Llama post-transform qualification NIXL RDMA receive and native fallback selection
Receiver structure preparation Publication, republish, and transport cleanup
Post-load hooks and derived state Shared transport logging and metrics

The outer ModelLoader now passes the model/load configuration and transform
protocol to the checkpoint loader, retains the active checkpoint loader for
cleanup, and preserves the existing native fallback return contract.

mx_config.server_query_timeout_s remains accepted for configuration
compatibility, but it no longer controls source polling: the shared strategy
performs one source-discovery query, consistent with the other engines.

Initial qualification remains limited to the Llama model family and
post-transform P2P weights. This PR does not claim PP/EP, speculative decoding,
multi-node TP, or PD-disaggregated production qualification.

Depends on ai-dynamo/modelexpress#565. The runtime image must contain that
ModelExpress change before this bridge can be exercised.

Test Coverage

  • TensorRT-LLM focused runtime tests:
    • tests/unittest/llmapi/test_mx_args.py
    • tests/unittest/_torch/models/checkpoints/mx/test_mx_checkpoint_loader.py
    • tests/unittest/_torch/executor/test_model_loader_mx.py
    • Result: 53 passed
  • Exact pre-commit suite passed for all eight changed files.
  • LLM-args golden-manifest check passed.
  • TRT-LLM was rebuilt from scratch at 30d24ad668c633a8d7749d6111408e8cc9d02e51 for sm100, then ModelExpress at b7b42d57e1e68e06cf0bec3e7dbb156cc9a93249 was installed with --no-deps.
  • Final cross-node TP=1 Llama 3.1 8B E2E:
    • source checked RDMA once, loaded from disk, published 195 tensors / 16.06 GB as READY, and passed inference
    • target selected RDMA with no disk fallback
    • 195 tensors / 16.06 GB transferred in 0.564 seconds at 227.8 Gbps
    • total receive time was 0.98 seconds
    • target applied post-transform protocol v1, republished READY, and passed inference
  • Planned follow-up: TP=4 CI qualification.

PR Checklist

  • PR description clearly explains what and why.
  • Test cases are provided for the new code paths.
  • No new dependency is introduced; this uses TensorRT-LLM's existing optional
    ModelExpress integration.
  • server_query_timeout_s remains accepted for configuration compatibility.
  • 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

  • Delegates MX checkpoint transport orchestration to modelexpress.engines.trtllm.MxModelLoader, while retaining TensorRT-LLM model construction, validation, fallback, hooks, and derived state.
  • Adds active checkpoint-loader ownership and cleanup handling to ModelLoader.
  • Passes model/load configuration and transform protocol information through staged-receiver loading.
  • Simplifies publishing and cleanup around the delegated MX session.
  • Potential follow-up: retain server_query_timeout_s as a deprecated no-op or remove/update its documentation and release notes to avoid strict configuration validation failures.
  • Potential follow-up: ensure dependency pinning or disk fallback for runtime images without the required ModelExpress version.
  • Review _model_name handling and the removed MODEL_NAME environment-variable precedence.
  • Confirm whether p2p_enabled being tied to post-transform qualification can regress RDMA for otherwise eligible models.
  • The implementation depends on the corresponding ModelExpress change; TP=4 CI qualification remains outstanding.

QA Engineer Review

Test code was updated in:

  • tests/unittest/_torch/executor/test_model_loader_mx.py
  • tests/unittest/_torch/models/checkpoints/mx/test_mx_checkpoint_loader.py

Added or modified coverage includes:

  • MX loader construction and fallback behavior.
  • Qualified and unqualified model handling.
  • Receiver and transform-protocol prerequisites.
  • Incompatible protocol failure behavior.
  • Republish behavior.
  • Checkpoint-loader cleanup and idempotency.
  • Speculative-mode canonicalization and fail-closed behavior.
  • Forwarding of model and load configuration.

Removed coverage includes:

  • Direct source-identity gating.
  • Timeout and model-name resolution behavior.
  • Extensive disk-fallback, publish, and normalization tests moved out with delegated ownership.

The source-identity gate test module was removed. Current tests use a fake ModelExpress module rather than the actual package, so integration coverage for source-identity gating is still needed. No test-list coverage was identified from the available repository references.

Verdict: needs follow-up.

Signed-off-by: Zheng Luo <zheluo@nvidia.com>
@zhengluo-nv
zhengluo-nv force-pushed the zheluo/mx-strategy-chain-bridge branch from 0da10a8 to 30d24ad Compare July 29, 2026 23:11
@zhengluo-nv
zhengluo-nv marked this pull request as ready for review July 30, 2026 00:08
@zhengluo-nv
zhengluo-nv requested review from a team as code owners July 30, 2026 00:08
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

MXCheckpointLoader is refactored into a thin ModelExpress adapter. ModelLoader now forwards MX staging parameters, retains and cleans up the checkpoint loader, while tests cover delegation, protocol validation, publishing, fallback behavior, and lifecycle cleanup.

Changes

MX loader flow

Layer / File(s) Summary
MX adapter delegation and lifecycle
tensorrt_llm/_torch/models/checkpoints/mx/checkpoint_loader.py
MXCheckpointLoader delegates loading and publishing to MxModelLoader, validates transform protocols, removes timeout handling, and cleans up the active session.
ModelLoader wiring and cleanup
tensorrt_llm/_torch/pyexecutor/model_loader.py
MX server and staged post-transform arguments are forwarded, and the checkpoint loader is retained and cleaned up once.
Behavior and lifecycle coverage
tests/unittest/_torch/models/checkpoints/mx/test_mx_checkpoint_loader.py, tests/unittest/_torch/executor/test_model_loader_mx.py
Tests cover fallback, registration, delegation, protocol prerequisites, republishing, argument forwarding, and cleanup behavior.

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

Sequence Diagram(s)

sequenceDiagram
  participant ModelLoader
  participant MXCheckpointLoader
  participant MxModelLoader
  participant Model
  ModelLoader->>MXCheckpointLoader: load_weights(staging arguments)
  MXCheckpointLoader->>MxModelLoader: construct with MX and protocol settings
  MXCheckpointLoader->>MxModelLoader: load_model(Model)
  MxModelLoader-->>MXCheckpointLoader: weights and transform protocol
  MXCheckpointLoader->>MXCheckpointLoader: validate protocol compatibility
  MXCheckpointLoader->>MxModelLoader: publish_model(Model)
Loading

Suggested reviewers: brnguyen2, arysef, allisonlim-nv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and accurately summarizes the main change: delegating MX loading to ModelExpress.
Description check ✅ Passed The description follows the required template and includes clear Description, Test Coverage, and PR Checklist sections.
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
tensorrt_llm/_torch/models/checkpoints/mx/checkpoint_loader.py (1)

170-193: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

post_load_publish now always republishes; this contradicts a documented assumption in model_loader.py.

Previously post_load_publish early-returned when weights_preloaded=True (per the summary). Now it unconditionally calls publish_as_sourceself._mx_loader.publish_model(model). However, tensorrt_llm/_torch/pyexecutor/model_loader.py's GMS RO branch still carries a comment stating MXCheckpointLoader.post_load_publish "honors this flag to early-return and not re-publish" when weights_preloaded=True is passed for a GMS RO receiver.

Today this is likely benign because a GMS RO receiver's checkpoint_loader instance never calls load_weights() (so self._mx_loader stays None and the publish is a no-op), but the mismatch between the code's actual contract and the still-standing comment elsewhere is a real trap for anyone extending the GMS+MX combination later (e.g., if _mx_loader ever gets populated on an RO-role instance, this would silently double-publish).

Please update the stale comment in model_loader.py (near the GMS RO branch) to reflect that the republish decision now lives entirely in ModelLoader._post_load_publish's qualification gate, not in MXCheckpointLoader.post_load_publish itself.

🤖 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/checkpoints/mx/checkpoint_loader.py` around lines
170 - 193, Update the stale GMS RO branch comment in
ModelLoader._post_load_publish to state that republishing is controlled by its
qualification gate, rather than MXCheckpointLoader.post_load_publish honoring
weights_preloaded. Keep the existing behavior and logic unchanged.
tensorrt_llm/_torch/pyexecutor/model_loader.py (1)

1331-1352: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

cleanup()'s "never raises" guarantee no longer holds, and its docstring is now stale.

The docstring explicitly promises: "Currently the only backend held by ModelLoader is the optional GMS client" and "this method never raises — safe to call from PyTorchModelEngine.cleanup and __del__ paths." Both claims are now inaccurate:

  1. self._checkpoint_loader is a second resource cleaned up here (lines 1350-1352), unmentioned in the docstring.
  2. Unlike self._gms_backend.cleanup() (documented as best-effort/self-swallowing), self._checkpoint_loader.cleanup() has no exception handling. MXCheckpointLoader.cleanup() calls self._mx_loader.cleanup() (an external ModelExpress client call) and super().cleanup() with no try/except, so any exception there will propagate out of ModelLoader.cleanup(), breaking the documented invariant for callers relying on it (e.g. __del__/engine shutdown paths).

Either make checkpoint-loader cleanup best-effort (mirroring the GMS backend's swallow-and-log pattern) or update the docstring to drop the "never raises" guarantee and document the new resource.

🛡️ Proposed fix (best-effort checkpoint-loader cleanup, mirroring GMS backend)
         if self._gms_backend is not None:
             self._gms_backend.cleanup()
             self._gms_backend = None
-        if self._checkpoint_loader is not None:
-            self._checkpoint_loader.cleanup()
-            self._checkpoint_loader = None
+        if self._checkpoint_loader is not None:
+            try:
+                self._checkpoint_loader.cleanup()
+            except Exception:
+                logger.warning(
+                    "Failed to clean up checkpoint loader %r",
+                    self._checkpoint_loader,
+                    exc_info=True,
+                )
+            finally:
+                self._checkpoint_loader = None
🤖 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 1331 - 1352,
Update ModelLoader.cleanup to make _checkpoint_loader cleanup best-effort,
matching the existing _gms_backend behavior: catch exceptions from
_checkpoint_loader.cleanup(), log them, and continue releasing resources without
propagating. Revise the cleanup docstring to mention the checkpoint loader and
accurately describe the non-raising guarantee for both resources.
tests/unittest/_torch/models/checkpoints/mx/test_mx_checkpoint_loader.py (1)

15-263: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the new MX checkpoint-loader tests to the integration lists.

Changed tests in tests/unittest/_torch/models/checkpoints/mx/test_mx_checkpoint_loader.py:

  • test_construction_preserves_checkpoint_loader_contract
  • test_registered_under_mx_and_mapper_fallback_is_preserved
  • test_missing_mx_state_uses_native_hf_loader
  • test_qualified_llama_delegates_to_shared_chain
  • test_unqualified_model_keeps_rdma_unavailable
  • test_qualified_model_requires_receiver_preparation
  • test_qualified_model_requires_transform_protocol
  • test_incompatible_transfer_protocol_fails_closed
  • test_p2p_receiver_republishes_after_trt_post_load
  • test_cleanup_releases_mx_and_native_loader_resources

None of these appear in tests/integration/test_lists/test-db/ or tests/integration/test_lists/qa/, so the coverage verdict is insufficient.

🤖 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/models/checkpoints/mx/test_mx_checkpoint_loader.py`
around lines 15 - 263, Add all ten MX checkpoint-loader tests from
test_mx_checkpoint_loader.py to the appropriate integration test-list files
under the test-db and qa lists, preserving their exact test identifiers and
existing list format so the new coverage is included.
🧹 Nitpick comments (1)
tensorrt_llm/_torch/models/checkpoints/mx/checkpoint_loader.py (1)

85-161: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

load_weights docstring lacks Args/contract documentation.

The new implementation handles a much richer **kwargs contract (model, source_identity, allow_post_transform_weights, prepare_post_transform_receiver, model_config, load_config, post_transform_protocol_version) with several fail-closed preconditions and side effects, but the docstring is a single line. Given this is a public override, documenting the accepted kwargs and the raised RuntimeError/ImportError conditions would help future callers/maintainers avoid contract violations.

Logic itself checks out: the reset-then-validate-then-delegate flow is fail-closed (flags reset before validation, protocol mismatch flips p2p_succeeded back to False before raising), consistent with the accompanying tests.

As per coding guidelines, "Prefer docstrings for external interfaces, use Google-style docstrings, document public function arguments."

🤖 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/checkpoints/mx/checkpoint_loader.py` around lines
85 - 161, The load_weights docstring does not document its expanded public
kwargs contract or failure conditions. Update the load_weights docstring using
Google-style sections to describe checkpoint_dir, mapping, and the supported
kwargs (model, source_identity, post-transform options, model_config, and
load_config), plus the returned weights and ImportError/RuntimeError conditions;
preserve the existing implementation behavior.

Source: Coding guidelines

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

Outside diff comments:
In `@tensorrt_llm/_torch/models/checkpoints/mx/checkpoint_loader.py`:
- Around line 170-193: Update the stale GMS RO branch comment in
ModelLoader._post_load_publish to state that republishing is controlled by its
qualification gate, rather than MXCheckpointLoader.post_load_publish honoring
weights_preloaded. Keep the existing behavior and logic unchanged.

In `@tensorrt_llm/_torch/pyexecutor/model_loader.py`:
- Around line 1331-1352: Update ModelLoader.cleanup to make _checkpoint_loader
cleanup best-effort, matching the existing _gms_backend behavior: catch
exceptions from _checkpoint_loader.cleanup(), log them, and continue releasing
resources without propagating. Revise the cleanup docstring to mention the
checkpoint loader and accurately describe the non-raising guarantee for both
resources.

In `@tests/unittest/_torch/models/checkpoints/mx/test_mx_checkpoint_loader.py`:
- Around line 15-263: Add all ten MX checkpoint-loader tests from
test_mx_checkpoint_loader.py to the appropriate integration test-list files
under the test-db and qa lists, preserving their exact test identifiers and
existing list format so the new coverage is included.

---

Nitpick comments:
In `@tensorrt_llm/_torch/models/checkpoints/mx/checkpoint_loader.py`:
- Around line 85-161: The load_weights docstring does not document its expanded
public kwargs contract or failure conditions. Update the load_weights docstring
using Google-style sections to describe checkpoint_dir, mapping, and the
supported kwargs (model, source_identity, post-transform options, model_config,
and load_config), plus the returned weights and ImportError/RuntimeError
conditions; preserve the existing implementation behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 23b6e790-214a-47f3-b7b6-5447ff715a34

📥 Commits

Reviewing files that changed from the base of the PR and between c45ad83 and 30d24ad.

📒 Files selected for processing (8)
  • tensorrt_llm/_torch/models/checkpoints/mx/checkpoint_loader.py
  • tensorrt_llm/_torch/pyexecutor/model_loader.py
  • tensorrt_llm/llmapi/llm_args.py
  • tensorrt_llm/usage/llm_args_golden_manifest.json
  • tests/unittest/_torch/executor/test_model_loader_mx.py
  • tests/unittest/_torch/models/checkpoints/mx/test_mx_checkpoint_loader.py
  • tests/unittest/_torch/weight_sharing/test_mx_source_identity_gate.py
  • tests/unittest/llmapi/test_mx_args.py
💤 Files with no reviewable changes (4)
  • tests/unittest/llmapi/test_mx_args.py
  • tests/unittest/_torch/weight_sharing/test_mx_source_identity_gate.py
  • tensorrt_llm/llmapi/llm_args.py
  • tensorrt_llm/usage/llm_args_golden_manifest.json

@BowenFu

BowenFu commented Jul 30, 2026

Copy link
Copy Markdown

The architectural direction is right — source discovery, RDMA transfer, native-fallback selection, publication and cleanup are ModelExpress's job, not a 900-line adapter in this repo — and non-MX users are properly insulated. Three things I'd want resolved before it lands, though.

1. Removing server_query_timeout_s is a hard break for existing configs, not a silent one. ModelExpressConfig inherits StrictBaseModel, whose Config.extra = "forbid" (llmapi/utils.py:36-45). So a user whose YAML/LlmArgs sets mx_config.server_query_timeout_s today doesn't get the field ignored — they get a Pydantic validation error at startup. And the field is documented: docs/source/features/model-express.md:137 describes its exact semantics ("When unset, TensorRT LLM uses a short fallback cap when no source exists and otherwise lets MX wait for long donor loads"), and it's in docs/source/developer-guide/telemetry.md:165. This PR touches no docs, so both pages keep advertising a field that now raises. Either keep it as a deprecated no-op for a release, or remove it with the doc updates and a note in the release notes.

Related: the capability itself is dropped, not relocated. #565's strategy does immediate native fallback when no compatible source is ready; there's no configurable source-wait. Users coordinating long donor loads lose something they have today.

2. The MX path now hard-depends on an unmerged external PR, and the failure is fatal rather than a fallback. If the runtime image doesn't carry ai-dynamo/modelexpress#565, importing modelexpress.engines.trtllm.MxModelLoader raises ImportError — it does not disk-fallback. Given checkpoint_format="MX" is a user-selectable entry point, that's a startup crash for anyone on an older image rather than a degraded-but-working load. Worth failing closed to disk instead, or at minimum pinning the modelexpress version in requirements.txt in the same PR so the combination can't be mismatched.

3. _model_name is now dead state. It's assigned at checkpoint_loader.py:55, exposed at :71-73, and still supplied by _construct_checkpoint_loader (model_loader.py:314-315), but it's never passed to MxModelLoader and never used for discovery or publication. The tests only assert that it's stored (test_model_loader_mx.py:230-243). The old MODEL_NAME env precedence is gone too. Either wire it or delete it — a stored-and-asserted-but-unused field will read as load-bearing to the next person.

On the deleted coverage (~1340 test lines): most of it is defensible as ownership moving upstream, and the fallback chain still has real local tests (test_model_loader_mx.py:300-316, 460-478, 497-521, 524-569). The one I'd push back on is source-identity gating — test_mx_source_identity_gate.py tested actual backend/artifact mismatch decisions, and what replaces it locally only checks that a source_identity object was handed to a fake loader (test_mx_checkpoint_loader.py:148-155). Since every local test substitutes a fake modelexpress module, nothing in this repo exercises the real boundary. One integration-level test against the actual package would cover the case where #565's contract drifts.

Also worth double-checking: p2p_enabled is now driven by allow_post_transform_weights (checkpoint_loader.py:137-145), which comes from the Llama post-transform qualification. That looks like it disables RDMA for pre-transform/unqualified MX models that the old loader could still accelerate. Correctness falls back to HF, so it's a perf regression rather than a break — but it's a behavior change that isn't called out in the description.

Signed-off-by: Zheng Luo <zheluo@nvidia.com>

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

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

250-267: 🗄️ Data Integrity & Integration | 🔵 Trivial | 🏗️ Heavy lift

Add or confirm one real MX-adapter contract test.

The mock loader verifies ModelLoader’s delegation arguments, but it cannot catch incompatibilities in the actual MXCheckpointLoader/ModelExpress implementation. Keep this unit coverage and add or confirm an integration test using the real adapter for source-identity gating, fallback, publication, and cleanup.

🤖 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 250 -
267, Keep the existing test_model_loader_mx delegation assertions, and add or
confirm an integration test that uses the real MXCheckpointLoader/ModelExpress
adapter rather than a mocked checkpoint loader. Cover source-identity gating,
fallback behavior, successful publication, and cleanup across the load flow,
using the adapter’s actual contract and preserving the existing ModelLoader
assertions.
🤖 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.

Nitpick comments:
In `@tests/unittest/_torch/executor/test_model_loader_mx.py`:
- Around line 250-267: Keep the existing test_model_loader_mx delegation
assertions, and add or confirm an integration test that uses the real
MXCheckpointLoader/ModelExpress adapter rather than a mocked checkpoint loader.
Cover source-identity gating, fallback behavior, successful publication, and
cleanup across the load flow, using the adapter’s actual contract and preserving
the existing ModelLoader assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 143d5797-2b4e-4cdc-9a5a-31bcdc667feb

📥 Commits

Reviewing files that changed from the base of the PR and between 30d24ad and 26a5129.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/pyexecutor/model_loader.py
  • tests/unittest/_torch/executor/test_model_loader_mx.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tensorrt_llm/_torch/pyexecutor/model_loader.py

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

Thanks for the PR. I raised a few points below and inline.


There could be problems with landing #16458/#16974 independently.

#17029 reimplements the Llama-only qualification inline in model_loader.py:1124, whereas #16458 makes qualification a single preserved decision based on pre-construction config identity, profile ABI, and feature/topology constraints.

Merging #17029 first will require a substantial conflict resolution and is likely to drop the Qwen2 support envelope in #16974 unless deliberately rebased onto #16458.


Also, GMS RO republish regression is real. MXCheckpointLoader.post_load_publish() now republishes whenever an MX session exists, while the GMS-RO path still claims weights_preloaded=True prevents republishing (910–935). This is currently masked by the loader-session shape, but is unsafe documentation/behavioral coupling for the future MX+GMS composition you own.

Comment on lines +146 to 153
weights = self._mx_loader.load_model(model)
self._p2p_succeeded = self._mx_loader.p2p_succeeded
self._transform_protocol_version_for_last_load = self._mx_loader.transform_protocol_version
protocol_compatible = (
self._p2p_succeeded
and transform_protocol_version is not None
and self._transform_protocol_version_for_last_load == transform_protocol_version
)

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.

This adapter now treats p2p_succeeded + transform_protocol_version as sufficient to set is_post_transform_weights_preloaded(), but it deletes TRT-LLM’s local SourceIdentity metadata gate. Our staged-receiver contract also requires the transform-layout ABI carried by SourceIdentity (format v3), not only protocol v1.

Please either retain an explicit verified compatibility result from the ModelExpress loader, including the TRT-LLM identity/ABI, or add a real-adapter integration test against #565 that proves incompatible artifact/ABI sources disk-fallback before the staged hooks are selected.

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