矩阵乘法最优标量量化:闭式密度与相变
Optimal Scalar Quantization for Matrix Multiplication: Closed-Form Density and Phase Transition
AI总结:
研究矩阵乘法前的逐元素标量量化,推导高分辨率下MSE的闭式密度和相变特性,适用于矩阵乘法量化和大语言模型激活量化。
摘要:
我们研究在矩阵乘法前对两个矩阵进行逐元素标量量化。给定A∈R^{m×k}和B∈R^{k×n},使用具有K_X和K_Y级的标量量化器独立量化A和B的元素,并形成C^=A^B^。目标是在一对独立同分布的内积模型下最小化矩阵乘法均方误差(MSE)E[||AB−A^B^||_F^2]。在高分辨率极限K_X,K_Y→∞下,我们推导了E的尖锐K^{-2}渐进行为,确定了精确的最优主常数,并以条件二阶矩来表征渐近最优量化中心密度。我们进一步专门研究相关高斯乘法对,得到闭式最优点密度[λ^*(u)∝exp(−u²/6)(1−ρ²+ρ²u²)^{1/3},u=x/σ_X],对于y/σ_Y具有相同形式,并证明了由相关性驱动的相变:密度在原点处单峰当|ρ|≤1/√3,当|ρ|>1/√3时变为双峰,峰值在u_peak=±√(3−1/ρ²)。我们展示了该方法在合成实验中的应用,如矩阵乘法量化和最小二乘优化,以及大语言模型键和查询激活的量化。
英文摘要:
We study entrywise scalar quantization of two matrices prior to multiplication. Given $A\in R^{m\times k}$ and $B\in R^{k\times n}$, we quantize entries of $A$ and $B$ independently using scalar quantizers with $K_X$ and $K_Y$ levels per entry, and form $\widehat C=\widehat A\,\widehat B$. The objective is to minimize the matrix multiplication mean-squared error (MSE) $E[\|{AB-\widehat A\widehat B}\|_F^2]$ under a pair-i.i.d.\ inner-product model. In the high-resolution regime $K_X,K_Y\to\infty$, we derive a sharp $K^{-2}$ asymptotic expansion for $\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 \[ λ^\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/σ_Y$, and prove a correlation-driven phase transition: the density is unimodal at the origin for $|ρ|\leq 1/\sqrt{3}$ and becomes bimodal for $|ρ|>1/\sqrt{3}$ with peaks at $u_{\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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。