cs.ITMar 20, 2026

Optimal Scalar Quantization for Matrix Multiplication: Closed-Form Density and Phase Transition

Authors: Calvin Ang, Sungyoon Kim, Mert Pilanci

Organizations: Stanford University

Abstract

We study entrywise scalar quantization of two matrices prior to multiplication. Given A∈Rm×kA\in R^{m\times k} and B∈Rk×nB\in R^{k\times n}, we quantize entries of AA and BB independently using scalar quantizers with KXK_X and KYK_Y levels per entry, and form C^=A^ B^\widehat C=\widehat A\,\widehat B. The objective is to minimize the matrix multiplication mean-squared error (MSE) E[∥AB−A^B^∥F2]E[\|{AB-\widehat A\widehat B}\|_F^2] under a pair-i.i.d.\ inner-product model. In the high-resolution regime KX,KY→∞K_X,K_Y\to\infty, we derive a sharp K−2K^{-2} asymptotic expansion for E\mathcal{E}, identify the exact optimal leading constants, and characterize asymptotically optimal quantization center densities in terms of conditional second moments. We then specialize to correlated Gaussian multiplicative pairs, obtaining a closed-form optimal point density

λ⋆(u) ∝ exp⁡ ⁣(−u26)((1−ρ2)+ρ2u2)1/3,u=xσX,λ^\star(u)\ \propto\ \exp\!\left(-\frac{u^2}{6}\right)\bigl((1-ρ^2)+ρ^2u^2\bigr)^{1/3}, \qquad u=\frac{x}{σ_X},

with the same form for y/σYy/σ_Y, and prove a correlation-driven phase transition: the density is unimodal at the origin for ∣ρ∣≤1/3|ρ|\leq 1/\sqrt{3} and becomes bimodal for ∣ρ∣>1/3|ρ|>1/\sqrt{3} with peaks at upeak=±3−1/ρ2u_{\mathrm{peak}}=\pm\sqrt{3-1/ρ^2}. We show our method's applicability in synthetic experiments such as matrix multiplication quantization and least squares optimization, as well as quantization of large language model key and query activations.

Figures & tables

Explore similar work

Sep 4, 2026

A Nuclear-Norm Lower Bound for Dithered Scalar Quantization of Matrix Products

We consider the problem of minimizing error in quantized matrix multiplication C=ABC=AB. Scalar quantization of the factors introduces rounding errors whose scale depends on the maximum absolute entries -- the ranges -- of their rows and columns. These ranges determine the quantization grid steps. To reduce the error, we optimize over product-preserving transformations that alter the factor ranges and grid steps without changing CC. Specifically, we seek the smallest leading expected squared error over invertible inner changes of basis and orthogonal outer rotations. Under independent, zero-mean subtractive dither noise on an unbounded lattice, we prove the output-only bound Elead≥(cA+cB)/K∥AB∥∗2E_{\rm lead} \ge (c_A+c_B)/K \Vert AB\Vert_*^2, where KK is the inner dimension, cAc_A and cBc_B are normalized noise variances, and ∥AB∥∗\Vert AB\Vert_* is the nuclear norm. The bound is tight: an SVD-aligned Hadamard construction attains the infimum whenever a Hadamard matrix of order KK exists, including every power of two, while an SVD-aligned DCT construction is within a factor of two for every KK. Without outer rotations, Gram-matrix balancing minimizes factorization energy, and finite-set flattening achieves the bound within Clog⁡(K(m+n))C\log(K(m+n)). For power-of-two KK, conditional expectations deterministically select the Hadamard signs in O((m+n)K2)O((m+n)K^2) exact-real operations. Synthetic experiments verify both constructions and illustrate the tradeoff between regularization and conditioning. These results characterize the full-gauge optimum and quantify the cost of preserving row and column indices.
Sep 11, 2026

Product-Aware Deterministic Rounding for Quantized Matrix Multiplication

Scalar rounding decisions interact through matrix multiplication. We study deterministic product-aware rounding after scales, clipping bounds, and grids are fixed, with each active scalar choosing between adjacent levels. For dynamic activation rounding, null-space reduction preserves the relaxed product while leaving at most rr fractional decisions, where rr is the rank of the active gap-weighted weight block. Conditional-expectation completion gives a deterministic polynomial-time algorithm with squared product error at most OPTdyn+rνmax⁡2/4 \mathrm{OPT}_{\mathrm{dyn}}+rν_{\max}^2/4, where OPTdyn\mathrm{OPT}_{\mathrm{dyn}} is the best admissible error and νmax⁡ν_{\max} is the largest row norm of that block. For reusable static weights, the exact expected product-loss metric is the uncentered input second moment with fixed output bias; free bias recalibration yields the centered covariance. Exact optimization is NP-hard even at rank one. In balanced blocks with K=1024K=1024 and r=16r=16, conditional- expectation completion attains a dither-normalized median error of 0.0100.010, compared with 0.8990.899 for round-to-nearest. Clipping-aware initialization reduces median normalized error by a factor of 43.443.4 at ten-percent clipping. Held-out Digits experiments show that retaining the input mean or correcting the output bias improves median product error over round-to-nearest in all four tested bit-width and calibration-size settings.
Jul 21, 2026

Contraction-Gauge Preconditioning for Quantized Matrix Multiplication

We study low-precision computation of C=AB with both factors quantized. We derive an exact finite-dimensional identity for the expected squared product error under independent, zero-mean entrywise errors with known variance fields; it holds exactly for non-overloading subtractive dither and for independent stochastic rounding, and we empirically assess deterministic round-to-nearest (RTN). Using the product-preserving equivalence AB=(AT)(T^{-1}B), we formulate contraction-gauge preconditioning: jointly choosing a factor representation and its sharing pattern before quantization. Preconditioning can reduce product error but may require extra transformed, quantized copies of the opposite operand: a shared transform needs one copy, a block-specific transform up to one per block. Within the bounded family of positive diagonal gauges (folds), a geometric program computes a globally optimal shared fold and a linear program decides whether the identity fold is already optimal. For other families we derive computable selection statistics -- tail index for scaling, profile spread for partitioning, coherence and weighted-Gram energy for rotations, slice-energy covariance for hierarchy depth -- with upper bounds for ranking heuristic candidates. Across twelve linear products from a trained three-block image classifier, median within-product rank correlations between dither-model predictions and deterministic-RTN errors are 0.937 at 8 bits and 0.918 at 4 bits. The GP fold cuts held-out product error over the identity fold by 18.0% (8-bit) and 20.5% (4-bit) in geometric mean, beats a SmoothQuant-style grid baseline at both precisions and on ten of twelve products, and lowers composed logit MSE by 15.4% and 26.4%. We thus provide exact stochastic product-error accounting, certified selection within the diagonal family, and a common objective for evaluating reusable transform candidates under RTN.