Skip to content

fix(deploy): unblock TensorRT 11 inference - #2908

Merged
kevalmorabia97 merged 2 commits into
NVIDIA:mainfrom
joe-nv:fix/6915422-remove-legacy-shape-check
Oct 22, 2026
Merged

kevalmorabia97 merged 2 commits into
NVIDIA:mainfrom
joe-nv:fix/6915422-remove-legacy-shape-check

Conversation

@joe-nv

@joe-nv joe-nv commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change: Bug fix

Remove the obsolete IExecutionContext.all_shape_inputs_specified assertion that aborts TensorRT inference initialization with AttributeError on TensorRT 11.

TensorRT 10.16 documents that this legacy check does not work with name-based APIs such as set_input_shape() and recommends infer_shapes(). NVIDIA's TensorRT 11 migration reference lists the corresponding allInputShapesSpecified() API as "Removed (always true)".

The change deletes only this three-line assertion. Existing name-based infer_shapes() validation, including its io_shapes == {} condition, is preserved. Input/output allocation, profile selection, inference execution, public APIs and dependency requirements are unchanged.

Usage

No new API or flag. Existing TensorRT deployment and evaluation calls continue to use the same entry points and optional io_shapes argument.

Testing

  • A development-only CPU protocol probe executes the production initializer with simulated TensorRT binding interfaces and explicit I/O shapes. Before the change, the absent-property case reproduces the reported AttributeError, while the legacy-property control passes. After the change, both cases pass and retain the same binding/profile calls. This validates the Python interface regression, not native TensorRT/CUDA execution; the scaffolding is not included in this PR.
  • All applicable pre-commit hooks passed for the changed file, including Ruff, formatting, mypy, license checks and Bandit. git diff --check and Python syntax parsing passed.
  • Native TensorRT 10.16/11.x GPU inference and baseline/FP8/INT8 accuracy evaluation were not run on the development Mac, which has no TensorRT installation or CUDA device. Run the existing deployment runtime tests and affected ONNX evaluation cases on the final commit before merge.

Before your PR is "Ready for review"

  • Is this change backward compatible?: API-contract review supports removing the obsolete check for TensorRT 10.16/11.x; no public signature or existing shape-inference condition changes. Native regression validation is pending.
  • Copied third-party code or new PIP dependency: none.
  • Necessary tests: existing TensorRT compile/profile tests are retained. Development-only protocol regression checks passed; no mock/scaffolding tests are added to CI.
  • Changelog: not added; this addresses the TensorRT 11 compatibility issue reported during the current release-candidate testing.
  • Claude approval: not obtained.

Additional Information

Refs: bug/6915422

The commit includes DCO sign-off and an SSH signature verified locally. GitHub reports unknown_key because the signing public key is not registered on the account.

Target: main, with cherry-pick-0.48.0. Keep as Draft pending native validation of the final commit. No merge or auto-merge requested.

Summary by CodeRabbit

  • Bug Fixes
    • Updated TensorRT shape handling to allow execution when shape inputs are configured through tensor addresses and input shapes.
    • Retained validation for cases where no input/output shapes are provided.

@copy-pr-bot

copy-pr-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/Model-Optimizer/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: fcbbf847-520b-4d45-bed4-2f63b8bb4af2
📥 Commits

Reviewing files that changed from the base of the PR and between 576c66f and 04621a0.

📒 Files selected for processing: 1
  • modelopt/torch/_deploy/_runtime/trt_client.py
💤 Files with no reviewable changes: 1
  • modelopt/torch/_deploy/_runtime/trt_client.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

The TensorRT client no longer asserts that all shape inputs are specified after input/output tensor initialization. Shape inference validation remains when io_shapes is empty.

Changes: TensorRT Initialization

Layer / File(s) Summary
Input initialization check
modelopt/torch/_deploy/_runtime/trt_client.py
Removed the assertion that required all TensorRT shape inputs to be specified.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 04621

No concrete regression remains identified from this change. Native TensorRT inference and affected evaluation cases are still pending as normal pre-merge validation.

