Skip to content

Fix TensorRT build version check for 11#29779

Open
Menkib64 wants to merge 1 commit into
microsoft:mainfrom
Menkib64:fix-strongly-typed-networks-when-using-tensorrt-10
Open

Fix TensorRT build version check for 11#29779
Menkib64 wants to merge 1 commit into
microsoft:mainfrom
Menkib64:fix-strongly-typed-networks-when-using-tensorrt-10

Conversation

@Menkib64

Copy link
Copy Markdown

Description

If onnxruntime is using TensorRT 10, the wrong version check ends up using TensorRT 11 code. This means strongly typed networks are converted to weak networks. This is a major performance penalty when using fp16 networks like Leela Chess Zero. Using _MAJOR version macro corrects the version check logic and fixes a major performance regression.

Motivation and Context

This fixes a major performance regression in onnxruntime 1.27 when using strongly typed fp16 network. The performance drops to about 31% when using fp32 evaluation. The root cause for the performance drop was TensorRT seeing it as a weakly typed network and inserted type cast everywhere.

I bisected the problem to 53fcead . After careful review I noticed the accidental use of wrong version macros in a code path which set strongly typed flag. Fixing the check fixed the performance problem in my local test.

If onnxruntime is using TensorRT 10, the wrong version check ends up
using TensorRT 11 code. This means strongly typed networks are converted
to weak networks. This is a major performance penalty when using fp16
networks like Leela Chess Zero. Using `_MAJOR` version macro corrects
the version check logic and fixes a major performance regression.
Copilot AI review requested due to automatic review settings July 18, 2026 20:19
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

Pull request overview

This PR fixes a TensorRT version-gating bug in the TensorRT Execution Provider where a preprocessor check used NV_TENSORRT_VERSION >= 11 (which is not comparable to a plain major version), causing TensorRT 10 builds to incorrectly take the TensorRT 11 code path and disable strongly-typed network creation—leading to significant performance regressions for fp16 strongly-typed networks.

Changes:

  • Replace #if NV_TENSORRT_VERSION >= 11 with #if NV_TENSORRT_MAJOR >= 11 when selecting createNetworkV2 flags.
  • Apply the same fix in both the supported-subgraph parsing path and the fused-node build path to keep behavior consistent.

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.

3 participants