Fix TensorRT build version check for 11#29779
Open
Menkib64 wants to merge 1 commit into
Open
Conversation
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.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
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 >= 11with#if NV_TENSORRT_MAJOR >= 11when selectingcreateNetworkV2flags. - Apply the same fix in both the supported-subgraph parsing path and the fused-node build path to keep behavior consistent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
_MAJORversion 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.