标量量化

分类: 量化与低秩

type:: concept aliases:: Scalar Quantization, SQ

  • 标量量化

  • 定义

  • 对每个标量值独立进行量化映射,将连续值映射到有限离散集合中最近的代表点

  • 数学形式

q(w)=argmincCwc,C={c1,c2,,cK}q(w) = \arg\min_{c \in \mathcal{C}} |w - c|, \quad \mathcal{C} = \{c_1, c_2, \ldots, c_K\}
  • 均匀量化:q(w)=round(w/Δ)Δq(w) = \text{round}(w / \Delta) \cdot \DeltaΔ\Delta 为步长

  • Lloyd-Max:最优非均匀标量量化器,最小化 MSE

  • 核心要点

  • 信息论上受限于标量 rate-distortion bound,对 i.i.d. Gaussian 源在 2 bits 时保留率仅约 77%(Lloyd-Max)

  • 实现简单、推理高效,但在极低比特率下精度损失严重

  • 向量量化 通过联合编码打破标量极限

  • 代表工作

  • GPTQ: 基于 Hessian 的逐列标量量化 + 误差补偿

  • SmoothQuant: 通过 activation smoothing 改善标量量化精度

  • LLVQ: 展示了标量量化在 2-bit 下的根本局限性

  • 相关概念

  • 向量量化

  • PTQ

  • Rate-Distortion