[论文解读] BESA: Pruning Large Language Models with Blockwise Parameter-Efficient Sparsity Allocation
BESA 提出了一种用于剪枝大型语言模型(LLMs)的可微分、分块稀疏性分配方法,通过最小化每个 Transformer 块的重建误差,并利用可学习的二值掩码优化各层特定的稀疏性。该方法在单张 A100 GPU 上仅用五小时即实现 LLaMA2-70B 模型 50% 的参数剪枝,且在 WikiText2 上仅比 SparseGPT 的困惑度提升 0.16,达到当前最先进性能,同时保持高效率与高性能。
Large language models (LLMs) have demonstrated outstanding performance in various tasks, such as text summarization, text question-answering, and etc. While their performance is impressive, the computational footprint due to their vast number of parameters can be prohibitive. Existing solutions such as SparseGPT and Wanda attempt to alleviate this issue through weight pruning. However, their layer-wise approach results in significant perturbation to the model's output and requires meticulous hyperparameter tuning, such as the pruning rate, which can adversely affect overall model performance. To address this, this paper introduces a novel LLM pruning technique dubbed blockwise parameter-efficient sparsity allocation (BESA) by applying a blockwise reconstruction loss. In contrast to the typical layer-wise pruning techniques, BESA is characterized by two distinctive attributes: i) it targets the overall pruning error with respect to individual transformer blocks, and ii) it allocates layer-specific sparsity in a differentiable manner, both of which ensure reduced performance degradation after pruning. Our experiments show that BESA achieves state-of-the-art performance, efficiently pruning LLMs like LLaMA1, and LLaMA2 with 7B to 70B parameters on a single A100 GPU in just five hours. Code is available at https://github.com/OpenGVLab/LLMPrune-BESA.
研究动机与目标
- 解决 LLM 中逐层剪枝的局限性,即剪枝误差在各层间累积,且统一剪枝率会降低性能。
- 通过各层稀疏性的可微分优化,减少对人工超参数调优(如剪枝率)的依赖。
- 通过联合剪枝与量化,提升模型效率与推理速度,同时最小化性能下降。
- 通过实现高精度压缩与极小的准确率损失,推动大模型的实际部署。
- 开发一种参数高效的剪枝方法,可在单张 GPU 上扩展至 7B 到 70B 参数的模型。
提出的方法
- 将剪枝问题建模为使用可微分二值掩码最小化各块的重建误差,从而实现基于梯度的优化。
- 将稀疏性表示为每权重的可学习剪枝概率,并通过直通估计法计算梯度,以处理不可微分的二值掩码。
- 以分块方式优化各层特定的稀疏性比率,相比逐层方法显著减少误差累积。
- 在可微分框架中联合剪枝与量化,实现 LLM 的端到端压缩。
- 使用 ViTCoD 硬件模拟器评估在非均衡、层特定稀疏性模式下的实际加速潜力。
- 在模拟中应用结构化的 $n:m$ 稀疏性模式,以评估现代加速器上的实际加速效果。
实验结果
研究问题
- RQ1与逐层方法相比,分块稀疏性分配能否减少 LLM 中的累积剪枝误差?
- RQ2可微分稀疏性优化能否消除 LLM 剪枝中对人工超参数调优的需求?
- RQ3在可微分框架中联合剪枝与量化,能否在实现高参数压缩率的同时保持高性能?
- RQ4在标准基准测试中,BESA 与 SparseGPT 和 Wanda 等 SOTA 方法相比,在困惑度和推理速度方面表现如何?
- RQ5在真实稀疏性模式下,BESA 剪枝模型的实际硬件加速潜力如何?
主要发现
- BESA 在 LLaMA1 和 LLaMA2 模型的剪枝中达到最先进性能,在单张 A100-80GB GPU 上仅用五小时即实现 LLaMA2-70B 模型 50% 的参数剪枝。
- 在 WikiText2 上,BESA 在剪枝 LLaMA2-70B 时相比 SparseGPT 的困惑度提升 0.16,证明其性能保持能力更优。
- BESA 将 LLaMA-7B 各层的平均运行时间减少最多达 1.98 倍(如 down_proj 层),并在 ViTCoD 模拟中实现 1.48× 至 1.98× 的加速效果,适用于不同层类型。
- 在 LLaMA-7B 中,q_proj 层实现 53.87% 的稀疏性,k_proj 层实现 54.54% 的稀疏性,且在多个基准测试中性能下降极小。
- 在所有评估模型(7B、13B、30B)和数据集(WikiText2、C4、PTB)上,BESA 的联合压缩方法均优于基于 Wanda 的后剪枝方法。
- BESA 的参数高效设计在 LLaMA1-7B 中每 Transformer 块仅增加 2.10% 的额外参数,使其在大规模部署中极具实用性。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。