Scalar Quantization as Sparse Least Square Optimization

Chen Wang, Xiaomei Yang, Shaomin Fei, Kai Zhou, Xiaofeng Gong, Miao Du, Ruisen Luo

Abstract

Scalar quantization is a fundamental technique for data compression, particularly in the deployment of deep neural networks on resource-constrained devices. Traditional methods, primarily K-means clustering, suffer from initialization sensitivity, computational inefficiency at high resolutions, and potential instability. This paper proposes a novel framework that reformulates scalar quantization as a sparse least square optimization problem. By leveraging $l_1$ and $l_2$ regularization, the authors introduce a mathematically grounded approach that ensures global convergence, improves computational speed, and minimizes information loss compared to traditional clustering heuristics.

Introduction

As neural networks grow in complexity, the demand for efficient compression techniques has intensified. Quantization—the process of mapping a large set of input values to a smaller set of discrete levels—is essential for reducing the memory footprint and power consumption of models deployed on edge devices like smartphones and IoT sensors.

For years, K-means clustering has been the industry standard for this task. However, K-means is essentially a heuristic that relies on random initialization, often leading to sub-optimal local minima. Furthermore, as the required number of quantization levels (resolution) increases, the computational burden of K-means grows significantly. This paper reimagines the problem: instead of grouping points into clusters, can we view quantization as a sparse representation problem? By framing quantization through the lens of sparse least square optimization, the authors provide a more robust and predictable alternative to traditional clustering.

The Limitations of K-means

The authors identify three primary "pain points" that hinder the effectiveness of K-means in modern compression pipelines:

  1. Initialization Sensitivity: The final quality of quantization is highly dependent on the initial random "seed." This necessitates multiple trials to ensure a reasonable result, adding to the engineering overhead.
  2. Instability: K-means can produce empty clusters or shared values that fall outside the original data range, which can be problematic for specific hardware constraints.
  3. High-Resolution Scaling: When a high number of unique values is required to maintain model accuracy, K-means becomes prohibitively slow and computationally expensive.

Proposed Methodology

The core innovation of this work is the realization that the number of unique values in a dataset is mathematically related to the sparsity of its representation in a specific lower-triangular coordinate system. This allows the authors to apply well-understood tools from sparse recovery and convex optimization.

$l_1$ Least Square Quantization

By using $l_1$ regularization (similar to the LASSO method in statistics), the authors induce sparsity in the representation, effectively forcing the data into a limited number of unique values. Because this formulation is strictly convex, it is guaranteed to find a single global optimum. This eliminates the "bad seed" problem entirely, providing a stable and reproducible compression path.

$l_1 + l_2$ Regularization (Elastic Net Approach)

To further refine the results, the authors propose a hybrid regularization approach. By adding a negative $l_2$ term, the algorithm can better preserve the magnitude of non-zero values while still encouraging the overall sparsity required for quantization. This helps maintain the original distribution of the data more effectively than $l_1$ alone.

Clustering-based Least Square Refinement

Recognizing that K-means is still useful for initial grouping, the authors introduce a hybrid algorithm. This method uses K-means to find initial clusters but then applies a final least-square optimization step to determine the optimal shared values. This refinement step is designed specifically to minimize the $l_2$ information loss, outperforming standard K-means updates.

Experimental Evaluation

The proposed methods were evaluated across three distinct data types to test robustness and versatility:

  • Neural Network Weights: The authors compressed the final layer of a 5-layer fully connected network trained on MNIST. The $l_1$ least-square method achieved accuracy levels comparable to, and occasionally exceeding, K-means, even under aggressive compression.
  • Image Data: Grayscale MNIST images were quantized to test visual fidelity. The sparse optimization methods avoided the "out-of-range" pixel artifacts sometimes seen in K-means, resulting in higher visual consistency.
  • Synthetic Distributions: Using Mixture of Gaussian, Uniform, and Single Gaussian distributions, the authors demonstrated that their sparse regression framework handles different data "shapes" more efficiently than clustering, particularly in high-resolution scenarios.

Key Insights and Results

  • Predictability through Convexity: The shift to convex optimization makes the quantization process predictable for engineers, removing the stochastic nature of traditional clustering.
  • Efficiency at Scale: The sparse regression methods proved significantly faster than K-means for medium-to-large datasets, as they do not require multiple restarts or extensive iterations to converge to a high-quality solution.
  • Optimal Information Loss: The hybrid Clustering-based Least Square method (Algorithm 3) consistently yielded the lowest information loss among all tested techniques, suggesting that the least-square refinement is a superior way to finalize quantization levels.

Conclusion and Future Work

This paper successfully demonstrates that scalar quantization can be effectively treated as a sparse optimization problem. By moving away from the local minima of K-means and toward the global optima of convex functions, the authors provide a faster, more stable framework for data compression.

While $l_0$ regularization was explored, it proved numerically unstable for large-scale tasks, leading the authors to recommend $l_1$-based approaches for general use. Future research will focus on extending this 1D scalar framework to multi-dimensional vector quantization, which is critical for more complex neural architectures and high-fidelity signal processing.

Summary updated

BibTeX
@article{wang2021scalar,
  author = {Chen Wang and Xiaomei Yang and Shaomin Fei and Kai Zhou and Xiaofeng Gong and Miao Du and Ruisen Luo},
  title = {{Scalar Quantization as Sparse Least Square Optimization}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2021},
  doi = {10.1109/tpami.2019.2952096},
}
Figure