TL;DR
This paper introduces Entropy-Constrained Adaptive Stochastic Quantization (ECASQ), a novel framework that minimizes mean squared error under a strict entropy budget while maintaining unbiased quantization. By co-designing quantization levels with downstream lossless entropy coding, ECASQ delivers significant compression gains for machine learning workloads (like gradients and KV-caches) alongside a GPU-friendly approximation algorithm that yields up to a 24x speedup.
What Problem Does This Paper Address?
Quantization is a cornerstone technique for compressing machine learning models, gradients, and KV-caches to alleviate memory and network bottlenecks. Adaptive Stochastic Quantization (ASQ) is highly desirable because it minimizes mean squared error (MSE) while remaining unbiased—a property crucial for the convergence of distributed training algorithms.
However, practical systems typically pass quantized data through a lossless entropy encoder (like Huffman or arithmetic coding) for final compression. Existing unbiased quantization methods choose their quantization values without considering this subsequent encoding stage, leaving substantial accuracy and compression efficiency on the table. The authors address this gap by jointly optimizing adaptive quantization values for both minimum distortion and downstream entropy size.
Methods
The authors formulate the problem as a Lagrangian optimization ($\lambda$-ECASQ) that balances MSE and average-entry entropy. They propose three primary algorithmic solutions:
- Optimal Dynamic Program (DP): Because true entropy depends on the probabilities of adjacent quantization levels, the cost function is non-separable. The authors design a novel DP that tracks pairs of quantization values to account for entropy accurately. They accelerate this using the SMAWK algorithm (for fast row-minima selection in Monge matrices) and Hirschberg’s divide-and-conquer technique to bound space complexity to $O(d^2)$ for a length-$d$ vector.
- Space-Efficient Approximation Algorithm: To scale to larger inputs, they introduce a local joint entropy surrogate $H(I, B)$ that decouples the dependencies between adjacent intervals. This reduces the space complexity to $O(d)$ and provides a theoretical "one-bit guarantee": its MSE is no worse than an optimal solution given one additional bit of entropy budget.
- Three-Color Iterative Refinement: To bridge the accuracy gap of the approximation, they introduce a GPU-friendly refinement step. It partitions the codebook into three independent sets and optimizes them in parallel via binary search, rapidly driving the approximate solution toward optimality.
Datasets
The authors evaluated ECASQ across both synthetic and real-world workloads:
- Synthetic Vectors: BF16 vectors ($d = 16,384$) generated from four distinct distributions: Normal, Lognormal, Student-$t$, and Sparse Outlier.
- Real-Model Tensors: 100 real-world tensor samples (comprising weights, activations, and KV-caches) extracted from five prominent open-source LLM families: Qwen2.5 (0.5B/1.5B), Gemma-3-1B-IT, Llama-3.2-1B, and Phi-3.5-Mini.
Key Insights and Ideas
- The Non-Separability Challenge: True entropy cannot be calculated interval-by-interval because the expected frequency of a quantization value depends on both its left and right neighbors. Tracking pairs of levels resolves this but introduces severe computational overhead.
- Surrogate Entropy as a Loophole: By optimizing the joint entropy of the coordinate interval and the stochastic rounding decision rather than the final vector's true entropy, the objective function becomes separable. This mathematical shift enables the highly parallelizable $O(d)$ space approximation.
- The Power of Time-Sharing: A single Lagrangian multiplier ($\lambda$) might skip certain hard entropy budgets. The authors prove that "time-sharing"—probabilistically running two different quantizers on a random partition of the input—convexifies the rate-distortion region, guaranteeing optimal performance for any arbitrary entropy budget.
Key Results
- Significant Distortion Reduction: The iterative refinement procedure successfully closed the accuracy gap, reducing the mean excess vector-Normalized MSE (vNMSE) of the approximation from 4.97% to just 1.37% on synthetic data, consistently outperforming strong baselines like QSGD and QUIVER.
- Massive Speedups: For a vector size of $d = 262,144$, the approximate DP achieved a 24x speedup over the optimal DP. Incorporating the refinement step still maintained a 19x speedup (taking just 0.33 seconds compared to the optimal solver's 6.39 seconds).
- Real-Model Superiority: Across LLM weights, activations, and KV-caches, ECASQ variants consistently achieved lower distortion at target bitrates (ranging from 1.5 to 4 bits/value) than uniform or non-adaptive stochastic quantization methods.
Limitations and Future Work
- Lagrangian Gaps: A single $\lambda$ value cannot guarantee hitting an exact, arbitrary hard entropy budget without employing the two-way time-sharing strategy, which adds slight implementation complexity.
- Codebook Overhead: Although bounded by a maximum size $s$, storing and transmitting the adaptive codebook metadata adds an overhead that can become noticeable for shorter vectors.
- Future Directions: Promising future work includes extending this joint entropy-distortion optimization framework to multi-dimensional vector quantization or directly integrating it into hardware-accelerated distributed training loops.
Summary updated