Introduction
Structural re-parametrization and quantization are two pillars of modern efficient deep learning. Re-parametrization, exemplified by architectures like RepVGG and ACNet, utilizes complex multi-branch structures during training to enhance accuracy, which are then mathematically collapsed into simple, high-speed layers for inference. Quantization further optimizes these models by reducing the precision of weights and activations (e.g., to 8-bit or 4-bit integers).
However, these techniques are traditionally incompatible. Standard Quantization-Aware Training (QAT) requires the training and inference architectures to be identical. If individual branches are quantized separately, they cannot be merged into a single inference layer without a significant loss of precision or an increase in bit-width. RepQ addresses this gap by introducing a generalized framework that treats inference-stage weights as a differentiable function of training parameters, allowing for seamless quantization of re-parametrized models.
Methodology: Differentiable Merging
The core innovation of RepQ is the shift from quantizing individual training weights ($W_1, W_2, \dots$) to quantizing the final merged weight used at inference.
As shown in the figure above, RepQ defines a differentiable merging function $M$ that represents the collapsed inference weight. During training, the framework computes $M(W_1, \dots, W_n)$ and applies a pseudo-quantization function $Q$ directly to this result. This ensures that the network is optimized based on the actual quantized weights that will be deployed, while gradients can still flow back through the merging function to the original training parameters.
Handling Batch Normalization
Batch Normalization (BN) is critical for re-parametrization but introduces complexity during merging. RepQ offers two solutions:
- RepQ-BN: Fuses BN into the preceding convolution during training, making the entire operation differentiable.
- RepQ-BNEst (BN Estimation): An optimized variant that estimates BN statistics (mean and variance) directly from the weights and input distributions. This avoids computationally expensive convolutions during training, reducing overhead by approximately 25%.
Training Workflow Comparison
A key advantage of RepQ is its ability to maintain the benefits of re-parametrization throughout the entire training pipeline, including the QAT stage.
As illustrated in the table, "Plain" QAT never uses re-parametrization, while the "Merged" approach only uses it during initial floating-point (FP) pre-training, reverting to a regular architecture for QAT. RepQ is unique in utilizing re-parametrized blocks across both stages, maximizing the representational power of the model before final deployment.
Experimental Results
The authors evaluated RepQ across image classification (ImageNet) and super-resolution (DIV2K) tasks using architectures like ResNet-18, RepVGG, and ECBSR.
Image Classification
RepQ achieves "lossless" 8-bit quantization. For instance, RepVGG-A0 reached 73.11% accuracy with 8-bit RepQ, actually exceeding the FP32 baseline of 72.43%. In the more challenging 4-bit regime, RepQ-BNEst achieved 71.12% on RepVGG-A0, significantly outperforming both standard QAT (69.90%) and architecture-specific methods like QARepVGG.
Super-Resolution
In super-resolution tasks using the ECBSR model, RepQ consistently delivered higher Peak Signal-to-Noise Ratio (PSNR) across standard benchmarks (Set5, Set14, B100, U100) compared to traditional quantization methods, maintaining robustness even at 2-bit precision.
Conclusion and Future Work
RepQ provides a robust, architecture-agnostic framework for quantizing re-parametrized models. By quantizing the output of the merging function, it preserves the accuracy gains of complex training structures while enabling efficient low-precision inference.
While RepQ introduces some training overhead (approximately 1.65x for OREPA-ResNet-18) and requires explicit definition of the merging function $M$, its performance gains are substantial. Future research may explore combining RepQ with non-uniform quantization or pruning to further push the boundaries of model efficiency.
Summary updated