Pre-merge checks: Passed 6
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: fixing TensorRT 11 inference support. It matches the pull request objectives.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
Security Anti-Patterns Passed PASS. The pull request changes only modelopt/torch/_deploy/_runtime/trt_client.py and removes three assertion lines. It adds no torch.load, numpy.load(..., allow_pickle=True), hardcoded `trust_r…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files.

Full details: Security Anti-Patterns

Explanation

PASS. The pull request changes only modelopt/torch/_deploy/_runtime/trt_client.py and removes three assertion lines. It adds no torch.load, numpy.load(..., allow_pickle=True), hardcoded trust_remote_code=True, eval, exec, or # nosec usage. It also changes no dependency files.

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

Comment @coderabbitai help to get the list of available commands.

ModelOpt's TensorRT inference session crashes during I/O initialization
on TensorRT 11 because initialize_input_output_tensors() reads the
removed IExecutionContext.all_shape_inputs_specified property. The
resulting AttributeError prevents both baseline and quantized models
from reaching inference. This is a product runtime API-compatibility
bug rather than a quantization or accuracy-threshold failure.

The property wraps the legacy C++ allInputShapesSpecified() interface.
TensorRT 10.16 documents that it does not work with name-based APIs such
as set_input_shape(), which ModelOpt already uses, and recommends
infer_shapes(). The TensorRT 11 migration reference lists this API as
"Removed (always true)"; it was removed, not simply renamed.

Delete only the obsolete assertion. Retain the existing infer_shapes()
validation and its io_shapes == {} condition. This removes an obsolete
check on TensorRT 10.16 and avoids accessing the missing property on
TensorRT 11.x. Model weights, quantization parameters and numerical
operations are unchanged, as are public APIs and dependencies.

Public history:
- 73d6af7, authored 2025-01-29,
  "Update 0.23.0 - OSS release", is the earliest public commit located
  that already contains the assertion. Its message gives no rationale
  for the check; the apparent intent to validate shape-input
  completeness is inferred from the assertion text.
- 2017cd9, authored 2025-03-03,
  "Update for 0.25.0 release", only reformats this assertion. Plain
  git blame can attribute the current lines to that formatting change.

Development-only CPU protocol checks reproduce the missing-property
failure before the fix and pass after it; the legacy-property control
also passes. Applicable pre-commit hooks passed. These checks do not
establish native TensorRT/CUDA compatibility or accuracy. TensorRT
10.16/11.x GPU inference and evaluation validation remain pending.

Sources:
NVIDIA@73d6af7
NVIDIA@2017cd9
https://github.com/NVIDIA/TensorRT/blob/v10.16/include/NvInferRuntime.h#L4556-L4565
https://docs.nvidia.com/deeplearning/tensorrt/11.4.0/api/migration/tensorrt-10x-to-11x-c-api-reference.html

Refs: bug/6915422
Signed-off-by: joe-nv <[email protected]>
@joe-nv
joe-nv force-pushed the fix/6915422-remove-legacy-shape-check branch from e3592ba to 713d261 Compare October 21, 2026 07:31
@joe-nv joe-nv changed the title fix(deploy): remove obsolete TensorRT shape check fix(deploy): unblock TensorRT 11 inference Oct 21, 2026
@joe-nv
joe-nv marked this pull request as ready for review October 21, 2026 07:36
@joe-nv
joe-nv requested a review from a team as a code owner October 21, 2026 07:36
@joe-nv
joe-nv requested a review from ajrasane October 21, 2026 07:36
@joe-nv

joe-nv commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@kevalmorabia97 please help to review bugfix

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.08%. Comparing base (576c66f) to head (04621a0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2908   +/-   ##
=======================================
  Coverage   70.08%   70.08%           
=======================================
  Files         659      659           
  Lines       74081    74080    -1     
=======================================
+ Hits        51917    51922    +5     
+ Misses      22164    22158    -6     
Flag Coverage Δ
unit 60.51% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Bot review (gpt-6.1-sol) — DM the bot to share feedback.

Nudge: the deletion looks correct and surgical, but native TensorRT regression validation is still pending.

Needs action:

  • Run tests/gpu/torch/deploy/_runtime/test_trt_client.py on TensorRT 10.16 and 11.x; report final-commit results and validate the explicit io_shapes path as well.

No action needed:

  • Existing GPU tests exercise initialization, inference, and output comparisons; no tests were modified or removed.
  • The obsolete property access is removed without changing the existing infer_shapes() condition or public APIs.

@kevalmorabia97
kevalmorabia97 merged commit d4f2c67 into NVIDIA:main Oct 22, 2026
31 checks passed
@joe-nv

joe-nv commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Hi @kevalmorabia97 Could you help cherry-pick this to the 0.48 branch? Thanks.

kevalmorabia97 added a commit that referenced this pull request Oct 28, 2026
#2928 #2885 #2908 #2929 #2950 #2972 #2877 #2951 #2816 #3005 #3012 #2971 #3015 #3006 #3026 #2988 #3028 #1860 #3030 #2612 #3033 #2653 #2599 #2655 #2618 #2868 #3032 #3027 #2869 #2984 #2975 #2345 #3020 #2997 (#3072)

## Cherry-picked PRs

- #2817
- #2671
- #2892
- #2876
- #2910
- #2911
- #2919
- #2904
- #2937
- #2928
- #2885
- #2908
- #2929
- #2950
- #2972
- #2877
- #2951
- #2816
- #3005
- #3012
- #2971
- #3015
- #3006
- #3026
- #2988
- #3028
- #1860
- #3030
- #2612
- #3033
- #2653
- #2599
- #2655
- #2618
- #2868
- #3032
- #3027
- #2869
- #2984
- #2975
- #2345
- #3020
- #2997

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Diffusion exports now offer more control over attention-quantizer
metadata and preserve sparse-attention settings in a format compatible
with downstream tooling.
* Model loading better handles select bundled model implementations, and
Docker guidance now covers writable CUDA-extension cache locations.
* **Bug Fixes**
* Improved reliability for model export and checkpoint saving,
quantization across devices, ONNX processing, and calibration.
* Temporary TensorRT and autotuning artifacts now use private
directories by default.
* **Documentation**
* Updated installation guidance, compatibility notes, and links;
corrected typos across guides and examples.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Chad Voegele <[email protected]>
Signed-off-by: Rohan Joshi <[email protected]>
Signed-off-by: LinCanNerd <[email protected]>
Signed-off-by: Keval Morabia <[email protected]>
Signed-off-by: weimingc <[email protected]>
Signed-off-by: Noey Yang <[email protected]>
Signed-off-by: Kai Xu <[email protected]>
Signed-off-by: Zhehao Hu <[email protected]>
Signed-off-by: noeyy-mino <[email protected]>
Signed-off-by: joe-nv <[email protected]>
Signed-off-by: yingguo-trt <[email protected]>
Signed-off-by: Shengliang Xu <[email protected]>
Signed-off-by: Chenjie Luo <[email protected]>
Signed-off-by: anmaurya001 <[email protected]>
Signed-off-by: Connor Baker <[email protected]>
Signed-off-by: wiederse <[email protected]>
Signed-off-by: Vu Dinh <[email protected]>
Signed-off-by: Pratik Gandhi <[email protected]>
Signed-off-by: Michael Rusu <[email protected]>
Signed-off-by: Michael-Rusu <[email protected]>
Signed-off-by: namgyu-youn <[email protected]>
Signed-off-by: Sylvester Kaczmarek <[email protected]>
Signed-off-by: Javier de Jesus <[email protected]>
Signed-off-by: javierdejesusda <[email protected]>
Signed-off-by: Zhiyu Cheng <[email protected]>
Signed-off-by: Juhi Mittal <[email protected]>
Signed-off-by: Dmitry Rantovov <[email protected]>
Signed-off-by: h-guo18 <[email protected]>
Co-authored-by: Chad Voegele <[email protected]>
Co-authored-by: LinCanNerd <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Co-authored-by: Keval Morabia <[email protected]>
Co-authored-by: Wei-Ming Chen <[email protected]>
Co-authored-by: noeyy-mino <[email protected]>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: kaix-nv <[email protected]>
Co-authored-by: Zhehao Hu <[email protected]>
Co-authored-by: joe <[email protected]>
Co-authored-by: yingguo-trt <[email protected]>
Co-authored-by: Shengliang Xu <[email protected]>
Co-authored-by: Chenjie Luo <[email protected]>
Co-authored-by: anmaurya001 <[email protected]>
Co-authored-by: Connor Baker <[email protected]>
Co-authored-by: Jiao Mingyang <[email protected]>
Co-authored-by: Vu Dinh <[email protected]>
Co-authored-by: Pratik Gandhi <[email protected]>
Co-authored-by: Michael R <[email protected]>
Co-authored-by: Michael-Rusu <[email protected]>
Co-authored-by: namgyu-youn <[email protected]>
Co-authored-by: Sylvester Kaczmarek <[email protected]>
Co-authored-by: Javier De Jesus <[email protected]>
Co-authored-by: Zhiyu <[email protected]>
Co-authored-by: Juhi Mittal <[email protected]>
Co-authored-by: Dmitry Rantovov <[email protected]>
Co-authored-by: h-guo18 <[email protected]>
@rohansjoshi rohansjoshi added the cherry-pick-done Added by bot once PR is cherry-picked to the release branch label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-0.48.0 cherry-pick-done Added by bot once PR is cherry-picked to the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants