Abstract
Large Transformer models face significant performance degradation when subjected to ultra-low bit-width Post-Training Quantization (PTQ), primarily due to extreme activation distributions in LayerNorm and Softmax layers. This paper introduces RepQuant, a novel framework that employs a "quantization-inference decoupling" paradigm. By utilizing complex quantizers during calibration and mathematically transforming them into hardware-friendly formats for inference via scale reparameterization, RepQuant achieves high accuracy in 4-bit settings without sacrificing deployment efficiency.
The Challenge: Extreme Activations in Transformers
Large models like LLaMA and ViT are resource-intensive. PTQ aims to reduce their footprint by converting high-precision weights and activations into low-bit integers (e.g., 4-bit). However, Transformers exhibit two problematic activation patterns:
- LayerNorm Activations: Significant inter-channel variation and asymmetric outliers make standard layer-wise quantization ineffective.
- Softmax Activations: A "power-law" distribution where a few large values dominate attention mechanisms, requiring high precision in specific ranges.
Existing methods often force these distributions into hardware-compatible formats prematurely, leading to severe accuracy drops or model "crashes" at low bit-widths.
The RepQuant Paradigm
RepQuant addresses these issues by breaking the traditional dependency between calibration-time quantization and inference-time execution. This "decoupling" allows researchers to prioritize accuracy during the calibration phase while ensuring the final model remains optimized for hardware.
Scale Reparameterization
The core innovation is Scale Reparameterization, a technique that allows the use of complex quantizers during calibration which are then mathematically "folded" into simpler forms for inference.
- LayerNorm: RepQuant uses accurate channel-wise quantization during calibration. For inference, these per-channel scales are mathematically integrated into the weights and biases of the subsequent layer, resulting in efficient layer-wise quantization with no loss in mathematical precision.
- Softmax: A log$\sqrt{2}$ quantizer is used during calibration to fit the power-law distribution. This is then reparameterized into a standard log2 format for inference, enabling high-speed execution via bit-shifting operations.
Per-Channel Dual Clipping
To manage asymmetric outliers in LayerNorm, RepQuant employs a learnable clipping scheme. Using a Sigmoid-based optimization, it identifies optimal upper and lower bounds for each channel, effectively pruning damaging outliers before the quantization process begins. This is combined with weight reconstruction (using the GPTQ algorithm) to further minimize error.
Key Results and Evaluation
RepQuant was evaluated across diverse architectures, including ViT, LLaMA (up to 65B), and the Segment Anything Model (SAM) on standard benchmarks like ImageNet, WikiText2, and COCO.
- Vision Tasks: On DeiT-S (W4/A4), while previous state-of-the-art methods like FQ-ViT failed completely (0.1% accuracy), RepQuant maintained 75.21% accuracy, only ~4.6% off the full-precision model.
- Language Tasks: For LLaMA-7B, RepQuant achieved a 20% improvement in average zero-shot accuracy over SmoothQuant in 4-bit configurations.
- Efficiency: Because the reparameterization is mathematically equivalent, the final model runs using standard hardware-friendly operations, ensuring no latency overhead compared to traditional PTQ.
Conclusion
RepQuant demonstrates that hardware constraints should not dictate the calibration process. By decoupling quantization from inference, it provides a robust path for deploying large Transformer models on resource-constrained hardware at ultra-low bit-widths while maintaining near-original performance. Future work may extend these principles to even lower bit-widths, such as 2-bit or binary quantization.
Summary updated