You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
quantize onnx model with fp8, convert tensorrt engine failed #439
hi:
I quantize an onnx model with fp8 with TensorRT model optimizer, the quantized model is generated successfully.
But when I build trt engine with command:
trtexec --onnx=calib.onnx --saveEngine=model_fp8.eng --fp16 --fp8
I meet:
and then I try to build engine according to #118 with command:
trtexec --onnx=calib.onnx --saveEngine=model_fp8.eng --stronglyTyped
I meet:
And at the same time the performance is slower than model with fp16 version.
convert model to fp8 with command:
python -m modelopt.onnx.quantization
--onnx_path=model.onnx
--quantize_mode=fp8
--calibration_method=max
--output_path=calib.onnx
build trt engine with command:
trtexec --onnx=calib.onnx --saveEngine=model_fp8.eng --stronglyTyped
We discovered that the build error was caused by the model's output cast. Manually changing the cast output to float32 resolved the error, but the performance issue persisted compared to fp16 precision. After using Nsight System Profiler, we found that additional kernels appeared before and after the kernels calculated using fp8, causing the overall performance slowdown.
Activity
wanghuihhh commentedon Oct 15, 2025
AnnaTrainingG commentedon Oct 16, 2025
tensorrt好像不支持直接量化fp8? 可以先用modelopt的autocast转成fp8 onnx,然后再用trtexec进行--stronglyTyped进行转换
wanghuihhh commentedon Oct 16, 2025
已经是用modelopt转换出fp8的onnx了
cjluo-nv commentedon Oct 30, 2025
Thanks @AnnaTrainingG . @wanghuihhh has your issue been resolved?
ajrasane commentedon Nov 6, 2025
@wanghuihhh, @AnnaTrainingG could you please share the models and commands to reproduce this issue?
wanghuihhh commentedon Nov 7, 2025
No, I still have this issue
wanghuihhh commentedon Nov 11, 2025
convert model to fp8 with command:
python -m modelopt.onnx.quantization
--onnx_path=model.onnx
--quantize_mode=fp8
--calibration_method=max
--output_path=calib.onnx
build trt engine with command:
trtexec --onnx=calib.onnx --saveEngine=model_fp8.eng --stronglyTyped
wanghuihhh commentedon Nov 11, 2025
We discovered that the build error was caused by the model's output cast. Manually changing the cast output to float32 resolved the error, but the performance issue persisted compared to fp16 precision. After using Nsight System Profiler, we found that additional kernels appeared before and after the kernels calculated using fp8, causing the overall performance slowdown.
ajrasane commentedon Jan 9, 2026
Hello @wanghuihhh,
Thanks for sharing the link for the model: https://autoai-oss-daily.oss-cn-hangzhou.aliyuncs.com/wanghui/openfile/model.onnx
However I do not have access to this link. Could you please provide me with the access?
In the mean time, could you also try setting the high_precision_dtype for FP32 and see if it works for your usecase?
Another approach could be converting the model to fp16 with modelopt autocast and then quantizing the model with ONNX PTQ by setting the high precision dtype as FP32.
If you have access to the original torch model, then you can also try out this example
ajrasane commentedon Mar 21, 2026
Closing this as it seems to be resolved.
[5591371] Add performance guard for ONNX Autotune (#2318)