[论文解读] OmniQuant: Omnidirectionally Calibrated Quantization for Large Language Models
OmniQuant 引入 Learnable Weight Clipping 与 Learnable Equivalent Transformation,以在 PTQ 效率下实现大语言模型的高质量权重仅量化以及权重-激活量化。
Large language models (LLMs) have revolutionized natural language processing tasks. However, their practical deployment is hindered by their immense memory and computation requirements. Although recent post-training quantization (PTQ) methods are effective in reducing memory footprint and improving the computational efficiency of LLM, they hand-craft quantization parameters, leading to low performance, especially in extremely low-bit quantization. To tackle this issue, we introduce an Omnidirectionally calibrated Quantization ( extbf{OmniQuant}) technique for LLMs, which achieves good performance in diverse quantization settings while maintaining the computational efficiency of PTQ by efficiently optimizing various quantization parameters. OmniQuant comprises two innovative components including Learnable Weight Clipping (LWC) and Learnable Equivalent Transformation (LET). LWC modulates the extreme values of weights by optimizing the clipping threshold. Meanwhile, LET tackles activation outliers by shifting the challenge of quantization from activations to weights. Operating within a differentiable framework using block-wise error minimization, OmniQuant can optimize the quantization process efficiently for both weight-only and weight-activation quantization. For instance, the LLaMA-2 model family size 7-70B can be processed with OmniQuant on a single A100-40G GPU within 1-16 hours using 128 samples. Extensive experiments validate OmniQuant's superior performance across diverse quantization configurations such as W4A4 (4-bit weight, 4-bit activation), W6A6, W4A16, W3A16, and W2A16. Additionally, OmniQuant demonstrates effectiveness in instruction-tuned models and delivers notable improvements in inference speed and memory reduction on real devices. Codes are available at \url{https://github.com/OpenGVLab/OmniQuant}.
研究动机与目标
- 在不牺牲准确性的前提下,推动降低大型语言模型(LLMs)的内存和计算需求。
- 开发一个可微的后训练量化框架,达到接近 QAT 的性能。
- 在不同的 LLM 家族中实现可靠的低比特量化(例如 W2A16、W4A4)。
- 保持 PTQ 风格的数据效率以及对大模型的单 GPU 实用性。
提出的方法
- 提出一个分块量化误差最小化目标,在学习少量量化参数的同时冻结全精度权重。
- 引入 Learnable Weight Clipping (LWC) 来优化权重裁剪阈值,以获得更好的权重量化。
- 引入 Learnable Equivalent Transformation (LET),通过线性层和注意力层的通道级缩放/平移,将量化难度从激活转移到权重。
- 在分块框架内应用可微优化,联合优化 LWC 和 LET,实现权重仅量化和权重-激活量化。
- 使用 MinMax 量化器对激活和权重量化,优化后将参数融合回原始权重。
- 在多种模型(LLaMA、OPT、Falcon、LLaMA-2、LLaMA-2-chat)和量化设置(W4A4、W3A16、W2A16、W6A6 等)上进行验证。
实验结果
研究问题
- RQ1是否可以将基于梯度的优化引入 PTQ 以在大型语言模型量化中实现接近 QAT 的性能?
- RQ2如何缓解变换器中的权重分布和激活异常值,以实现极低比特的量化?
- RQ3可学习组件(LWC 与 LET)是否在不同模型家族和指令微调变体中具有泛化性?
- RQ4在单 GPU 硬件上对大型模型进行量化的实际数据和时间需求是多少?
- RQ5在零-shot 任务和语言生成困惑度方面,OmniQuant 的权重仅量化和权重-激活量化与先前的 PTQ/QAT 方法相比如何?
主要发现
- OmniQuant 在多种配置(如 W4A4、W3A16、W2A16、W6A6 等)和模型家族上超越了以往的基于 PTQ 的方法。
- 在 W2A16 量化下,OmniQuant 在 LLaMA-1/2 模型上实现的困惑度显著优于 GPTQ 及其他基线。
- 在权重-激活设置中,OmniQuant 在零-shot 任务准确率方面带来显著提升(例如在若干 LLaMA 变体上平均提升大约 5–12 点),并且在较小模型中可超越某些 QAT 方法。
- OmniQuant 能在 GPT-4 评测协议下对 LLaMA-2-chat 等指令微调模型进行量化,且性能具有竞争力。
- 对 LLaMA-2 系列及其他模型的量化可以在单张 A100-40G GPU 上完成,样本量少至 128 个,每个模型大小的计算时间为 1–16 小时。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。