Skip to content

[TRTLLM-14475][chore] Self-sufficient transfer-agent dlopen and drop onnx/modelopt deps#16829

Open
Wanli-Jiang wants to merge 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/trtllm-14027-cpp-cleanup
Open

[TRTLLM-14475][chore] Self-sufficient transfer-agent dlopen and drop onnx/modelopt deps#16829
Wanli-Jiang wants to merge 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/trtllm-14027-cpp-cleanup

Conversation

@Wanli-Jiang

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

Copy link
Copy Markdown
Collaborator

Trailing cleanup after the TensorRT backend removal, in two parts.

  1. Make the KV-cache transfer-agent wrapper dlopen self-sufficient.
    The wrapper libraries (libtensorrt_llm_{nixl,ucx,mooncake}_wrapper.so)
    carry no DT_NEEDED on libtensorrt_llm.so (circular) and resolve its
    symbols from the process global scope. In the wheel they only worked
    because tensorrt_llm/_common.py preloaded libtensorrt_llm.so with ctypes
    RTLD_GLOBAL - a stopgap added when the removed TensorRT plugin's
    RTLD_GLOBAL load stopped providing this as a side effect. New
    executor::kv_cache::promoteHostLibraryToGlobalScope() (dladdr-self +
    RTLD_NOW|RTLD_GLOBAL|RTLD_NOLOAD, call_once, no-op when statically
    linked) is called at both wrapper-load sites (DynLibLoader::getHandle and
    the UCX dllOpen), and the _common.py preload is removed.

  2. Drop the onnx and nvidia-modelopt dependencies.

    • onnx / onnx_graphsurgeon: TensorRT ONNX-engine-build graph tools with zero consumers repo-wide. Legacy relics of the removed engine path.
    • nvidia-modelopt[torch]: removed as a dependency and its AutoDeploy package import sites stripped (all four were try/except-guarded). The main PyTorch backend never imported the package. PRESERVED (package free): loading pre-quantized FP8/NVFP4 checkpoints via models/quant_config_reader.py + _compat.py + the local modelopt_fp4_scale_to_cutlass_fp4_scale, which read the modelopt checkpoint format and never imported the package. DISABLED: loading graphs with live modelopt fake-quant ops (is_quantized_graph=True) and the modelopt export context. Guarded test helpers degrade gracefully, so test collection is unaffected; examples/auto_deploy/ build_and_run_flux.py hard-imports the package and will not run without it (out of scope here).

Dev Engineer Review

  • Promotes libtensorrt_llm.so globally at KV-cache wrapper load sites, removing the _common.py preload.
  • Removes ONNX and ModelOpt dependencies and disables ModelOpt quantization/export integrations while preserving pre-quantized checkpoint loading.
  • Makes promotion idempotent, thread-safe, and gracefully handles dynamic-loading failures.
  • No test-list, configuration-format, or unrelated API changes identified.

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.

…onnx/modelopt deps

Trailing cleanup after the TensorRT backend removal, in two parts.

1) Make the KV-cache transfer-agent wrapper dlopen self-sufficient.
   The wrapper libraries (libtensorrt_llm_{nixl,ucx,mooncake}_wrapper.so)
   carry no DT_NEEDED on libtensorrt_llm.so (circular) and resolve its
   symbols from the process global scope. In the wheel they only worked
   because tensorrt_llm/_common.py preloaded libtensorrt_llm.so with ctypes
   RTLD_GLOBAL - a stopgap added when the removed TensorRT plugin's
   RTLD_GLOBAL load stopped providing this as a side effect. New
   executor::kv_cache::promoteHostLibraryToGlobalScope() (dladdr-self +
   RTLD_NOW|RTLD_GLOBAL|RTLD_NOLOAD, call_once, no-op when statically
   linked) is called at both wrapper-load sites (DynLibLoader::getHandle and
   the UCX dllOpen), and the _common.py preload is removed.

2) Drop the onnx and nvidia-modelopt dependencies.
   - onnx / onnx_graphsurgeon: TensorRT ONNX-engine-build graph tools with
     zero consumers repo-wide. Legacy relics of the removed engine path.
   - nvidia-modelopt[torch]: removed as a dependency and its AutoDeploy
     package import sites stripped (all four were try/except-guarded). The
     main PyTorch backend never imported the package. PRESERVED (package
     free): loading pre-quantized FP8/NVFP4 checkpoints via
     models/quant_config_reader.py + _compat.py + the local
     modelopt_fp4_scale_to_cutlass_fp4_scale, which read the modelopt
     *checkpoint format* and never imported the package. DISABLED: loading
     graphs with live modelopt fake-quant ops (is_quantized_graph=True) and
     the modelopt export context. Guarded test helpers degrade gracefully,
     so test collection is unaffected; examples/auto_deploy/
     build_and_run_flux.py hard-imports the package and will not run without
     it (out of scope here).

Signed-off-by: Wanli Jiang <35160485+Wanli-Jiang@users.noreply.github.com>
@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61511 [ run ] triggered by Bot. Commit: 447ab03 Link to invocation

@Wanli-Jiang
Wanli-Jiang marked this pull request as ready for review July 24, 2026 06:19
@Wanli-Jiang
Wanli-Jiang requested review from a team as code owners July 24, 2026 06:19
@coderabbitai

