Introduction
Quantization-aware training (QAT) is the standard approach for deploying deep learning models on edge devices with limited memory and compute power. By simulating low-precision arithmetic (such as 2-bit or 4-bit) during the training process, models can learn to compensate for the precision loss. However, Vision Transformers (ViTs) have proven notoriously difficult to quantize at ultra-low bit-widths. This paper identifies "weight oscillation" as the primary barrier to convergence and introduces Oscillation-Free Quantization (OFQ), a suite of techniques designed to stabilize training and achieve state-of-the-art accuracy in low-bit ViTs.
The Problem: Weight Oscillation
Weight oscillation occurs when weights frequently jump between two discrete quantized levels (e.g., fluctuating between -1 and 0) during training. This instability prevents the model from settling into an optimal solution. The authors identify two specific mechanisms that exacerbate this in ViTs:
- Instability of Learnable Scaling Factors: Modern QAT methods often use learnable parameters to determine the optimal range for quantization. In ViTs, these scaling factors are highly sensitive to outlier weights. A single outlier can shift the quantization threshold for an entire layer, pushing previously stable weights into an "oscillation zone," which in turn further destabilizes the scaling factor.
- Query-Key Interdependence: In the self-attention mechanism, the weights for queries (Q) and keys (K) are mathematically intertwined. Oscillation in the query weights corrupts the gradient estimation for the key weights, leading to a phenomenon the authors term "co-oscillation."
Proposed Methodology: Oscillation-Free Quantization (OFQ)
To address these challenges, the authors propose three novel components that collectively form the OFQ framework:
Statistical Weight Quantization (StatsQ)
Rather than treating the quantization scaling factor as a learnable parameter subject to noisy backpropagation, StatsQ calculates it analytically. By using a formula derived from maximum information entropy based on the weight distribution, StatsQ provides a threshold that is robust to outliers. This ensures a much smoother training trajectory compared to gradient-based scaling methods.
Confidence-Guided Annealing (CGA)
CGA is a specialized fine-tuning phase designed to "calm" the remaining oscillating weights. The algorithm identifies "high confidence" weights—those that have settled far from the quantization thresholds—and freezes them. The training then focuses exclusively on the "low confidence" weights near the thresholds, gradually encouraging them to settle into stable states.
Query-Key Reparameterization (QKR)
To break the cycle of co-oscillation in self-attention, QKR reorders the matrix multiplication operations. By mathematically decoupling the query and key weights during the backward pass, QKR prevents the gradient of one from being corrupted by the oscillation of the other, effectively isolating the noise.
Experimental Evaluation
The researchers evaluated OFQ on the ImageNet-1K classification benchmark using three popular architectures: DeiT-T (Tiny), DeiT-S (Small), and Swin-T (Swin Transformer-Tiny).
Key Results
OFQ demonstrates significant performance gains, particularly at the 2-bit level, where previous methods struggled to maintain accuracy:
- 2-bit Performance: OFQ outperformed the previous state-of-the-art (QViT) by 9.8% on DeiT-T, 7.7% on DeiT-S, and 4.64% on Swin-T. For DeiT-S, the 2-bit model reached 75.72% accuracy, a massive leap from the 68% achieved by standard LSQ.
- Near-Lossless 3-bit Quantization: The 3-bit DeiT-T model achieved 72.72% accuracy, which actually exceeds the full-precision (32-bit) baseline of 72.02%. This suggests that the stabilization techniques in OFQ may provide a beneficial regularization effect.
Conclusion and Future Work
OFQ effectively mitigates the weight oscillation problem in Vision Transformers, enabling high-performance quantization at ultra-low bit-widths. While the QKR component is currently specific to the self-attention mechanism, the principles of StatsQ and CGA are broadly applicable. Future research may explore extending these "oscillation-free" strategies to other architectures and complex tasks such as object detection and natural language processing. Although the CGA phase adds a small computational overhead (approximately 25 additional epochs), the resulting gains in model efficiency and accuracy make it a compelling solution for edge deployment.
Summary updated