Post-Training Piecewise Linear Quantization for Deep Neural Networks

Jun Fang, Ali Shafiee, Hamzah Abdel-Aziz, David Thorsley, Georgios Georgiadis, Joseph Hassoun

TL;DR

Post-training quantization (PTQ) is essential for deploying deep neural networks on edge devices without costly retraining, but standard uniform quantization fails at low bit-widths (e.g., 4-bit). This paper introduces Piecewise Linear Quantization (PWLQ), a hardware-friendly method that breaks bell-shaped tensor distributions into non-overlapping regions to drastically reduce quantization error and preserve model accuracy.

What Problem Does This Paper Address?

Quantization maps 32-bit floating-point values (FP32) to lower-precision integers (like INT8 or INT4) to reduce the memory footprint and computational overhead of deep neural networks (DNNs). Post-training quantization is highly desirable because it directly converts pre-trained models without requiring time-consuming retraining or access to full training datasets.

While 8-bit uniform quantization preserves near-lossless accuracy, dropping to lower bit-widths like 4-bit causes severe performance degradation. This happens because weights and activations in pre-trained DNNs typically follow bell-shaped distributions (like Gaussian or Laplacian distributions) with long tails. Uniform quantization divides the entire range evenly, meaning it assigns too few quantization levels to the dense cluster of values near zero and too many to the sparse, high-magnitude values in the tails.

Methods

The authors propose Piecewise Linear Quantization (PWLQ) to better approximate bell-shaped tensor distributions. Instead of using a single uniform scale, PWLQ splits a tensor's quantization range into two symmetric, non-overlapping regions:

  1. A dense center region ($R_1 = [-p, p]$)
  2. A sparse tail region ($R_2 = [-m, -p) \cup (p, m]$)

Each region is assigned an equal number of quantization levels ($2^{b-1}$ levels per side for a $b$-bit representation). Within each region, standard uniform quantization is applied.

The core innovation lies in finding the optimal breakpoint ($p^*$) that divides the center and tail regions. The authors mathematically prove that the expected mean squared quantization error (MSE) is a convex function with respect to the breakpoint $p$. This guarantee allows them to find a unique optimal breakpoint efficiently using gradient descent or a fast analytical approximation formula derived for Gaussian distributions ($p^*/m = \ln(0.8614m + 0.6079)$).

Comparison of uniform quantization, PWLQ, and their respective Mean Squared Error (MSE) curves.

Datasets

The proposed method was evaluated on several standard computer vision benchmarks:

  • ImageNet (ILSVRC2012) for image classification, evaluating Inception-v3, ResNet-50, and MobileNet-v2.
  • Pascal VOC for semantic segmentation (using DeepLab-v3+) and object detection (using SSD-Lite).

Key Insights and Ideas

  • Convexity Guarantee: Proving that the quantization error function is convex with respect to the breakpoint means that finding the optimal split point is mathematically robust and computationally cheap, avoiding sub-optimal local minima.
  • The Non-Overlapping Advantage: By ensuring regions do not overlap, PWLQ shortens the quantization range for the tail regions by $1.25\times$ to $2\times$ compared to prior overlapping methods, significantly driving down overall quantization noise.
  • The 90/10 Rule in Hardware: Empirical data shows that roughly 90% of a model's weights naturally fall into the center region ($R_1$). Consequently, the extra hardware operations required to handle the non-zero offset of the tail region ($R_2$) are rarely triggered, keeping the actual computational overhead minimal.

Key Results

PWLQ consistently outperforms standard uniform quantization and other state-of-the-art post-training quantization methods, particularly at low bit-widths:

  • Inception-v3 (4-bit weights): Uniform quantization collapses to 44.28% top-1 accuracy. PWLQ achieves 75.72% (and 76.45% when combined with bias correction), closely approaching the unquantized baseline of 77.49%.
  • MobileNet-v2 (4-bit weights): MobileNet architectures are notoriously difficult to quantize due to depthwise convolutions. Uniform quantization drops to 11.37% accuracy, while PWLQ with bias correction recovers it to 69.22% (compared to the 71.88% FP32 baseline).
  • Semantic Segmentation (DeepLab-v3+): 4-bit PWLQ improves the mean Intersection over Union (mIoU) by 17.61% over 4-bit uniform quantization.
  • Object Detection (SSD-Lite): 4-bit PWLQ reduces the mean Average Precision (mAP) gap down to just 0.38% from the full-precision model.

Limitations and Future Work

While the method can theoretically scale to multiple breakpoints, the authors note that adding more splits linearly increases hardware complexity, requiring more accumulators and storage bits. Therefore, they suggest limiting the implementation to a single breakpoint.

Additionally, applying PWLQ to both weights and activations simultaneously requires dedicated hardware accumulators for every combination of activation and weight regions. This significantly increases hardware overhead, making dual-activation-weight PWLQ less feasible for highly resource-constrained edge devices.

Summary updated

BibTeX
@inproceedings{fang2020post,
  author = {Jun Fang and Ali Shafiee and Hamzah Abdel-Aziz and David Thorsley and Georgios Georgiadis and Joseph Hassoun},
  title = {{Post-Training Piecewise Linear Quantization for Deep Neural Networks}},
  booktitle = {European Conference on Computer Vision},
  year = {2020},
  url = {https://openreview.net/forum?id=ksyoiYXhwU},
}

Loading related content...

Figure