[论文解读] LUT-GEMM: Quantized Matrix Multiplication based on LUTs for Efficient Inference in Large-Scale Generative Language Models
LUT-GEMM 引入一个基于查找表的矩阵乘法内核,支持权重仅量化(通过扩展的 BCQ 与偏置实现的均匀或非均匀)以及全精度激活,能够显著降低延迟,并有可能在单个 GPU 上以最小的精度损失运行 OPT-175B。
Recent advances in self-supervised learning and the Transformer architecture have significantly improved natural language processing (NLP), achieving remarkably low perplexity. However, the growing size of NLP models introduces a memory wall problem during the generation phase. To mitigate this issue, recent efforts have focused on quantizing model weights to sub-4-bit precision while preserving full precision for activations, resulting in practical speed-ups during inference on a single GPU. However, these improvements primarily stem from reduced memory movement, which necessitates a resource-intensive dequantization process rather than actual computational reduction. In this paper, we introduce LUT-GEMM, an efficient kernel for quantized matrix multiplication, which not only eliminates the resource-intensive dequantization process but also reduces computational costs compared to previous kernels for weight-only quantization. Furthermore, we proposed group-wise quantization to offer a flexible trade-off between compression ratio and accuracy. The impact of LUT-GEMM is facilitated by implementing high compression ratios through low-bit quantization and efficient LUT-based operations. We show experimentally that when applied to the OPT-175B model with 3-bit quantization, LUT-GEMM substantially accelerates token generation latency, achieving a remarkable 2.1$ imes$ improvement on a single GPU when compared to OPTQ, which relies on the costly dequantization process.
研究动机与目标
- 通过在保持激活精度的前提下压缩权重精度,实现对大规模生成式语言模型的内存和能耗高效推理。
- 提出一种权重仅量化内核,消除对均匀与非均匀量化的去量化开销。
- 基于带偏置的扩展二进制编码量化(BCQ)开发 LUT-GEMM,以表示多样化的量化方案。
- 证明增加压缩(低比特权重)在大规模语言模型中能减少 GPU 数量和延迟,而不会带来显著的精度损失。
- 展示实际加速和单GPU推理的可行性,适用于非常大的模型(如 OPT-175B)。
提出的方法
- 在统一的 BCQ 格式中通过引入带偏置项来表示非均匀和均匀量化。
- 引入分组 BCQ,设定的分组大小 g,以权衡压缩比和量化误差。
- 开发 LUT-GEMM,使用基于 LUT 的计算来替代冗余的部分和避免激活去量化,从而实现高效的权重仅量化 GEMMs。
- 将 LUT-GEMM 架构映射到 GPU 线程,使用快速片上内存中的共享 LUT,并优化 tiling/hete 步骤(每 TB 的参数,mu=8,l,t_h,t_w,q,g)。
- 将单批 LUT-GEMM 运算表述为 y = sum_{i=1}^q (A_i ∘ (B_i · x)),其中 A 是 FP16 缩放,B 是 FP16 二值,x 是 FP16 输入,∘ 是逐元素乘法。
- 提供经验性的 LUT 优化(mu, g, q)指导,并讨论内存占用驱动的延迟。
实验结果
研究问题
- RQ1权重仅量化内核是否能在不对激活进行去量化的情况下加速大规模语言模型推理?
- RQ2在扩展 BCQ 以带偏置项并引入分组 BCQ 后,对大规模语言模型的压缩、延迟和精度有何影响?
- RQ3使用 LUT-GEMM 相较于现有的去量化方法(如 OPTQ),在 OPT-175B 上可以实现哪些延迟上的收益?
- RQ4哪些实际的 GPU 实现考虑(线程配置、LUT 存储、内存占用)可以最大化 LUT-GEMM 的吞吐量?
主要发现
| Kernel | Data Type Precision for Data | Weight | Output | Latency (ms) |
|---|---|---|---|---|
| cuBLAS | FP32 | FP32 | FP32 | 1.4015 |
| cuBLAS | FP16 | FP16 | FP16 | 0.7256 |
| cuBLAS | INT8 | INT8 | INT32 | 0.6345 |
| OPTQ (Frantar et al., 2022) | FP16 | INT3 | FP16 | 0.1956 |
| OPTQ (Frantar et al., 2022) | FP32 | INT3 | FP32 | 0.3047 |
| LUT-GEMM | FP16 | BCQ8, INT8 | FP16 | 0.4620 |
| LUT-GEMM | FP16 | BCQ3, INT3 | FP16 | 0.1956 |
- LUT-GEMM 实现了带有灵活 BCQ 表达的权重仅量化,兼容均匀与非均匀量化格式。
- 通过对 BCQ 引入偏置项并引入分组量化,扩展了量化空间,使大规模语言模型的压缩与延迟权衡得到改善。
- 对于 OPT-175B,LUT-GEMM 在单个 GPU 上使用 3-bit BCQ 权重时,令牌生成延迟比 OPTQ 快 2.1×,减少对多 GPU 的需求。
- LUT-GEMM 显示在接近单 GPU 的推理情况下,OPT-175B 的精度/性能损失极小,能够在不产生高额去量化开销的情况下缓解内存瓶颈。
- 延迟规模与内存占用密切相关;提高分组大小 g 超过一个阈值会使延迟趋近于逐行 BCQ,同时带来更高的压缩潜力。
- 实证结果表明 LUT-GEMM 在各核实现中的延迟优势(例如具有 BCQ3/INT3 的 LUT-GEMM 在 0.1956 ms,而 OPTQ FP16/INT3 为 0.3047 ms,见表 2)。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。