Closed tp111222 closed 10 months ago
It is quite common that TensorRT QAT model is slower than PTQ model . Maybe Q-DQ not set right, so fusion bad.
Yes.
this is yolov8m quant model:
https://pan.baidu.com/s/1MC7BYxs71wzLdEqXBHmF-Q?pwd=ysha
How to set Q-DQ correctly?
We have some guidance about this topic, see https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html#qdq-placement-recs
This is not a trivial task and needs some try and run.
@zerollzeng this is yolov8 quant svg file
Can you give us some guidance on which nodes to optimize
Can you give me some guidance on which nodes to optimize?
Well it's hard to analyze through the image...
A way to check with the log: Build a PTQ engine(e.g. with trtexec --int8 --fp16) and compare the final engine(in the verbose log) with the QAT engine. check the different between them, e.g. layer precision(some layer may still running in FP16 in the QAT model) and layer fusions(redundant Q/DQ may break the layer fusion)
@zerollzeng What should I do after I find out that PTQ engine and QAT engine are different?
You can check it in the verbose log. there is a section call "Engine Layer Information"
@zerollzeng 还是用中文交流吧,我的意思是,对比了PTQ engine 和 QAT engine 不同后,接下来该怎样去优化QAT engine ,使其到达PTQ engine的性能
最终的目标是:让你的qat model build出来的engine结构和ptq的一样(有可能会导致精度下降,需要自己权衡),奔着这个目标去调整优化Q/DQ节点(pytorch-quantization)的摆放
Based on my result, I guess PTQ has full int8 but less performence on yolo. QAT has many reformat layer consume too many times (INT8-FP32/FP16), you can use engine profiler to get similar result. Replace SiLU to ReLU and re-train the model, then add Q/DQ and finetune the model again. The model has larger chance to INT8, otherwise, use full fp16 will get best inference time.
借个楼. Do TRT have any suggestions for the quantization deployment of transformer architecture with int8? (considering both speed and precision, with PTQ by calibration or pytorch-QAT or anything else?) @zerollzeng Thanks!
There are some progress and effort about this, I'll let @ttyio to answer the question.
For transformer, we will release some new demo with FP8 and INT8 in the coming months using Q/DQ nodes. Thanks!
thanks! where will it be released? @ttyio
@WeixiangXu sorry we need wait for the official announcement. thanks!
Now the TensorRT-LLM is released in https://github.com/NVIDIA/TensorRT-LLM closing and thanks all!
@zerollzeng this is yolov8 quant svg file !
Hey bro, how did you get this svg image?
@zerollzeng this is yolov8 quant svg file !
Hey bro, how did you get this svg image?
trex
https://github.com/NVIDIA/TensorRT/tree/release/8.6/tools/experimental/trt-engine-explorer
Description
Yolov8m TensorRT QAT model is slower than PTQ model
Environment
TensorRT Version: 8.4.1.5 NVIDIA GPU: RTX2080 NVIDIA Driver Version:
CUDA Version: CUDA11.1 CUDNN Version:
Operating System:
Python Version (if applicable):
Tensorflow Version (if applicable):
PyTorch Version (if applicable):
Baremetal or Container (if so, version):
Relevant Files
Model link:
Steps To Reproduce
Commands or scripts:
Have you tried the latest release?:
Can this model run on other frameworks? For example run ONNX model with ONNXRuntime (
polygraphy run <model.onnx> --onnxrt
):PTQ inter time:![69d1c9f9d5548dfe1462bfb3cc30ba5](https://github.com/NVIDIA/TensorRT/assets/12984410/44783959-6cb5-4254-91de-6840b6c7e405)
QAT infer time:![70bd9864e94965abedf1f716116ef2f](https://github.com/NVIDIA/TensorRT/assets/12984410/e6181236-e89c-45c2-bc92-038816e3ef50)