SQuant: On-the-Fly Data-Free Quantization via Diagonal Hessian Approximation

Cong Guo, Yuxian Qiu, Jingwen Leng, Xiaotian Gao, Chen Zhang, Yunxin Liu, Fan Yang, Yuhao Zhu, Minyi Guo

TL;DR

SQuant is a breakthrough "on-the-fly" data-free quantization framework that compresses deep neural networks in sub-second time without requiring any original or synthetic training data. By using a clever diagonal Hessian approximation to minimize the "Constrained Absolute Sum of Error" (CASE), it achieves over 30% higher accuracy than existing data-free methods in ultra-low 4-bit settings.

What Problem Does This Paper Address?

Quantization—converting high-precision neural network weights into low-bit formats (like 4-bit or 8-bit)—is essential for deploying models on edge devices like smartphones. However, standard quantization usually requires the original training dataset to "calibrate" the model and prevent accuracy loss.

In many real-world scenarios (e.g., medical or confidential data), the original dataset is unavailable due to privacy concerns. Existing "Data-Free Quantization" (DFQ) solutions generally fall into two camps:

  1. Simple Rounding: Fast, but results in massive accuracy drops at low bit-widths.
  2. Data-Generative Methods: These use backpropagation to create "synthetic" data for calibration. While more accurate, they are incredibly slow, often taking hours of GPU time to quantize a single model.

SQuant aims to bridge this gap by providing the accuracy of data-driven methods with the speed of simple rounding.

Methods

The core innovation of SQuant is its mathematical approach to weight optimization without needing input data.

  • Diagonal Hessian Approximation: The authors analyze the "Hessian" matrix, which describes the curvature of the loss function. They prove that the optimization objective can be decomposed into three diagonal sub-items corresponding to the dimensions of a weight tensor: element-wise, kernel-wise, and output channel-wise.
Diagonal Hessian Approximation
  • CASE (Constrained Absolute Sum of Error): By simplifying the Hessian objective, they derive a new metric called CASE. This metric suggests that instead of just rounding every weight to the nearest value, we should intentionally "flip" some weights (round them the "wrong" way) to ensure that the total error across a kernel or channel cancels out.
  • Progressive Algorithm: SQuant uses a greedy, three-stage algorithm (SQuant-E $\rightarrow$ K $\rightarrow$ C). It first rounds elements, then flips specific elements to calibrate the kernel-level error, and finally flips kernels to calibrate the channel-level error.
  • Inference-Only Compatibility: Because the method involves no backpropagation or fine-tuning, it can run on devices that don't even support training, making true "on-the-fly" quantization possible.

Key Insights and Ideas

  • Error Cancellation is Key: The most surprising finding is that "rounding to the nearest neighbor" is often suboptimal. SQuant shows that intentionally introducing a slightly larger error on one weight to cancel out an error on another weight (maintaining a zero-sum error across a group) is far more effective for preserving model logic.
  • Data-Independence: The authors demonstrate that the Hessian-based objective can be simplified to a point where it is independent of the input data and network architecture. This is why SQuant doesn't need synthetic images to work.
  • Granularity Matters: By optimizing at three different granularities (element, kernel, and channel), SQuant captures the structural dependencies of the weights that simpler methods ignore.

Key Results

The authors evaluated SQuant on the ImageNet dataset across five different architectures, including ResNet-18, ResNet-50, Inception V3, SqueezeNext, and ShuffleNet.

  • Speed: SQuant quantizes a ResNet-18 model in just 84 milliseconds on an NVIDIA A100. For comparison, generative DFQ methods like GDFQ take nearly 2 hours for the same task.
  • Accuracy (4-bit): In the challenging 4-bit weight/activation setting, SQuant achieved 66.14% Top-1 accuracy on ResNet-18. Previous state-of-the-art data-free methods were stuck at around 19-34%, and even some generative methods were outperformed by over 5%.
Accuracy Comparison on ResNet Architectures
  • 8-bit Performance: At 8-bit quantization, SQuant introduces almost zero accuracy loss (0.1% on average), making it a reliable "drop-in" replacement for standard rounding.

Limitations and Future Work

  • Activation Quantization: While SQuant provides a sophisticated way to handle weights, it still relies on standard, simpler methods for activation quantization. The authors note that they use a basic rounding method for activations to maintain the data-free premise.
  • Architecture Scope: The paper focuses heavily on Convolutional Neural Networks (CNNs). While the math is general, future work could explore how this diagonal Hessian approximation performs on Transformer-based architectures (like ViT or BERT).
  • Hardware-Specific Tuning: The current framework is general; future iterations could be optimized for specific hardware constraints, such as leveraging specific bit-manipulation instructions on mobile CPUs.

Summary updated

BibTeX
@inproceedings{guo2022squant,
  author = {Cong Guo and Yuxian Qiu and Jingwen Leng and Xiaotian Gao and Chen Zhang and Yunxin Liu and Fan Yang and Yuhao Zhu and Minyi Guo},
  title = {{SQuant: On-the-Fly Data-Free Quantization via Diagonal Hessian Approximation}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=-zniVpVMvj},
}
Figure