Introduction
Post-Training Quantization (PTQ) is a critical technique for compressing and accelerating neural networks, making it feasible to deploy massive Vision Transformers (ViTs) on resource-constrained edge devices. By converting a model’s weights and activations from high-precision floating-point numbers (like FP32) to low-bit integers (like INT4), PTQ drastically reduces memory footprint and latency. However, as model sizes increase, a severe challenge emerges: the detrimental impact of activation outliers on the accuracy of quantized transformer architectures.
The Heavy-Tail Outlier Problem
ViTs notoriously suffer from a "heavy-tail" distribution problem, where a small fraction of activation values (outliers) are significantly larger than the rest. In standard PTQ, these extreme outliers force the quantization scale to be excessively wide. This wide scale effectively "squashes" the precision of all normal, non-outlier values into a tiny range near zero, leading to a massive drop in model accuracy. In fact, excluding just the top 5% of outliers can reduce quantization error by two orders of magnitude.
While previous research has attempted to clip or mathematically transform these outliers, this paper identifies a powerful, previously neglected factor: reconstruction granularity. This concept asks a fundamental question: how much of the model should we look at simultaneously when trying to minimize quantization error?
Methodology: Outlier-Aware Slicing
To address this, the authors propose Outlier-Aware Slicing, a method focused on finding the optimal "slice" of the model to optimize during the PTQ process. Instead of defaulting to layer-by-layer optimization, this approach leverages reconstruction granularity through two main strategies:
- Coarse Granularity: Optimizing multiple consecutive blocks together.
- Fine Granularity: Optimizing sub-components within a single block.
To achieve fine-grained control, the authors partition the standard transformer block into three distinct modules: Self-Attention (Module A), Out Projection (Module B), and the MLP (Module C). As demonstrated in the slicing configurations, the choice of which modules to optimize together significantly impacts the final accuracy.
The Role of Topological Homogeneity
The decision to use coarse or fine granularity depends entirely on the architecture's "Transformer-Like Topological Homogeneity"—whether the blocks share the same structure and operators throughout the network.
- Homogeneous Models (e.g., standard ViT and DeiT): For these architectures, coarser granularity is superior. Optimizing 3-4 blocks together allows the optimization process to better "absorb" and distribute the impact of outliers across the sequence.
- Heterogeneous Models (e.g., Swin Transformers): Models that break homogeneity, such as Swin Transformers with their downsampling stages, require finer granularity. Because Swin models accumulate outliers primarily in their third stage and use downsampling between stages, a "global" or coarse optimization across the whole model destabilizes gradient flow. Therefore, they benefit from optimizing sub-modules (A, B, and C) individually.
Key Results
By tailoring the reconstruction granularity to the specific architecture, Outlier-Aware Slicing achieves state-of-the-art (SOTA) PTQ performance, particularly in challenging 4-bit quantization scenarios on the ImageNet classification task:
- Swin-Base (4-bit): Reached 82.24% Top-1 accuracy, outperforming the previous SOTA (RepQ-ViT) by a massive 3.92%.
- ViT-Small (4-bit): Achieved 80.50% accuracy, surpassing NoisyQuant by 3.64%.
- DeiT-Tiny (4-bit): Reached 66.31%, an impressive 8.88% improvement over RepQ-ViT.
Furthermore, the authors successfully extended their method to Large Language Models (LLMs). When integrated with OmniQuant on Llama-2-7B, the slicing technique further reduced perplexity from 11.06 to 9.51 on the WikiText2 dataset.
Limitations and Future Work
While Outlier-Aware Slicing provides a robust theoretical and empirical framework for transformer quantization, several avenues remain for future exploration:
- Expanded Search Space: Current experiments limited the "coarse" search to combinations of up to 3-4 blocks. Larger slices could potentially yield benefits for extremely deep models, albeit at a higher computational cost during the optimization phase.
- Automated Slicing: The process of slicing internal modules currently relies on manual architectural heuristics. Future work could involve a fully automated search algorithm to discover the optimal slicing configuration without human intervention.
- Hardware Efficiency: The primary focus of this work is recovering task accuracy. While quantization inherently improves inference speed, the specific impact of different slicing granularities on actual hardware latency—due to potential shifts in memory access patterns—warrants deeper investigation.
Summary updated