Incorrect Min NaN handling of TensorRT 10.16.1.11 when running ONNX Min on GPU
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 13.4k
- Forks
- 2.4k
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 2
Description
Description
TensorRT appears to handle NaN values incorrectly for ONNX Min.
For inputs containing NaN, ONNX Runtime propagates NaN in the output. TensorRT instead returns the non-NaN operand for mixed NaN/non-NaN inputs, which changes the result.
This appears to be a TensorRT execution issue for ONNX Min NaN semantics.
Environment
TensorRT Version: 10.16.1.11
NVIDIA GPU: N/A / not detected by nvidia-smi
NVIDIA Driver Version: N/A / nvidia-smi failed
CUDA Version: N/A / nvcc not found
CUDNN Version: N/A / torch.backends.cudnn.version() returned None
Operating System: Linux 6.17.0-20-generic x86_64, glibc 2.39
Python Version (if applicable): Python 3.11.15
Tensorflow Version (if applicable): N/A
PyTorch Version (if applicable): N/A
Baremetal or Container (if so, version): Baremetal / non-Docker environment (/proc/1/cgroup: 0::/init.scope)
Additional package versions:
ONNX Version: 1.21.0
ONNX Runtime Version: 1.25.1
Relevant Files
Model link: N/A
The ONNX model is generated inline by the minimal reproducible script below.
Steps To Reproduce
Commands or scripts:
import numpy as np
import onnx
import onnxruntime as ort
from onnx import helper, TensorProto
from _trt_helper import build_engine_from_onnx, run_engine
n = helper.make_node("Min", ["a", "b"], ["y"])
g = helper.make_graph(
[n],
"g",
[
helper.make_tensor_value_info("a", TensorProto.FLOAT, [4]),
helper.make_tensor_value_info("b", TensorProto.FLOAT, [4]),
],
[helper.make_tensor_value_info("y", TensorProto.FLOAT, [4])],
)
m = helper.make_model(g, opset_imports=[helper.make_opsetid("", 18)])
m.ir_version = 10
ob = m.SerializeToString()
a = np.array([np.nan, 12.0, np.nan, 7.5], dtype=np.float32)
b = np.array([6.0, np.nan, np.nan, 4.5], dtype=np.float32)
ort_y = ort.InferenceSession(
ob,
providers=["CPUExecutionProvider"],
).run(["y"], {"a": a, "b": b})[0]
eng, _ = build_engine_from_onnx(ob)
trt_y = run_engine(
eng,
{"a": a, "b": b},
["y"],
[(4,)],
[np.float32],
)["y"]
print("ORT:", ort_y.tolist())
print("TRT:", trt_y.tolist())
assert (np.isnan(ort_y) != np.isnan(trt_y)).any()
Have you tried the latest release?: Yes, reproduced with TensorRT 10.16.1.11.
Attach the captured .json and .bin files from TensorRT's API Capture tool if you're on an x86_64 Unix system Not attached. The issue is reproducible from the self-contained Python script above.
Can this model run on other frameworks? For example run ONNX model with ONNXRuntime (polygraphy run <model.onnx> --onnxrt): Yes. ONNX Runtime runs the same model and propagates NaN values.
Actual output:
ORT: [nan, nan, nan, 4.5]
TRT: [6.0, 12.0, nan, 4.5]
TensorRT returns 6.0 for min(nan, 6.0) and 12.0 for min(12.0, nan), while ONNX Runtime returns nan for both cases.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the inline Python reproduction, especially build_engine_from_onnx and run_engine, and compare its TensorRT output with the ONNX Runtime result. Trace the ONNX Min conversion and execution path for NaN inputs; done means mixed NaN/non-NaN inputs produce the NaN-propagating result shown by ONNX Runtime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100