Differentiable Soft Quantization: Bridging Full-Precision and Low-Bit Neural Networks

Ruihao Gong, Xianglong Liu, Shenghu Jiang, Tianxiang Li, Peng Hu, Jiazhen Lin, Fengwei Yu, Junjie Yan

Abstract

Deep neural networks are increasingly deployed on edge devices, yet their high memory and computational demands remain a significant barrier. Quantization—reducing weights and activations to low-bit representations (1-4 bits)—offers a solution but typically suffers from training instability due to the non-differentiable nature of discrete quantization functions. This paper introduces Differentiable Soft Quantization (DSQ), a novel framework that employs a smooth, differentiable approximation of the quantization process. By utilizing an evolutionary training strategy that transitions from "soft" to "hard" quantization and jointly optimizing clipping ranges, DSQ achieves state-of-the-art accuracy across multiple benchmarks and enables significant real-world speedups on mobile hardware.

Introduction

The primary challenge in training low-bit neural networks is the "staircase" nature of the quantization function, which has a derivative of zero almost everywhere. Traditional methods rely on the Straight-Through Estimator (STE) to bypass this during backpropagation. However, at extremely low bit-widths (e.g., 1 or 2 bits), the gradient mismatch between the quantized forward pass and the full-precision backward pass leads to unstable training and severe accuracy degradation. DSQ addresses this by bridging the gap with a continuous, differentiable function that evolves during training.

Methodology

The DSQ Function

Instead of the standard discrete round() function, DSQ utilizes a series of scaled hyperbolic tangent (tanh) functions to approximate quantization levels. This piecewise approach ensures the function is continuously differentiable, allowing gradients to flow accurately through the quantization layers.

Differentiable Approximation of Quantization Functions

As shown in the figure above, DSQ can approximate both multi-bit (Piecewise) and binary quantization. The "softness" of these curves is controlled by a parameter $\alpha$, which is treated as a learnable variable during the training process.

Evolutionary Training and Joint Optimization

DSQ employs an evolutionary strategy where the quantization function starts "soft" (behaving similarly to a linear identity function) to stabilize early training. Over successive epochs, the function gradually "hardens" into a staircase shape to match the final deployment requirements. This transition allows the model to explore the weight space more effectively before converging on discrete values.

The DSQ Training and Deployment Pipeline

Furthermore, DSQ jointly optimizes the clipping range ($l, u$). This optimization balances clipping error (loss of information from outliers) against rounding error (loss of precision within the range), which is crucial for maintaining high accuracy in low-bit regimes.

Hardware-Efficient Deployment

To demonstrate practical utility, the authors implemented custom 2-bit to 4-bit General Matrix Multiply (GEMM) kernels. These kernels utilize ARM NEON instructions, specifically leveraging bit-manipulation primitives like MLA and SADDW. This implementation ensures that the theoretical benefits of low-bit quantization translate into tangible performance gains on mobile devices.

Experimental Results

The researchers evaluated DSQ on standard benchmarks including CIFAR-10 and ImageNet (ILSVRC12):

  • CIFAR-10: A 1-bit ResNet-20 trained with DSQ achieved 84.11% accuracy, a significant improvement over DoReFa-Net's 79.30%.
  • ImageNet: For 2-bit quantization on ResNet-18, DSQ reached 65.17% Top-1 accuracy, outperforming other state-of-the-art methods like PACT (64.40%) and LQ-Net (64.90%).
  • Mobile Speedup: On a Raspberry Pi 3B, the custom 2-bit DSQ implementation achieved a 1.7x speedup compared to the highly optimized NCNN 8-bit framework.

Conclusion

Differentiable Soft Quantization successfully bridges the gap between full-precision and low-bit networks. By replacing the non-differentiable staircase function with an evolving, differentiable approximation, DSQ provides more accurate gradients and smoother convergence. The results demonstrate that DSQ not only preserves accuracy in extremely low-bit models but also provides a viable path for high-performance deployment on resource-constrained edge hardware.

Summary updated

BibTeX
@inproceedings{gong2019differentiable,
  author = {Ruihao Gong and Xianglong Liu and Shenghu Jiang and Tianxiang Li and Peng Hu and Jiazhen Lin and Fengwei Yu and Junjie Yan},
  title = {{Differentiable Soft Quantization: Bridging Full-Precision and Low-Bit Neural Networks}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2019},
  doi = {10.1109/iccv.2019.00495},
}
Figure