Q-DETR: An Efficient Low-Bit Quantized Detection Transformer

Sheng Xu, Yanjing Li, Mingbao Lin, Peng Gao, Guodong Guo, Jinhu Lu, Baochang ZhangCVPR 2023 · DOI

Abstract

Detection Transformers (DETR) have set new benchmarks in object detection, yet their deployment on resource-constrained devices is hindered by high computational and memory demands. Quantization offers a path to efficiency, but conventional low-bit methods often lead to severe performance degradation in DETR models. We identify query information distortion as the primary bottleneck. To address this, we propose Q-DETR, a framework based on Distribution Rectification Distillation (DRD). By formulating DRD as a bi-level optimization problem derived from the Information Bottleneck principle, we align query distributions and introduce a foreground-aware matching scheme. Our 4-bit Q-DETR achieves 39.4% AP on COCO with a ResNet-50 backbone, offering a theoretical 6.6x acceleration with only a 2.6% performance gap compared to the real-valued model.

Introduction

While DETR simplifies object detection by removing hand-crafted components like Non-Maximum Suppression (NMS), its standard implementation (e.g., ResNet-50 backbone) requires approximately 86 GFLOPs and 159MB of memory. This footprint is prohibitive for edge and mobile deployment. Quantization to low bit-widths (e.g., 3-bit or 4-bit) is a standard compression technique, but in DETR, it typically causes a "performance cliff." The authors pinpoint the issue to the transformer's queries: quantization distorts their statistical distribution, leading to inaccurate spatial attention and poor object localization.

Methodology: Distribution Rectification Distillation (DRD)

The core of Q-DETR is the DRD framework, which treats quantization-aware training as an Information Bottleneck (IB) problem. The goal is to maximize the information retained in the quantized "student" model while minimizing noise.

The Q-DETR architecture features a quantized decoder and a bi-level optimization process for distillation.

The DRD process operates at two levels:

  1. Inner-Level (Distribution Alignment): Empirical analysis shows that query values in DETR follow a Gaussian distribution. Q-DETR uses a distribution alignment module to shift and scale student queries, maximizing their self-information entropy to match the teacher's distribution.
  2. Upper-Level (Foreground-Aware Query Matching): To prevent the student from learning from "noisy" background queries, a matching scheme filters for high-quality queries that overlap with ground-truth objects. Distillation is then focused on these foreground-aware features to minimize conditional information entropy.

Key Insights and Empirical Analysis

A critical discovery was the Gaussian nature of query distributions across different decoder layers. Quantization tends to skew these distributions, which directly impacts the model's ability to attend to the correct image regions.

Histograms comparing query value distributions between real-valued and 4-bit DETR-R50 across different decoder layers.

By rectifying these distributions, Q-DETR ensures that the quantized queries maintain the representational power of their full-precision counterparts. This "refocuses" the model's attention, preventing the "wandering eyes" effect where attention maps become blurry or displaced under low-bit quantization.

Experimental Results

Q-DETR was evaluated on the PASCAL VOC and COCO 2017 datasets, demonstrating state-of-the-art performance for quantized detection transformers.

  • COCO Performance: A 4-bit Q-DETR with a ResNet-50 backbone achieved 39.4% AP, significantly narrowing the gap to the real-valued baseline (42.0% AP).
  • Efficiency Gains: The 4-bit model provides a 6.6x theoretical acceleration in operations and reduces memory usage from 159MB to approximately 20MB.
  • Robustness at Low Bits: At 3-bit quantization on VOC, Q-DETR reached 82.1% AP₅₀, outperforming the standard LSQ baseline (75.3% AP₅₀) by a wide margin.

Conclusion

Q-DETR successfully bridges the gap between high-performance detection transformers and efficient low-bit execution. By addressing query information distortion through distribution rectification and foreground-aware distillation, it enables the deployment of DETR on resource-constrained hardware. Future research may extend these techniques to even lower bit-widths (2-bit or 1-bit) or apply them to large-scale vision-language models.

Summary updated

BibTeX
@inproceedings{xu2023q,
  author = {Sheng Xu and Yanjing Li and Mingbao Lin and Peng Gao and Guodong Guo and Jinhu Lu and Baochang Zhang},
  title = {{Q-DETR: An Efficient Low-Bit Quantized Detection Transformer}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  doi = {10.1109/cvpr52729.2023.00374},
}
Figure