Adaptive Layer-Wise Transformations for Post-Training Quantization of Large Language Models
作者: Cuong Pham, Hoang Anh Dung, Cuong C. Nguyen, Trung Le, Gustavo Carneiro, Jianfei Cai, Thanh-Toan Do
分类: cs.LG
发布日期: 2025-11-21
💡 一句话要点
提出自适应层级变换框架,用于大语言模型后训练量化,显著提升低比特量化性能。
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 大语言模型量化 后训练量化 自适应变换 低比特量化 异常值抑制
📋 核心要点
- 大语言模型量化面临激活和权重异常值挑战,导致低比特量化性能显著下降。
- 提出自适应层级变换框架,根据每层特性选择最优变换类型,缓解异构分布问题。
- 实验表明,该方法在LLaMA模型上优于固定变换方法,显著提升低比特量化性能。
📝 摘要(中文)
大语言模型部署需要大量计算资源,量化对于实际应用至关重要。然而,有效量化的主要障碍在于激活和权重中的系统性异常值,这会导致LLM性能显著下降,尤其是在低比特设置下。现有的基于变换的方法(如仿射和旋转变换)虽然能有效缓解异常值,但它们采用同构变换设置,即在所有层中使用相同的变换类型,忽略了LLM内部的异构分布特征。本文提出了一种自适应变换选择框架,该框架系统地确定每个层的最佳变换。为此,我们首先将变换选择公式化为一个可微优化问题,以实现每个层的精确变换类型。然而,为每个模型搜索最佳层级变换在计算上是昂贵的。为此,我们建立了权重分布峰度与精确变换类型之间的联系。具体来说,我们提出了一种使用鲁棒$z$-score归一化的异常值引导层选择方法,该方法实现了与可微搜索相当的性能,同时显著降低了开销。对LLaMA系列模型的全面实验表明,我们的自适应方法始终优于广泛使用的固定变换设置。例如,在LLaMA-3-8B模型的激进W3A3K2V2量化设置下,我们的方法实现了高达4.58困惑度点的改进,以及在平均六任务零样本准确率方面提高了2.11%,与当前最佳现有方法FlatQuant相比,证明了异构变换选择对于最佳LLM量化的必要性。
🔬 方法详解
问题定义:现有大语言模型量化方法,如FlatQuant,通常采用同构变换,即所有层使用相同的变换方式。然而,LLM内部各层激活和权重的分布具有异构性,统一的变换方式无法有效处理所有层的异常值,导致量化精度下降。因此,需要一种能够根据每层特性自适应选择变换方式的量化方法。
核心思路:论文的核心思路是根据每一层的权重分布特性,自适应地选择最适合该层的变换方式。通过对每一层进行独立的变换优化,可以更有效地抑制异常值,从而提高量化模型的精度。论文建立了权重分布的峰度与最佳变换类型之间的联系,从而指导变换类型的选择。
技术框架:该方法包含两个主要阶段:1) 可微搜索阶段:将变换选择问题建模为可微优化问题,通过梯度下降搜索每一层的最佳变换类型。2) 异常值引导层选择阶段:利用权重分布的峰度信息,通过鲁棒的z-score归一化方法选择需要进行变换的层,并确定其变换类型。该阶段旨在降低计算复杂度,提高效率。
关键创新:该方法最重要的创新点在于提出了自适应的层级变换选择机制,打破了传统量化方法中同构变换的限制。通过对每一层进行独立的变换优化,可以更有效地抑制异常值,从而提高量化模型的精度。此外,论文还建立了权重分布的峰度与最佳变换类型之间的联系,为变换类型的选择提供了理论依据。
关键设计:在异常值引导层选择阶段,论文使用鲁棒的z-score归一化方法来识别异常值。具体来说,使用中位数绝对偏差(MAD)代替标准差,以减少异常值对z-score计算的影响。此外,论文还设计了一种基于峰度的变换类型选择策略,根据峰度值的大小选择不同的变换类型,例如仿射变换或旋转变换。
🖼️ 关键图片
📊 实验亮点
实验结果表明,该方法在LLaMA-3-8B模型上,W3A3K2V2量化设置下,相比于FlatQuant,困惑度降低了4.58,平均六任务零样本准确率提高了2.11%。这表明该方法在低比特量化方面具有显著优势,能够有效提升量化模型的性能。
🎯 应用场景
该研究成果可应用于大语言模型的低成本部署,尤其是在资源受限的边缘设备上。通过自适应量化,可以在保证模型性能的前提下,显著降低模型大小和计算复杂度,从而实现更广泛的应用,例如移动设备上的智能助手、嵌入式系统的自然语言处理等。
📄 摘要(原文)
Large language models require significant computational resources for deployment, making quantization essential for practical applications. However, the main obstacle to effective quantization lies in systematic outliers in activations and weights, which cause substantial LLM performance degradation, especially at low-bit settings. While existing transformation-based methods like affine and rotation transformations successfully mitigate outliers, they apply the homogeneous transformation setting, i.e., using the same transformation types across all layers, ignoring the heterogeneous distribution characteristics within LLMs. In this paper, we propose an adaptive transformation selection framework that systematically determines optimal transformations on a per-layer basis. To this end, we first formulate transformation selection as a differentiable optimization problem to achieve the accurate transformation type for each layer. However, searching for optimal layer-wise transformations for every model is computationally expensive. To this end, we establish the connection between weight distribution kurtosis and accurate transformation type. Specifically, we propose an outlier-guided layer selection method using robust $z$-score normalization that achieves comparable performance to differentiable search with significantly reduced overhead. Comprehensive experiments on LLaMA family models demonstrate that our adaptive approach consistently outperforms the widely-used fixed transformation settings. For example, our method achieves an improvement of up to 4.58 perplexity points and a 2.11% gain in average six-task zero-shot accuracy under aggressive W3A3K2V2 quantization settings for the LLaMA-3-8B model compared to the current best existing method, FlatQuant, demonstrating the necessity of heterogeneous transformation selection for optimal LLM quantization.