Fix TensorRT GridSample inference for LT-DETR - #917
Merged
Conversation
yutong-xiang-97
force-pushed
the
yutong-trn-2329-fix-onnx-verification
branch
from
July 28, 2026 09:42
4927b77 to
9029640
Compare
yutong-xiang-97
marked this pull request as ready for review
July 28, 2026 11:32
Contributor
Author
|
/review |
yutong-xiang-97
force-pushed
the
yutong-trn-2329-fix-tensorrt-gridsample
branch
from
July 28, 2026 11:49
30684c0 to
c4f5bc2
Compare
The gather-based bilinear replacement for grid_sample removes the ONNX GridSample op that TensorRT miscompiled, so weakly-typed TensorRT export is now numerically correct for DINOv3 ViT-S/16 LT-DETR (verified on a T4 with TensorRT 10.16: 100% top-class agreement and tight boxes vs PyTorch). Treat this model like every other LT-DETR model instead of forcing a strongly-typed network. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
yutong-xiang-97
force-pushed
the
yutong-trn-2329-fix-tensorrt-gridsample
branch
from
July 28, 2026 13:01
a12afee to
ac6500e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac6500e1c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
yutong-xiang-97
enabled auto-merge (squash)
July 28, 2026 14:30
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.
What has changed and why?
This is PR 2 of a three-PR stack and is based on
yutong-trn-2329-fix-onnx-verification.LT-DETR TensorRT engines could build and run successfully while silently producing
incorrect detections or segmentations because TensorRT compiled the deformable-attention
GridSamplepath incorrectly.For ONNX export, the affected DFINE and RT-DETRv2 attention modules now replace native
grid_samplewith equivalent gather-based bilinear interpolation built from simpleroperations such as
Pad,Gather, multiplication, and addition. The resulting ONNXgraphs contain no
GridSamplenodes, so no opset-specific TensorRT parser workaround isneeded. Training and ordinary deployment retain the faster native
grid_samplepath.The ONNX-only conversion is applied through an explicit runtime-checkable export
protocol. DINOv3 ViT-S/16 FP16 TensorRT export remains strongly typed independently of
the
GridSamplefix, preserving the graph's FP32 attention operations and preventingFP16 overflow. Other model and precision combinations retain the existing weakly typed
path.
How has it been tested?
Raw ONNX Runtime versus TensorRT results on the T4 with TensorRT 10.13.3.9:
7.97e-4/1.46e-55.21e-5/3.58e-71.05e-2/1.48e-41.16e-3/2.95e-56.87e-6/4.29e-7Did you update CHANGELOG.md?
Did you update the documentation?