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
How does Model Optimizer compare with the default Tensorrt 10 Optimisations? #5
e.g convert onnx to tensorrt using trtexec v/s using this model optimizer to generate the optimised tensorrt engine?
Which engine will give faster speeds?
Assuming this question is related to ONNX quantization, certain models can achieve faster speeds with the default TensorRT 10 implicit quantization (IQ), but ModelOpt's explicit quantization (EQ) will generally yield faster speeds for most network types, especially for Vision Transformers (ViTs). If users find that their network is not faster with ModelOpt quantization, they should file a bug report with a reproducible example.
TensorRT will depreciate IQ in future releases and recommend EQ for users seeking better speed improvements and accuracy control.
My question is, where does this Tensorrt-Model-Optimizer fit into all of this, and will it give better speeds than the current pipeline.
Users can use Tensorrt-Model-Optimizer (aka modelopt) to deploy models with lower precisions like fp8, int8 and int4. For fp16 engine deployment, users won't need modelopt.
Typically, users would generate the TensorRT engine with int8 precision using the following simplified command:
With above, TensorRT will use implicit quantization (IQ) to select the precision of different layers of the model. While IQ can still work better for some CNN models in terms of performance, it does not support Transformer based models, lacks reproducibility, provides no accuracy control for the users and only supports int8 quantization mode. modelopt aims to alleviate most of these issues.
With modelopt, users will do these two steps instead, explicit quantization (EQ) followed by trtexec compilation:
In case of int8, while explicit quantization (EQ) is anticipated to enhance the accuracy of the model, it is not assured to yield better speeds compared to the current implicit quantization (IQ) pipeline for all network types. For instance, certain models may still achieve faster inference speeds using the IQ workflow. Thus, it's crucial to assess the specific characteristics of your model to determine the most appropriate optimization approach.
@riyadshairi979 I am currently using the ONNX_PTQ pipeline to generate an int8 quantized ONNX model, and the int8 quantized ONNX model performs well. However, when I convert the quantized ONNX model into a .engine file, the accuracy drops to zero. I've tried both the --best and --int8 flags, but the results are the same in both cases.
Activity
i-riyad commentedon May 15, 2024
Assuming this question is related to ONNX quantization, certain models can achieve faster speeds with the default TensorRT 10 implicit quantization (IQ), but ModelOpt's explicit quantization (EQ) will generally yield faster speeds for most network types, especially for Vision Transformers (ViTs). If users find that their network is not faster with ModelOpt quantization, they should file a bug report with a reproducible example.
TensorRT will depreciate IQ in future releases and recommend EQ for users seeking better speed improvements and accuracy control.
yuvraj108c commentedon May 16, 2024
The most popular tensorrt optimisation pipeline is to first export a
.pthmodel to.onnx, e.gthen, convert the onnx model to tensorrt, e.g using trtexec
My question is, where does this Tensorrt-Model-Optimizer fit into all of this, and will it give better speeds than the current pipeline.
i-riyad commentedon May 16, 2024
Users can use Tensorrt-Model-Optimizer (aka
modelopt) to deploy models with lower precisions likefp8,int8andint4. Forfp16engine deployment, users won't needmodelopt.Typically, users would generate the TensorRT engine with
int8precision using the following simplified command:With above, TensorRT will use implicit quantization (IQ) to select the precision of different layers of the model. While IQ can still work better for some CNN models in terms of performance, it does not support Transformer based models, lacks reproducibility, provides no accuracy control for the users and only supports
int8quantization mode.modeloptaims to alleviate most of these issues.With
modelopt, users will do these two steps instead, explicit quantization (EQ) followed bytrtexeccompilation:In case of
int8, while explicit quantization (EQ) is anticipated to enhance the accuracy of the model, it is not assured to yield better speeds compared to the current implicit quantization (IQ) pipeline for all network types. For instance, certain models may still achieve faster inference speeds using the IQ workflow. Thus, it's crucial to assess the specific characteristics of your model to determine the most appropriate optimization approach.yuvraj108c commentedon May 17, 2024
Thanks for the clarifications!
It now makes more sense.
--fp16 --int8can be used at the same time?i-riyad commentedon May 17, 2024
Yes, it is equivalent to using
--best.sriram487 commentedon Feb 6, 2025
@riyadshairi979 I am currently using the ONNX_PTQ pipeline to generate an int8 quantized ONNX model, and the int8 quantized ONNX model performs well. However, when I convert the quantized ONNX model into a .engine file, the accuracy drops to zero. I've tried both the --best and --int8 flags, but the results are the same in both cases.
modelopt: strip cache kwargs at capture + replay so layerwise calib n…
quanty: K2.6 recipe block_sizes.type static -> dynamic for NVFP4 disp…
[OMNIML-4788] specdec_bench: address @kevalmorabia97 review on PR 1531