用分歧理论优化神经网络权重量化,显著提升低比特模型精度。
DiscQuant: A Quantization Method for Neural Networks Inspired by Discrepancy Theory
- 基于分歧理论设计新型量化取整方法,实现更优权重映射。
- 在Phi3mini-3.8B上,3.25比特时准确率达64%,优于GPTQ的54%和RTN的31%。
- 适合追求高精度低比特部署的模型压缩研究者与工程实践者。
神经网络权重量化包含两步:(1) 构建低比特复杂度的权重表示(即量化网格),(2) 将原始权重四舍五入至量化网格中的值。本文研究给定任意量化网格下的最优取整问题。最常用方法是最近取整(RTN),但若采用数据相关的方式取整,可显著提升量化模型质量。本文从分歧理论视角分析该问题,该理论研究如何在不显著影响解质量的前提下将连续解近似为离散解。我们证明:当从数据分布中采样 $m=\mathrm{poly}(1/ε)$ 个样本,且原模型梯度空间近似低秩(经实证验证)时,可使除 $O(m)$ 个权重外的所有权重均满足:量化后模型在真实数据分布上的期望近似误差 $\le ε$。该证明具有算法性,启发了名为 extit{DiscQuant} 的简单实用取整算法。实验表明,DiscQuant 在 Phi3mini-3.8B 与 Llama3.1-8B 多个基准测试中显著优于 GPTQ 和基线 RTN。例如,在固定 3.25 位/参数的量化下,对 Phi3mini-3.8B 使用 DiscQuant 在 GSM8k 数据集上达到 64% 准确率,而 GPTQ 为 54%,RTN 仅为 31%(原始模型为 84%)。代码已开源于 https://github.com/jerry-chee/DiscQuant。
原文摘要 · Abstract (English)
Quantizing the weights of a neural network has two steps: (1) Finding a good low bit-complexity representation for weights (which we call the quantization grid) and (2) Rounding the original weights to values in the quantization grid. In this paper, we study the problem of rounding optimally given any quantization grid. The simplest and most commonly used way to round is Round-to-Nearest (RTN). By rounding in a data-dependent way instead, one can improve the quality of the quantized model significantly. We study the rounding problem from the lens of \emph{discrepancy theory}, which studies how well we can round a continuous solution to a discrete solution without affecting solution quality too much. We prove that given $m=\mathrm{poly}(1/ε)$ samples from the data distribution, we can round all but $O(m)$ model weights such that the expected approximation error of the quantized model on the true data distribution is $\le ε$ as long as the space of gradients of the original model is approximately low rank (which we empirically validate). Our proof, which is algorithmic, inspired a simple and practical rounding algorithm called \emph{DiscQuant}. In our experiments, we demonstrate that DiscQuant significantly improves over the prior state-of-the-art rounding method called GPTQ and the baseline RTN over a range of benchmarks on Phi3mini-3.8B and Llama3.1-8B. For example, rounding Phi3mini-3.8B to a fixed quantization grid with 3.25 bits per parameter using DiscQuant gets 64\% accuracy on the GSM8k dataset, whereas GPTQ achieves 54\% and RTN achieves 31\% (the original model achieves 84\%). We make our code available at https://github.com/jerry-chee/DiscQuant.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。