TL;DR
Reparameterized models like RepVGG offer blazing-fast inference but traditionally "break" during post-training quantization (PTQ). This paper introduces RepAPQ, a framework that restores accuracy by swapping standard Mean Squared Error (MSE) for Mean Absolute Error (MAE) and introducing a "Quantization Protecting" affine layer to gracefully handle the extreme outliers that typically plague these architectures.
What Problem Does This Paper Address?
Structural reparameterization is a modern "cheat code" in deep learning: you train a complex model with multiple branches (like 3x3 convs, 1x1 convs, and identity mappings) and then fuse them into a single, simple convolution for inference. This gives you the performance of a complex network with the speed of a plain one.
However, these models are notoriously difficult to quantize (converting 32-bit floats to 8-bit integers). Standard PTQ methods often cause massive accuracy drops. The authors identify the culprit: outliers. Because of the BatchNorm layers used during training, certain channels produce activation values that are orders of magnitude larger than the rest. When standard quantization tries to fit these outliers, it "squashes" the normal values into a tiny range, destroying the model's information entropy and, consequently, its accuracy.
Methods
The authors propose a two-pronged framework called RepAPQ:
- Quantization Protecting Reparameterization (QPRep): Instead of just fusing branches into a single convolution, the authors insert a channel-wise affine layer after the convolution during the calibration phase. This layer adaptively amplifies features to better accommodate outliers. During inference, these affine parameters are folded into the quantization scales and biases, meaning there is zero extra computational cost at runtime.
- Across-block Calibration (ABC): Standard PTQ usually optimizes one layer at a time using Mean Squared Error (MSE). The authors argue that MSE is too sensitive to outliers (it penalizes large errors quadratically). They switch to Mean Absolute Error (MAE), which is more robust. To fix the gradient issues that sometimes come with MAE, they use the output of an entire "stage" (multiple blocks) as a supervision signal, ensuring that errors don't accumulate across the network.
Datasets
The researchers evaluated RepAPQ on two primary benchmarks:
- ImageNet: For image classification, testing across the RepVGG and MobileOne families.
- COCO: For object detection, specifically using the YOLOv6 series (which utilizes RepVGG blocks).
Key Insights and Ideas
- The MSE Trap: Most quantization tools use MSE to find the best "clipping range." If a channel has one massive outlier, MSE will widen the range to catch it, which effectively rounds all the useful, smaller values to zero. MAE acts as a "median-seeking" metric that prioritizes the majority of the data.
- Outlier Propagation: The authors observed that outliers in early layers often trigger outliers in subsequent layers. By managing them at the source (the "Quantization Protecting" layer), the entire downstream "outlier phenomenon" is attenuated.
- Information Entropy: The paper highlights that naive quantization of reparameterized models leads to values clustering at the very bottom of the bit-range. By using MAE and QPRep, they maintain higher information entropy, meaning the 8-bit (or 6-bit) values are used more effectively to represent the original signal.
Key Results
RepAPQ sets a new state-of-the-art for quantizing these specific architectures:
- 8-bit PTQ: On RepVGG models, RepAPQ achieves accuracy within 0.5% of the full-precision (FP32) model, outperforming previous methods by about 1%.
- 6-bit PTQ: The gap widens at lower bit-widths. For 6-bit quantization, RepAPQ outperforms competitors by roughly 2-3%, making low-bit reparameterized models viable for the first time.
- Object Detection: On YOLOv6, RepAPQ consistently outperformed "naive" quantization and other advanced methods like AdaQuant, particularly on "quantization-unfriendly" versions of the model.
Limitations and Future Work
While highly effective for VGG-style reparameterized models, the authors note that their method might not perform as well on depth-wise convolutions at very low bit-widths (like 4-bit).
Future research directions include:
- Extending the framework to more complex, non-VGG architectures.
- Addressing the specific challenges of depth-wise separable convolutions in the context of reparameterization and quantization.
- Exploring even lower bit-precisions (4-bit) while maintaining the "zero-cost" inference philosophy.
Summary updated