NVIDIA / NVIDIA/Model-Optimizer
Bringing Back Effective Quantization: Using ModelOPT for YOLO and Similar Architectures
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 604
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 142
Description
I have developed a project YOLOv9-QAT to perform quantization using QAT for models based on the YOLO architecture using discontinued nvidia pytorch-quantization library.
However, I faced several challenges while using modelopt and noticed that some functions have been changed. Due to the model's complexity and the need for greater control over the insertion of QDQ nodes, we had to configure it in a rule-based manner, ensuring that the setup is optimal under TensorRT. This involved making sure that all nodes are running in INT8.
I have seen many recommendations to use ONNX PTQ Toolkit to quantize ONNX models, but the results have been unsatisfactory.
It would be interesting to revive this repository: https://github.com/NVIDIA-AI-IOT/yolo_deepstream/tree/main/yolov7_qat as an example for performing quantization in FP8, INT8, or INT4 on models with similar architectures, such as ResNet, among others. This would help the community implement quantization for detection and segmentation models that use similar architectures.
Another point is that exporting the QAT model from PyTorch to ONNX offers flexibility for exporting using TensorRT plugins, such as EfficientNMS, among others. However, if I try to quantize ONNX models exported with plugins using the ONNX PTQ Toolkit, it results in an error during quantization. This forces me to perform quantization directly in PyTorch and then export to ONNX.
My main goal is to get a direction to achieve the same or better results using modelopt as we did with the pytorch-quantization library.
Results:
Evaluation Results
Activation SiLU
| Eval Model | AP | AP50 | Precision | Recall |
|---|---|---|---|---|
| Origin (Pytorch) | 0.529 | 0.699 | 0.743 | 0.634 |
| INT8 (Pytorch) | 0.529 | 0.702 | 0.742 | 0.63 |
| INT8 (TensorRT) | 0.529 | 0.696 | 0.739 | 0.635 |
Activation ReLU
| Eval Model | AP | AP50 | Precision | Recall |
|---|---|---|---|---|
| Origin (Pytorch) | 0.519 | 0.69 | 0.719 | 0.629 |
| INT8 (Pytorch) | 0.518 | 0.69 | 0.726 | 0.625 |
| INT8 (TensorRT) | 0.517 | 0.685 | 0.723 | 0.626 |
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.
Assessment
This issue has not been assessed yet.