Fast and Efficient 2-bit LLM Inference on GPU: 2/4/16-bit in a Weight Matrix with Asynchronous Dequantization

📄 arXiv: 2311.16442v4 📥 PDF

作者: Jinhao Li, Jiaming Xu, Shiyao Li, Shan Huang, Jun Liu, Yaoxiu Lian, Guohao Dai

分类: cs.LG, cs.DC

发布日期: 2023-11-28 (更新: 2024-11-09)


💡 一句话要点

提出混合精度量化与异步解量化以提升LLM推理效率

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 量化技术 混合精度 异步解量化 推理效率 GPU优化 自然语言处理

📋 核心要点

  1. 现有LLM推理方法面临高昂的成本和准确率损失,尤其在使用2位量化时。
  2. 本文提出权重内部混合精度量化、独占2位稀疏异常值和异步解量化等技术以提升推理效率。
  3. 实验结果显示,采用新方法的Llama2-7b模型实现了1.74倍的加速,并显著降低了运行和总成本。

📝 摘要(中文)

大型语言模型(LLMs)在多个领域展现了卓越的能力,但推理成本高昂。以往研究通过量化方法降低推理成本,然而2位单精度权重量化会导致超过3%的准确率损失。为此,现有的最先进方法采用混合精度以提高准确性,但仍面临权重矩阵分布不均、稀疏异常值导致速度显著下降以及GPU上解量化操作耗时等挑战。本文提出了三项技术:1)权重内部混合精度量化;2)具有最小速度下降的独占2位稀疏异常值;3)异步解量化。通过在不同模型家族和规模上的广泛实验,我们实现了每个权重的2.91位量化,且损失可忽略不计。最终,我们的设计在Llama2-7b模型上实现了1.74倍的端到端加速,并将运行时间和总成本分别降低了2.53倍和2.29倍,同时减少了GPU需求。

🔬 方法详解

问题定义:本文旨在解决大型语言模型推理中的高成本和准确率损失问题。现有方法在使用2位量化时,准确率损失超过3%,且在GPU上解量化操作耗时较长。

核心思路:提出混合精度量化和异步解量化的方案,以减少推理延迟和内存消耗,同时保持较高的准确性。通过在权重矩阵中采用不同的位数进行量化,优化了权重的存储和计算效率。

技术框架:整体架构包括三个主要模块:1)权重内部混合精度量化,2)独占2位稀疏异常值处理,3)异步解量化。每个模块协同工作,以提高推理速度和降低资源消耗。

关键创新:最重要的创新在于引入了异步解量化技术,解决了传统解量化过程中的时间瓶颈,同时通过混合精度量化有效降低了模型的内存占用。

关键设计:在量化过程中,采用了2/4/16位混合精度策略,并针对稀疏异常值进行了专门处理,以确保在保持性能的同时,尽量减少速度损失。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,采用本文提出的方法,Llama2-7b模型的端到端推理速度提升了1.74倍,同时运行时间和总成本分别降低了2.53倍和2.29倍,且对GPU的需求显著减少,展现了良好的实用性和效率。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理、对话系统和智能助手等。通过提升大型语言模型的推理效率,能够在资源受限的环境中更好地部署这些模型,推动人工智能技术的普及与应用。未来,该技术可能会影响更多领域的智能化进程,提升用户体验。

📄 摘要(原文)

Large language models (LLMs) have demonstrated impressive abilities in various domains while the inference cost is expensive. Many previous studies exploit quantization methods to reduce LLM inference cost by reducing latency and memory consumption. Applying 2-bit single-precision weight quantization brings >3% accuracy loss, so the state-of-the-art methods use mixed-precision methods for LLMs (e.g. Llama2-7b, etc.) to improve the accuracy. However, challenges still exist: (1) Uneven distribution in weight matrix. (2) Large speed degradation by adding sparse outliers. (3) Time-consuming dequantization operations on GPUs. To tackle these challenges and enable fast and efficient LLM inference on GPUs, we propose the following techniques in this paper. (1) Intra-weight mixed-precision quantization. (2) Exclusive 2-bit sparse outlier with minimum speed degradation. (3) Asynchronous dequantization. We conduct extensive experiments on different model families (e.g. Llama3, etc.) and model sizes. We achieve 2.91-bit for each weight considering all scales/zeros for different models with negligible loss. As a result, with our 2/4/16 mixed-precision quantization for each weight matrix and asynchronous dequantization during inference, our design achieves an end-to-end speedup for Llama2-7b is 1.74x over the original model, and we reduce both runtime cost and total cost by up to 2.53x and 2.29x with less GPU requirements.