NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Theory-optimal Quantization Based on Flatness

Xiusheng Huang, Zhe Li, Xuanwu Yin, Lu Wang, Yequan Wang, Dong Li, Emad Barsoum, Kang LiuarXiv 2026

TL;DR

This paper introduces Bidirectional Diagonal Quantization (BDQ), a mathematically grounded post-training quantization (PTQ) framework designed to tackle activation outliers in Large Language Models (LLMs). By defining a new "Flatness" metric inspired by information entropy, the authors derive a theoretically optimal matrix transformation that evenly disperses outlier magnitudes across matrix dimensions. BDQ significantly closes the performance gap in ultra-low bit settings, achieving state-of-the-art compression with minimal accuracy loss.

What Problem Does This Paper Address?

Quantizing LLMs to low bit-widths (e.g., 4-bit or 2-bit weights and activations) is essential for reducing the massive computational and storage costs of deployment. However, LLMs naturally produce "activation outliers"—features with exceptionally large magnitudes concentrated in specific channels.

When mapping continuous floating-point values to a limited discrete space (like INT4), these massive outliers force the quantization scale factor to expand. As a result, the remaining normal data gets squished into just a few quantization bins, leading to severe precision loss. While recent methods try to use linear rotations to spread out these outliers, the data often remains heavily concentrated in certain regions. Furthermore, existing approaches are largely heuristic and lack a direct mathematical link between outlier distributions and quantization errors.

Methods

The authors approach the outlier problem through rigorous mathematical modeling and introduce three core components:

  1. The Flatness Metric: The authors prove that the total quantization error scales quadratically with outlier magnitude. To quantify how evenly outliers are distributed, they introduce Flatness, a metric inspired by information entropy. Treating matrix element magnitudes like a probability distribution, they prove that maximizing entropy (minimizing Flatness) yields a unique, theoretically optimal solution using simple diagonal matrix scaling.
  2. Bidirectional Diagonal Quantization (BDQ): Based on their theoretical derivation, BDQ applies two learnable diagonal transformation pairs ($\Lambda_1, \Lambda_2$) for each fully connected layer to scale rows and columns simultaneously. This strategically redistributes outlier magnitudes across both dimensions. To handle cases with strong column correlations, they also incorporate a learnable Hadamard rotation matrix ($R$) to further smooth out the distribution.
  3. Recursive Cross-Entropy (RCE) Loss: PTQ methods often overfit to the small calibration datasets (e.g., 128 samples) typically used during quantization. The authors show that while standard cross-entropy loss improves validation perplexity, it actually increases matrix flatness and hurts general zero-shot accuracy. RCE loss fixes this by regularizing the optimization process, simultaneously fitting the calibration labels and the model's own highly reliable predicted token distributions.

The overall transformation pipeline and its impact on matrix flatness compared to standard rotation methods can be seen in the authors' framework diagram:

Fig. 2: The transformation results of different methods. The Rotation Matrix is a learnable random Hadamard matrix. The diagonal matrix is obtained by optimizing and converging utilizing deep neural networks.

Datasets

  • Calibration & Perplexity Evaluation: WikiText2 and C4 datasets.
  • Downstream Zero-Shot Evaluation: Six standard benchmarks from the lm-evaluation-harness: HellaSwag, LAMBADA, PIQA, WinoGrande, ARC-Easy, and ARC-Challenge.
  • Models Tested: LLaMA-2 (7B to 70B), LLaMA-3 (8B and 70B), and the DeepSeek-R1-Distill-LLaMA (8B and 70B) series.

Key Insights and Ideas

  • The Quadratic Penalty: Outliers do not just add linear noise; their impact on the total matrix quantization error is quadratic. This makes outlier dispersion the absolute highest priority for low-bit quantization.
  • Entropy as a Structural Guide: By framing matrix smoothing as an entropy maximization problem, the authors move away from heuristic tuning and provide a mathematically optimal form ($V = d_1 W d_2$) for outlier elimination.
  • The PTQ Overfitting Trap: The paper exposes a hidden pitfall in post-training quantization: optimizing strictly for cross-entropy on small calibration sets causes the model to overfit to specific features, which actively hinders outlier mitigation on unseen data.

Key Results

  • W4A4 Quantization: On the LLaMA-3-8B model, BDQ achieves less than a 1% accuracy drop compared to the unquantized FP16 baseline.
  • Ultra-Low Bit (W2A4KV16): In the highly challenging 2-bit weight setting, BDQ reduces the performance gap to the baseline by 39.1% on the DeepSeek-R1-Distill-LLaMA-70B model compared to the previous state-of-the-art method (FlatQuant).
  • Quantization Uniformity: As visualized below, BDQ maps values to integer levels much more uniformly than standard rotation transformations, preserving the original data space:
Fig. 1: Activation distributions under different transformations for LLaMA3-8B. After quantization, values from various ranges are mapped to corresponding integer levels. The number of points within each box reflects the frequency of quantized values. A more uniform distribution of points indicates higher quantization quality. Blue dots represent values near zero, Orange dots indicate mid-range values, and Red dots correspond to large-magnitude values.
  • Hardware Efficiency: In practical deployment, BDQ delivers up to a 3.44× speedup during the prefill phase on NVIDIA A100 GPUs and up to 3.74× memory savings on AMD MI250 GPUs.

Limitations and Future Work

  • Model Scale Constraints: Due to limited computing resources, the authors did not validate their framework on ultra-large models beyond 70B parameters (such as the LLaMA-3 405B model).
  • Hardware Diversity: The inference efficiency experiments were restricted to specific high-end enterprise GPUs (NVIDIA A100 and AMD MI250). Further testing across a broader variety of consumer and edge GPU architectures is needed to verify widespread practical deployment.

Summary updated

BibTeX
@misc{huang2026theory,
  author = {Xiusheng Huang and Zhe Li and Xuanwu Yin and Lu Wang and Yequan Wang and Dong Li and Emad Barsoum and Kang Liu},
  title = {{Theory-optimal Quantization Based on Flatness}},
  year = {2026},
  eprint = {2605.18800},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.18800},
}
Figure