Improving Post-Training Quantization on Object Detection with Task Loss-Guided Lp Metric

Lin Niu, Jiawei Liu, Zhihang Yuan, Dawei Yang, Xinggang Wang, Wenyu LiuarXiv 2023 · DOI

Abstract

Post-training quantization (PTQ) is a critical technique for deploying deep learning models on resource-constrained edge devices. However, standard PTQ methods often suffer from significant performance degradation in complex tasks like object detection, primarily due to the use of fixed error metrics like Mean Squared Error ($L_2$) across all network layers. This paper introduces DetPTQ, a novel framework that adaptively selects the optimal $L_p$ metric for each layer guided by a task-specific Object Detection Output Loss (ODOL). By bridging the gap between local reconstruction error and global task performance, DetPTQ achieves state-of-the-art results, reducing the accuracy gap to less than 1% mAP for 4-bit quantized models on standard benchmarks.

Introduction

The deployment of high-performance object detection models on edge devices—such as smartphones, autonomous vehicles, and IoT sensors—requires aggressive model compression. Quantization, the process of mapping high-precision floating-point weights and activations to low-bit integers, is a primary strategy for achieving this. Post-Training Quantization (PTQ) is particularly attractive as it avoids the high computational cost and data requirements of Quantization-Aware Training (QAT).

Despite its advantages, PTQ frequently encounters an "accuracy cliff" when applied to object detection. Unlike simple classification, object detection requires both categorical prediction and precise bounding box regression across multiple spatial scales. Traditional PTQ methods typically minimize a fixed reconstruction error (usually $L_2$) between original and quantized feature maps. This "one-size-fits-all" approach ignores the varying sensitivities of different layers to quantization noise, leading to sub-optimal performance.

The DetPTQ Framework

The core innovation of DetPTQ is the realization that the optimal quantization metric depends on the specific role a layer plays in the final detection task. The framework introduces two key components: an adaptive $L_p$ metric search and the Object Detection Output Loss (ODOL).

Figure 1: Visualization of how different layers (Layer 4.1 vs Layer 1.1) respond differently to quantization metrics ($L_2$ vs $L_4$), impacting the final mAP.
  1. Adaptive $L_p$ Metric: Instead of a fixed $L_2$ norm, DetPTQ treats the power $p$ in the $L_p$ metric as a per-layer hyperparameter. By searching through a range of $p$ values (e.g., 1.5, 3.0, 4.5), the method can better preserve the specific information required by different parts of the network.
  2. Object Detection Output Loss (ODOL): To guide the selection of $p$ without requiring labeled training data, the authors developed ODOL. This loss measures the discrepancy between the outputs of the full-precision (FP) teacher model and the quantized student model. ODOL combines a classification loss (KL Divergence) and a localization loss ($L_1$ distance between bounding box coordinates).
  3. Two-Step Optimization: The optimization proceeds block-by-block. First, the algorithm identifies the $p$ value that minimizes the ODOL for the current block. Second, it fine-tunes the quantization parameters (scale factors and rounding weights) using the chosen $L_p$ metric. This ensures that local quantization decisions are globally informed by the final task objectives.

Experimental Results

The researchers evaluated DetPTQ on the COCO dataset for 2D detection and the KITTI dataset for 3D detection using models like RetinaNet, Faster R-CNN, and PointPillar.

Figure 5: Normalized loss curves for various layers in Faster RCNN-ResNet18. The task-specific loss (red) often aligns better with specific $L_p$-based metrics depending on the layer.

On the COCO benchmark, DetPTQ demonstrated remarkable robustness. For a RetinaNet-ResNet18 model with 4-bit weights and activations (W4A4), DetPTQ achieved 31.1% mAP, nearly matching the full-precision baseline of 31.7%. This significantly outperformed existing state-of-the-art PTQ methods like BRECQ and QDrop. In even more constrained settings, such as W2A4 (2-bit weights), DetPTQ improved the mAP of RetinaNet-ResNet50 by 1.42% over previous best results.

The framework's versatility was further proven on 3D object detection. Using the PointPillar model on the KITTI dataset, DetPTQ reduced the performance drop significantly, outperforming QDrop by over 3% in certain categories. This suggests that the task-loss guidance is effective across different data modalities and model architectures.

Discussion and Insights

A key insight from this work is the layer-wise sensitivity to quantization. High-level layers, responsible for detecting larger objects, often favor different $L_p$ metrics than low-level layers focused on fine-grained details. For instance, larger $p$ values can help preserve the small activations necessary for detecting tiny objects, which might otherwise be zeroed out by standard $L_2$-based quantization.

Furthermore, the study highlights that while model weights are relatively robust to quantization, activations are highly sensitive. The adaptive choice of the $L_p$ metric is particularly crucial for maintaining the integrity of activation maps throughout the network.

Conclusion and Future Work

DetPTQ represents a significant step forward in making post-training quantization viable for complex computer vision tasks. By replacing rigid error metrics with a task-guided adaptive approach, it bridges the gap between local optimization and global performance. While the search for optimal $p$ values introduces some computational overhead compared to basic PTQ, the resulting gains in accuracy make it a compelling choice for high-precision edge deployment. Future work may involve extending this methodology to vision transformers and automating the tuning of the ODOL balancing hyperparameters.

Summary updated

BibTeX
@misc{niu2023improving,
  author = {Lin Niu and Jiawei Liu and Zhihang Yuan and Dawei Yang and Xinggang Wang and Wenyu Liu},
  title = {{Improving Post-Training Quantization on Object Detection with Task Loss-Guided Lp Metric}},
  year = {2023},
  eprint = {2304.09785},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.09785},
}
Figure