4-bit静态量化新方法,提升大模型推理速度与精度。
MergeQuant: Accurate 4-bit Static Quantization of Large Language Models by Channel-wise Calibration
- 通过通道级静态量化消除动态校准开销。
- 在Llama-2-70B上零样本任务误差仅差1.3点。
- 适合需要高效推理的大模型部署场景。
量化被广泛用于压缩和加速大语言模型的推理。现有方法聚焦于每标记动态校准,以在4比特量化下兼顾推理加速与模型精度。然而,在长序列自回归生成推理中,重复的动态量化与反量化步骤带来显著开销。本文提出MergeQuant,一种精确高效的通道级静态量化框架。MergeQuant通过量化步骤迁移(QSM)方法,将通道级量化步骤与相应缩放及线性映射合并,从而消除矩阵乘法前后量化开销。针对不同通道范围差异显著的问题,提出维度重构与自适应截断,解决量化缩放因子非均匀性,并将通道变化重新分配至后续模块,平衡参数分布。在W4A4静态量化设置下,MergeQuant在Llama-2-70B模型上的零样本任务准确率与FP16基线差距缩小至1.3点;在Llama-2-7B模型上,解码阶段最高提速1.77倍,端到端最高提速2.06倍。
原文摘要 · Abstract (English)
Quantization has been widely used to compress and accelerate inference of large language models (LLMs). Existing methods focus on exploring the per-token dynamic calibration to ensure both inference acceleration and model accuracy under 4-bit quantization. However, in autoregressive generation inference of long sequences, the overhead of repeated dynamic quantization and dequantization steps becomes considerably expensive. In this work, we propose MergeQuant, an accurate and efficient per-channel static quantization framework. MergeQuant integrates the per-channel quantization steps with the corresponding scalings and linear mappings through a Quantization Step Migration (QSM) method, thereby eliminating the quantization overheads before and after matrix multiplication. Furthermore, in view of the significant differences between the different channel ranges, we propose dimensional reconstruction and adaptive clipping to address the non-uniformity of quantization scale factors and redistribute the channel variations to the subsequent modules to balance the parameter distribution under QSM. Within the static quantization setting of W4A4, MergeQuant reduces the accuracy gap on zero-shot tasks compared to FP16 baseline to 1.3 points on Llama-2-70B model. On Llama-2-7B model, MergeQuant achieves up to 1.77x speedup in decoding, and up to 2.06x speedup in end-to-end compared to FP16 baseline.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。