Dual Grained Quantization: Efficient Fine-Grained Quantization for LLM

📄 arXiv: 2310.04836v1 📥 PDF

作者: Luoming Zhang, Wen Fei, Weijia Wu, Yefei He, Zhenyu Lou, Hong Zhou

分类: cs.AI

发布日期: 2023-10-07

备注: 15 pages, 2 figures


💡 一句话要点

提出双粒度量化以解决大语言模型的高效推理问题

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

关键词: 大语言模型 量化技术 推理效率 内存优化 矩阵乘法 深度学习

📋 核心要点

  1. 现有的细粒度量化在权重-激活量化时会影响矩阵乘法的效率,导致推理速度降低。
  2. 本文提出双粒度量化(DGQ),通过将细粒度权重反量化为粗粒度表示,优化推理速度。
  3. 实验表明,DGQ在多种LLM架构中均表现优异,内存减少1.12倍,速度提升3.24倍。

📝 摘要(中文)

大语言模型(LLMs)在内存需求和计算能力方面面临重大硬件挑战。现有的量化方案主要有粗粒度和细粒度两种,细粒度量化虽然能降低量化损失并提升性能,但在权重-激活量化时会影响连续整数矩阵乘法,导致推理效率低下。本文提出了双粒度量化(DGQ),一种新颖的A8W4量化方案,既保持了优越的性能,又确保了快速的推理速度。DGQ将细粒度INT4权重反量化为粗粒度INT8表示,并使用INT8内核进行矩阵乘法。此外,我们开发了一种两阶段网格搜索算法,以简化细粒度和粗粒度量化尺度的确定。实验结果表明,DGQ在多种LLM架构和任务中均优于现有方法,显著实现了1.12倍的内存减少和3.24倍的速度提升。

🔬 方法详解

问题定义:本文旨在解决大语言模型在量化过程中面临的推理效率低下问题。现有的细粒度量化方法在权重-激活量化时会破坏连续整数矩阵乘法,导致性能下降。

核心思路:提出双粒度量化(DGQ),通过将细粒度INT4权重反量化为粗粒度INT8表示,利用INT8内核进行矩阵乘法,从而提高推理速度并保持性能。

技术框架:DGQ的整体架构包括细粒度和粗粒度量化两个阶段,首先进行细粒度量化,然后通过反量化得到粗粒度表示,最后使用INT8内核进行高效的矩阵乘法。

关键创新:DGQ的主要创新在于将细粒度和粗粒度量化结合,解决了细粒度量化带来的推理效率问题。这一方法与传统的单一量化方法本质上不同,能够在保持性能的同时提升速度。

关键设计:在设计中,采用了两阶段网格搜索算法来简化量化尺度的确定,并引入百分位裁剪方案以平滑激活异常值,避免复杂的优化技术。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,DGQ在多种大语言模型架构上均优于现有方法,具体实现了1.12倍的内存减少和3.24倍的速度提升,相较于A16W4实现,展现了显著的性能改进。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理、对话系统和机器翻译等,能够有效提升大语言模型在实际应用中的推理速度和内存效率,促进其在资源受限环境中的部署。

📄 摘要(原文)

Large Language Models (LLMs) pose significant hardware challenges related to memory requirements and computational ability. There are two mainstream quantization schemes for LLMs: coarse-grained ($\textit{e.g.,}$ channel-wise) quantization and fine-grained ($\textit{e.g.,}$ group-wise) quantization. Fine-grained quantization has smaller quantization loss, consequently achieving superior performance. However, when applied to weight-activation quantization, it disrupts continuous integer matrix multiplication, leading to inefficient inference. In this paper, we introduce Dual Grained Quantization (DGQ), a novel A8W4 quantization for LLM that maintains superior performance while ensuring fast inference speed. DSQ dequantizes the fine-grained INT4 weight into coarse-grained INT8 representation and preform matrix multiplication using INT8 kernels. Besides, we develop a two-phase grid search algorithm to simplify the determination of fine-grained and coarse-grained quantization scales. We also devise a percentile clipping schema for smoothing the activation outliers without the need for complex optimization techniques. Experimental results demonstrate that DGQ consistently outperforms prior methods across various LLM architectures and a wide range of tasks. Remarkably, by our implemented efficient CUTLASS kernel, we achieve $\textbf{1.12}$ $\times$ memory reduction and $\textbf{3.24}$ $\times$ speed gains comparing A16W4 implementation. These advancements enable efficient deployment of A8W4 LLMs for real-world applications.