Abstract
Post-training quantization (PTQ) is essential for deploying massive deep neural networks on resource-constrained edge devices. However, traditional rounding mechanisms in PTQ often introduce significant quantization errors. FlexRound introduces a novel PTQ approach that replaces additive weight-rounding with an element-wise division mechanism. This shift allows for the joint optimization of quantization grid sizes and individual weight scales, granting higher-magnitude weights greater flexibility. The result is better preserved accuracy across challenging architectures, from MobileNetV2 to large language models like LLaMA.
The Challenge of Post-Training Quantization
To run massive deep learning models on smartphones or edge devices, high-precision 32-bit floating-point weights must be converted into low-precision formats, such as 4-bit or 8-bit integers. While Quantization-Aware Training (QAT) is the gold standard for maintaining accuracy, it requires the full original dataset and massive computational resources.
Post-Training Quantization (PTQ) offers a faster, more practical alternative. However, PTQ frequently suffers from "rounding error." Standard nearest-integer rounding is often sub-optimal. Recent state-of-the-art methods, such as AdaRound, use optimization to "learn" whether to round a weight up or down. Despite their improvements, these methods suffer from two major flaws:
- Limited Flexibility: They typically restrict a weight to move only to the single nearest higher or lower integer.
- Fixed Grids: They struggle to optimize the global quantization "step size" (grid size) simultaneously while learning individual rounding decisions.
The FlexRound Approach
FlexRound departs from the standard "weight + learned offset" approach by formulating quantization using element-wise division:
$$ \widehat{W} = s_1 \lfloor W / S \rceil $$
Here, $s_1$ represents the common grid size, and $S$ is a learnable division factor.
The Advantage of Division
The core innovation of FlexRound stems from the reciprocal rule of derivatives. In calculus, the gradient of a function involving division ($1/x$) is proportional to the numerator. In the context of FlexRound, the gradient used to update the scale $S$ is proportional to the magnitude of the weight $W$.
This dynamic creates a natural priority system: weights with larger magnitudes—which are typically more critical to a model's performance—receive proportionally larger updates. Consequently, important weights can "jump" across multiple quantization levels if doing so minimizes the reconstruction error. This breaks the strict "up-or-down" constraint of previous methods.
Furthermore, FlexRound jointly learns the global grid ($s_1$) and the individual scales ($S$) using a small calibration dataset (e.g., 1024 images) to minimize the mean squared error between the original and quantized layer outputs.
Broad Evaluation Across Domains
The researchers evaluated FlexRound across an unusually broad spectrum of tasks and architectures:
- Computer Vision: ImageNet classification using ResNet-18, ResNet-50, and the notoriously difficult-to-quantize MobileNetV2.
- Natural Language Understanding (NLU): The GLUE benchmark (MNLI, QQP, MRPC, etc.) using BERT and GPT-Neo.
- Natural Language Generation (NLG): WikiText2, Penn Treebank (PTB), and WebNLG using GPT-2, GPT-Neo, and OPT.
- Large Language Models (LLMs): Zero-shot and five-shot reasoning tasks (BoolQ, PIQA, HellaSwag, etc.) using the LLaMA family (7B to 33B parameters).
Key Results and Insights
FlexRound consistently outperformed previous state-of-the-art PTQ methods across all tested domains:
- Magnitude-Aware Flexibility: By allowing larger weights more "room to move" during optimization, FlexRound better preserves the most critical features of the network.
- MobileNetV2 (4-bit): FlexRound achieved 70.82% Top-1 accuracy on ImageNet, significantly outperforming AdaRound's 69.46%.
- LLMs (LLaMA-33B): On the WikiText2 perplexity test (where lower is better), FlexRound achieved a score of 6.82, remarkably close to the FP16 baseline of 6.35. In contrast, AdaRound lagged significantly at 10.39.
- Efficiency: The method achieves near-lossless 8-bit quantization for massive models like LLaMA without relying on specialized assumptions about "activation outliers," a common crutch in other LLM quantization literature.
Limitations and Future Directions
While highly effective, FlexRound does have limitations. Although much faster than full retraining, it still requires an iterative optimization process (e.g., 5,000 to 20,000 iterations per block), making it slower than "one-shot" quantization methods.
Additionally, the authors explored combining FlexRound with additive methods (like AdaQuant) but found the results were not yet superior to FlexRound alone. Finding a successful hybrid approach remains a promising future direction. Finally, regarding hardware mapping, the specific learnable parameters used to account for channel statistics are folded into the weights after learning, ensuring there is zero extra overhead during actual inference on hardware.
Summary updated