[论文解读] GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers
GPTQ 是一种一次性后训练量化方法,能够将大型 GPT/OPT 模型精确压缩到每权重 3–4 位,从而实现单 GPU 推理和有意义的加速,而不会显著损失准确性。
Generative Pre-trained Transformer models, known as GPT or OPT, set themselves apart through breakthrough performance across complex language modelling tasks, but also by their extremely high computational and storage costs. Specifically, due to their massive size, even inference for large, highly-accurate GPT models may require multiple performant GPUs, which limits the usability of such models. While there is emerging work on relieving this pressure via model compression, the applicability and performance of existing compression techniques is limited by the scale and complexity of GPT models. In this paper, we address this challenge, and propose GPTQ, a new one-shot weight quantization method based on approximate second-order information, that is both highly-accurate and highly-efficient. Specifically, GPTQ can quantize GPT models with 175 billion parameters in approximately four GPU hours, reducing the bitwidth down to 3 or 4 bits per weight, with negligible accuracy degradation relative to the uncompressed baseline. Our method more than doubles the compression gains relative to previously-proposed one-shot quantization methods, preserving accuracy, allowing us for the first time to execute an 175 billion-parameter model inside a single GPU for generative inference. Moreover, we also show that our method can still provide reasonable accuracy in the extreme quantization regime, in which weights are quantized to 2-bit or even ternary quantization levels. We show experimentally that these improvements can be leveraged for end-to-end inference speedups over FP16, of around 3.25x when using high-end GPUs (NVIDIA A100) and 4.5x when using more cost-effective ones (NVIDIA A6000). The implementation is available at https://github.com/IST-DASLab/gptq.
研究动机与目标
- 推动减少极大规模的 GPT/OPT 模型的推理内存和计算需求。
- 开发一种一次性、数据高效的量化方法,在极低比特宽度下仍具高精度。
- 将量化扩展到参数量达到数千亿级别的模型,在可实践的计算预算内。
- 展示端到端推理加速和在普通商用 GPU 上的实际部署。
提出的方法
- 基于 Optimal Brain Quantization (OBQ),并为大模型引入关键的可扩展性改进。
- 逐层对权重量化,使用基于 Hessian 逆信息的近似二阶目标函数。
- 将 OBQ 重构为按块对权重进行量化,并重复使用固定的逆 Hessian 结构,将在层维度上的运行时从立方级降低到接近二次。
- 采用惰性批量更新以提高 GPU 利用率和内存吞吐量。
- 使用 Cholesky 改写和阻尼以在大规模下保持数值稳定性。
- 提供完整的 GPTQ 算法,包含实用优化和对权重矩阵量化的伪代码。
实验结果
研究问题
- RQ1后训练量化是否能在参数量达数千亿级、权重为 3–4 位时实现高精度?
- RQ2哪些算法性变革能够实现对巨型语言模型的可扩展、快速且高精度的一次性量化?
- RQ3就困惑度、运行时以及在 GPU 上的实际部署而言,GPTQ 与现有的后训练量化方法相比如何?
- RQ4对大型 LLM 的极端量化(2 位或三元)有何极限,分组如何提供帮助?
- RQ5部署 GPTQ 量化模型时对端到端推理加速和硬件利用的实际意义是什么?
主要发现
- GPTQ 将 OPT-175B 和 BLOOM-176B 量化到 3–4 位,与未压缩基线相比困惑度损失可以忽略。
- 量化运行时间在单个 GPU 上对 175B 规模的模型达到大约四个 GPU 小时,从而实现单-GPU 的生成推理。
- GPTQ 在 3–4 位时优于 RTN 风格的舍入,在 175B 模型上维持可用的困惑度,而 RTN 在 3 位时会崩溃。
- 分组量化(如 g1024、g128)进一步提高准确性,特别是在 3 位时,甚至在 2 位/三元范围内也可实现并带来合理损失。
- 展示了端到端的加速:对 3 位的 OPT-175B 生成内核,在 A100 上最高可达约 3.25x,加速在 A6000 上约 4.5x,并实现 3 位模型的内存匹配单-GPU 推理。
- 该方法仍兼容多种量化网格和分组方案,能够在准确性与压缩之间实现灵活的权衡。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。