coderabbitai Bot commented Jul 24, 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: 98a2bd88-67c8-4645-b71e-c6a21d796485

📥 Commits

Reviewing files that changed from the base of the PR and between 929f153 and 447ab03.

📒 Files selected for processing (9)
  • cpp/include/tensorrt_llm/executor/transferAgent.h
  • cpp/tensorrt_llm/batch_manager/cacheTransceiver.cpp
  • cpp/tensorrt_llm/executor/cache_transmission/transferAgent.cpp
  • requirements.txt
  • tensorrt_llm/_common.py
  • tensorrt_llm/_torch/auto_deploy/__init__.py
  • tensorrt_llm/_torch/auto_deploy/export/export.py
  • tensorrt_llm/_torch/auto_deploy/export/library/modelopt_context.py
  • tensorrt_llm/_torch/auto_deploy/utils/node_utils.py
💤 Files with no reviewable changes (4)
  • tensorrt_llm/_torch/auto_deploy/export/library/modelopt_context.py
  • requirements.txt
  • tensorrt_llm/_common.py
  • tensorrt_llm/_torch/auto_deploy/init.py

Walkthrough

The change moves host-library symbol promotion from Python initialization into C++, invokes it before dynamic wrapper loading, removes ModelOpt auto-deploy integration, and removes ONNX and ModelOpt requirements.

Changes

Global symbol promotion

Layer / File(s) Summary
Promotion helper and public declaration
cpp/include/tensorrt_llm/executor/transferAgent.h, cpp/tensorrt_llm/executor/cache_transmission/transferAgent.cpp
Declares and implements promoteHostLibraryToGlobalScope() using dladdr and dlopen with process-once behavior and debug logging.
Wrapper loading integration
cpp/tensorrt_llm/executor/cache_transmission/transferAgent.cpp, cpp/tensorrt_llm/batch_manager/cacheTransceiver.cpp, tensorrt_llm/_common.py
Calls promotion before dynamic library loading and removes the previous Python ctypes.RTLD_GLOBAL initialization path.

ModelOpt integration removal

Layer / File(s) Summary
Auto-deploy ModelOpt removal
tensorrt_llm/_torch/auto_deploy/__init__.py, tensorrt_llm/_torch/auto_deploy/export/export.py, tensorrt_llm/_torch/auto_deploy/export/library/modelopt_context.py, tensorrt_llm/_torch/auto_deploy/utils/node_utils.py, requirements.txt
Removes ModelOpt bootstrap and export context integration, sets ModelOpt quantization operations to None, deletes the ModelOpt context patch, and removes its requirement.

ONNX dependency removal

Layer / File(s) Summary
ONNX requirement cleanup
requirements.txt
Removes the onnx and onnx_graphsurgeon requirements.

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

Sequence Diagram(s)

sequenceDiagram
  participant CacheTransceiver
  participant DynLibLoader
  participant HostLibrary
  participant UCXWrapper
  CacheTransceiver->>HostLibrary: promoteHostLibraryToGlobalScope()
  CacheTransceiver->>UCXWrapper: open UCX wrapper
  DynLibLoader->>HostLibrary: promote before handle lookup
  DynLibLoader->>UCXWrapper: resolve wrapper symbols
Loading

Suggested reviewers: chienchunhung

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the transfer-agent dlopen change and dependency cleanup.
Description check ✅ Passed The description clearly explains the cleanup, the motivation, and the resulting behavior changes.
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.

modelopt_quantize_op = None
modelopt_dynamic_block_quantize_op = None
# modelopt quantization support has been removed; these ops are no longer available.
modelopt_quantize_op = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@nv-guomingz can you help review this part? Are we still using modelopt.torch.quantization.tensor_quant in torch path?

Comment thread tensorrt_llm/_common.py
# table, while Python extension modules and their dependencies load with
# RTLD_LOCAL. This promotion was previously a side effect of loading the
# TensorRT plugin library with RTLD_GLOBAL.
if platform.system() != "Windows":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@Wanli-Jiang can you explain why we switch to implement this logic in C++? Is it that the python version no longer works?

@Wanli-Jiang Wanli-Jiang Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The Python preload wasn't broken — but it was a hack: on every import tensorrt_llm it force-loads the whole libtensorrt_llm.so with RTLD_GLOBAL via ctypes, purely to satisfy a C++ dlopen requirement (the nixl/ucx/mooncake wrappers carry no DT_NEEDED on it and need its symbols in the global scope). It also only kicks in when you enter through the Python import path.

The C++ version is simpler and cleaner: the library promotes its own symbols right at the wrapper-load site — promoteHostLibraryToGlobalScope() (RTLD_NOLOAD | RTLD_GLOBAL, call_once, no-op when statically linked). No Python involvement, works for any caller (C++ embeddings, executor, gtests), and the requirement lives where it belongs.

the Python preload was a hack (a whole-library RTLD_GLOBAL force-load on every import, just to satisfy a C++ dlopen need), and the C++ version is the simpler, cleaner home for it.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61511 [ run ] completed with state FAILURE. Commit: 447ab03
/LLM/main/L0_MergeRequest_PR pipeline #49728 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 #61573 [ run ] triggered by Bot. Commit: 447ab03 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61573 [ run ] completed with state FAILURE. Commit: 447ab03
/LLM/main/L0_MergeRequest_PR pipeline #49784 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

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.

6 participants