Skip to main content
QUICK REVIEW

[论文解读] QuaRot: Outlier-Free 4-Bit Inference in Rotated LLMs

Saleh Ashkboos, Amirkeivan Mohtashami|arXiv (Cornell University)|Mar 30, 2024
Optical Network TechnologiesEngineering被引用 3
一句话总结

QuaRot 提出了一种新颖的量化框架,通过使用随机化的哈达玛变换消除大语言模型中的异常激活,实现权重、激活和 KV 缓存的端到端 4 位推理,且无精度损失。通过利用计算不变性,它在 Llama 2-70B 上实现了 2.16 倍的预填充加速和 3.39 倍的内存减少,同时在 WikiText-2 上仅造成 0.29 的困惑度下降。

ABSTRACT

We introduce QuaRot, a new Quantization scheme based on Rotations, which is able to quantize LLMs end-to-end, including all weights, activations, and KV cache in 4 bits. QuaRot rotates LLMs in a way that removes outliers from the hidden state without changing the output, making quantization easier. This computational invariance is applied to the hidden state (residual) of the LLM, as well as to the activations of the feed-forward components, aspects of the attention mechanism, and to the KV cache. The result is a quantized model where all matrix multiplications are performed in 4 bits, without any channels identified for retention in higher precision. Our 4-bit quantized LLaMa2-70B model has losses of at most 0.47 WikiText-2 perplexity and retains 99% of the zero-shot performance. We also show that QuaRot can provide lossless 6 and 8 bit LLaMa2 models without any calibration data using round-to-nearest quantization. Code is available at: https://github.com/spcl/QuaRot.

研究动机与目标

  • 解决 4 位量化大语言模型时异常激活带来的严重精度下降问题。
  • 在不保留任何通道于更高精度的前提下,实现权重、激活和 KV 缓存的端到端 4 位量化。
  • 通过正交变换利用计算不变性,重新配置模型的坐标系,从而在不改变模型输出的前提下消除异常值。
  • 在低比特宽度下实现高精度性能,尤其针对仍为高效大语言模型部署主要瓶颈的 4 位推理。

提出的方法

  • 对每个 Transformer 块的输入和输出权重矩阵应用随机化的哈达玛变换,利用计算不变性在保留模型输出的同时消除隐藏状态中的异常特征。
  • 在模型构建过程中将哈达玛变换融合到权重矩阵中,生成一个等效网络,使得激活不再包含极端异常值。
  • 将变换扩展到前馈网络激活以及注意力机制,特别针对键和值,以实现 KV 缓存的 4 位量化。
  • 对权重和激活使用可配置组大小的分组非对称量化,同时在需要时保持 KV 缓存的高精度。
  • 与现有的量化方案(如 GPTQ 和 RTN)集成,用于权重量化,从而与标准的大语言模型推理流水线兼容。
  • 在推理过程中应用在线哈达玛变换,以保持鲁棒性并避免微调,确保与动态自回归生成的兼容性。

实验结果

研究问题

  • RQ1是否可以系统性地消除大语言模型激活中的异常特征而不改变模型输出,从而实现所有组件的 4 位量化?
  • RQ2通过正交变换(如哈达玛矩阵)实现的计算不变性在在多大程度上可用于重新配置模型的内部表征以减少量化误差?
  • RQ3当所有组件——权重、激活和 KV 缓存——均被量化为 4 位时,是否可在 Llama 2-70B 等大语言模型上实现端到端 4 位推理?
  • RQ4与保留部分组件于更高精度的现有 4 位量化方法相比,QuaRot 的性能如何?
  • RQ5在 4 位激活量化背景下,组大小、量化精度和精度损失之间的最优权衡是什么?

主要发现

  • QuaRot 实现了 Llama 2-70B 的端到端 4 位量化,在 WikiText-2 上仅造成 0.29 的困惑度下降,保留了 FP16 基线 99% 的零样本性能。
  • 该方法在 RTX 3090 GPU 上实现了预填充阶段最高 2.16 倍的加速和解码阶段最高 3.39 倍的内存减少。
  • 对于 Llama 2-7B,QuaRot 实现了 2.16 倍的预填充加速和 3.39 倍的内存节省,WikiText-2 上的困惑度损失最多为 0.63。
  • 使用 QuaRot 对权重和激活进行 6 位和 8 位量化在所有测试模型上均无损,未观察到性能下降。
  • KV 缓存量化为 3 位(键为 4 位,值为 3 位)在 Llama 2-70B 上仅造成 0.07 的困惑度下降,表现出极高的鲁棒性。
  • 该方法在所有模型尺寸上均保持优越的量化性能,QuaRot-INT4 在 Llama 2-70B 上达到 3.79 的困惑度,优于 FP16 基线的 3.32。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。