arXiv:2410.03185cs.LGcs.AI2024-10被引 1

提出新型量化方法,让大模型推理中软最大运算快36.9%。

EXAQ: Exponent Aware Quantization For LLMs Acceleration

  • 分析软最大运算瓶颈,优化指数与求和阶段的截断值。
  • 在LLaMA1-30B上实现2比特量化,PIQA数据集性能不变。
  • 首次实现4倍加速,适合追求极致推理速度的部署场景。

量化已成为降低大语言模型(LLMs)推理计算与存储开销的主要方法。当前多数研究聚焦于将权重与激活量化以支持低比特通用矩阵乘法(GEMM),其余非线性操作仍以高精度执行。本研究发现,在应用这些技术后,软最大(softmax)层成为主要瓶颈。softmax包含三个阶段:指数计算、累加与归一化。本文专注于优化前两个阶段。我们提出一种解析方法,确定softmax输入的最优截断值,实现针对LLMs推理的亚4比特量化。该方法在几乎无精度损失的前提下,加速了$e^x$与$\ ext{sum}(e^x)$的计算。例如,在LLaMA1-30B上,于知名PIQA数据集评估中实现了2比特量化下的基线性能。此超低比特量化使累加阶段首次获得约4倍加速。同时加速$e^x$与$ ext{sum}(e^x)$,使软最大运算整体提速36.9%。

原文摘要 · Abstract (English)

Quantization has established itself as the primary approach for decreasing the computational and storage expenses associated with Large Language Models (LLMs) inference. The majority of current research emphasizes quantizing weights and activations to enable low-bit general-matrix-multiply (GEMM) operations, with the remaining non-linear operations executed at higher precision. In our study, we discovered that following the application of these techniques, the primary bottleneck in LLMs inference lies in the softmax layer. The softmax operation comprises three phases: exponent calculation, accumulation, and normalization, Our work focuses on optimizing the first two phases. We propose an analytical approach to determine the optimal clipping value for the input to the softmax function, enabling sub-4-bit quantization for LLMs inference. This method accelerates the calculations of both $e^x$ and $\sum(e^x)$ with minimal to no accuracy degradation. For example, in LLaMA1-30B, we achieve baseline performance with 2-bit quantization on the well-known "Physical Interaction: Question Answering" (PIQA) dataset evaluation. This ultra-low bit quantization allows, for the first time, an acceleration of approximately 4x in the accumulation phase. The combination of accelerating both $e^x$ and $\sum(e^x)$ results in a 36.9% acceleration in the softmax operation.

量化大模型推理软最大优化加速

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。