arXiv:2412.00648cs.LGstat.ML2024-12被引 15

提出DFRot方法,让旋转量化大模型同时消除异常值和海量激活影响。

DFRot: Achieving Outlier-Free and Massive Activation-Free for Rotated LLMs with Refined Rotation

  • 用加权损失与正交投影优化旋转矩阵,改善激活分布。
  • 仅用单样本调参,4比特量化下困惑度提升0.98(LLaMA3-70B)。
  • 适合追求低精度量化高精度的模型部署场景。

将激活与权重矩阵旋转以降低大语言模型中异常值的影响,近年在模型量化中备受关注。已有研究发现,在4比特权重与4比特激活(W4A4)等低精度量化下,随机哈达玛变换比随机正交变换显著提升准确率,但原因不明。本文发现,两类变换均能有效消除常见词元的异常值,且量化误差相近;准确率差异主要源于哈达玛变换可轻微降低海量激活词元的量化误差,而正交变换反而增加误差。由于这些词元极为罕见却对模型精度至关重要,形成长尾优化问题,因此我们构建简单有效的加权损失函数。同时提出旋转矩阵优化策略:交替优化量化参数,并使用正交普鲁斯特变换精炼旋转矩阵,使旋转后激活值分布更利于量化,尤其针对海量激活词元。本方法实现双重无瑕:异常值消除与海量激活消除,称为DFRot。大量实验表明其高效有效:仅用单样本调参,对难量化模型LLaMA3-70B在W4A4KV4与W4A4KV16下分别取得0.98与0.95的困惑度改进。

原文摘要 · Abstract (English)

Rotating the activation and weight matrices to reduce the influence of outliers in large language models (LLMs) has recently attracted significant attention, particularly in the context of model quantization. Prior studies have shown that in low-precision quantization scenarios, such as 4-bit weights and 4-bit activations (W4A4), randomized Hadamard transforms can achieve significantly higher accuracy than randomized orthogonal transforms. Notably, the reason behind this phenomenon remains unknown. In this paper, we find that these transformations show substantial improvement in eliminating outliers for common tokens and achieve similar quantization error. The primary reason for the accuracy difference lies in the fact that randomized Hadamard transforms can slightly reduce the quantization error for tokens with massive activations while randomized orthogonal transforms increase the quantization error. Due to the extreme rarity of these tokens and their critical impact on model accuracy, we consider this a long-tail optimization problem, and therefore construct a simple yet effective method: a weighted loss function. Additionally, we propose an optimization strategy for the rotation matrix that involves alternating optimization of quantization parameters while employing orthogonal Procrustes transforms to refine the rotation matrix. This makes the distribution of the rotated activation values more conducive to quantization, especially for tokens with massive activations. Our method enhances the Rotated LLMs by achieving dual free, Outlier-Free and Massive Activation-Free, dubbed as DFRot. Extensive experiments demonstrate the effectiveness and efficiency of DFRot. By tuning the rotation matrix using just a single sample, DFRot achieves a perplexity improvement of 0.98 and 0.95 on W4A4KV4 and W4A4KV16, respectively, for LLaMA3-70B, a model known for its quantization challenges.

量化旋转大模型低精度

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