QLLM: Accurate and Efficient Low-Bitwidth Quantization for Large Language Models
作者: Jing Liu, Ruihao Gong, Xiuying Wei, Zhiwei Dong, Jianfei Cai, Bohan Zhuang
分类: cs.CL, cs.AI, cs.LG
发布日期: 2023-10-12 (更新: 2024-04-06)
备注: ICLR 2024 camera ready; Code is available at https://github.com/ziplab/QLLM and https://github.com/ModelTC/QLLM
💡 一句话要点
提出QLLM以解决大语言模型低比特量化问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 量化技术 大语言模型 后训练量化 激活异常值 自适应通道重组 低比特量化 自然语言处理 模型压缩
📋 核心要点
- 现有的后训练量化方法在处理激活异常值时存在准确性不足的问题,限制了大语言模型的应用。
- QLLM通过自适应通道重组技术,将激活异常值的幅度重新分配到其他通道,改善量化效果。
- 在LLaMA-1和LLaMA-2的实验中,QLLM实现了显著的准确率提升,且量化速度快,效率高。
📝 摘要(中文)
大语言模型(LLMs)在自然语言处理领域表现出色,但其高资源需求限制了广泛应用。尽管量化感知训练(QAT)提供了解决方案,但其训练成本高,使得后训练量化(PTQ)成为更实用的选择。现有研究表明,特定通道的激活异常值是PTQ准确性的瓶颈。本文提出QLLM,一种针对LLMs的高效低比特PTQ方法,通过自适应通道重组技术,将异常值的幅度重新分配到其他通道,减轻其对量化范围的影响。实验结果表明,QLLM在LLaMA-1和LLaMA-2上表现优异,能够在10小时内高效量化4比特的LLaMA-2-70B,准确率较之前的最优方法提升7.89%。
🔬 方法详解
问题定义:本文旨在解决大语言模型在后训练量化(PTQ)过程中,由于激活异常值导致的准确性下降问题。现有方法在处理这些异常值时,往往无法有效提升量化后的模型性能,造成性能严重下降。
核心思路:QLLM的核心思路是通过自适应通道重组技术,将激活异常值的幅度重新分配到其他通道,以减轻其对量化范围的影响。通过通道的拆分与组合,确保激活幅度的更均衡分布,从而提高量化精度。
技术框架:QLLM的整体架构包括通道拆分、通道组合和自适应策略三个主要模块。首先,通道拆分将异常通道分解为多个子通道,以实现更均衡的幅度分布;然后,类似的通道被合并以保持原有通道数量,提升效率。最后,自适应策略用于自动确定子通道的最佳数量。
关键创新:QLLM的主要创新在于自适应通道重组技术,通过动态调整通道的幅度分配,显著改善了低比特量化的性能。这一方法与传统的量化方法相比,能够更有效地处理激活异常值,减少性能损失。
关键设计:在QLLM中,设计了高效的调优方法,仅学习少量低秩权重,同时冻结预训练的量化模型。这些低秩参数在训练后可以与冻结权重融合,而不会影响推理过程。
🖼️ 关键图片
📊 实验亮点
在LLaMA-1和LLaMA-2的实验中,QLLM实现了显著的性能提升,特别是在4比特量化的情况下,能够在10小时内完成量化,且在五个零-shot任务上的平均准确率比之前的最优方法提升了7.89%。
🎯 应用场景
QLLM的研究成果在大语言模型的实际应用中具有广泛的潜力,尤其是在资源受限的环境中。通过高效的低比特量化,QLLM能够使得大语言模型在移动设备和边缘计算中得以部署,从而推动自然语言处理技术的普及和应用。未来,QLLM可能在智能助手、自动翻译和内容生成等领域发挥重要作用。
📄 摘要(原文)
Large Language Models (LLMs) excel in NLP, but their demands hinder their widespread deployment. While Quantization-Aware Training (QAT) offers a solution, its extensive training costs make Post-Training Quantization (PTQ) a more practical approach for LLMs. In existing studies, activation outliers in particular channels are identified as the bottleneck to PTQ accuracy. They propose to transform the magnitudes from activations to weights, which however offers limited alleviation or suffers from unstable gradients, resulting in a severe performance drop at low-bitwidth. In this paper, we propose QLLM, an accurate and efficient low-bitwidth PTQ method designed for LLMs. QLLM introduces an adaptive channel reassembly technique that reallocates the magnitude of outliers to other channels, thereby mitigating their impact on the quantization range. This is achieved by channel disassembly and channel assembly, which first breaks down the outlier channels into several sub-channels to ensure a more balanced distribution of activation magnitudes. Then similar channels are merged to maintain the original channel number for efficiency. Additionally, an adaptive strategy is designed to autonomously determine the optimal number of sub-channels for channel disassembly. To further compensate for the performance loss caused by quantization, we propose an efficient tuning method that only learns a small number of low-rank weights while freezing the pre-trained quantized model. After training, these low-rank parameters can be fused into the frozen weights without affecting inference. Extensive experiments on LLaMA-1 and LLaMA-2 show that QLLM can obtain accurate quantized models efficiently. For example, QLLM quantizes the 4-bit LLaMA-2-70B within 10 hours on a single A100-80G GPU, outperforming the previous state-of-the-art method by 7.89% on the average accuracy across five zero-shot tasks.