Skip to main content
QUICK REVIEW

[论文解读] Sparse Fine-tuning for Inference Acceleration of Large Language Models

Eldar Kurtic, Denis Kuznedelev|arXiv (Cornell University)|Oct 10, 2023
Topic Modeling被引用 4
一句话总结

本文提出了一种用于大语言模型(LLMs)的稀疏微调框架,结合了一种新颖的基于L2的知识蒸馏方法——SquareHead,以及迭代剪枝技术,即使在极端稀疏度(高达75%)下也能保持高精度。该方法在保持精度的同时,实现了显著的端到端推理加速——CPU上最高达9.08倍,GPU上最高达7.49倍,并且与量化技术兼容,可在CPU和GPU工作负载上进一步提升性能。

ABSTRACT

We consider the problem of accurate sparse fine-tuning of large language models (LLMs), that is, fine-tuning pretrained LLMs on specialized tasks, while inducing sparsity in their weights. On the accuracy side, we observe that standard loss-based fine-tuning may fail to recover accuracy, especially at high sparsities. To address this, we perform a detailed study of distillation-type losses, determining an L2-based distillation approach we term SquareHead which enables accurate recovery even at higher sparsities, across all model types. On the practical efficiency side, we show that sparse LLMs can be executed with speedups by taking advantage of sparsity, for both CPU and GPU runtimes. While the standard approach is to leverage sparsity for computational reduction, we observe that in the case of memory-bound LLMs sparsity can also be leveraged for reducing memory bandwidth. We exhibit end-to-end results showing speedups due to sparsity, while recovering accuracy, on T5 (language translation), Whisper (speech translation), and open GPT-type (MPT for text generation). For MPT text generation, we show for the first time that sparse fine-tuning can reach 75% sparsity without accuracy drops, provide notable end-to-end speedups for both CPU and GPU inference, and highlight that sparsity is also compatible with quantization approaches. Models and software for reproducing our results are provided in Section 6.

研究动机与目标

  • 解决在高稀疏度下微调大语言模型时保持模型精度的挑战。
  • 克服因微调数据有限和模型复杂性导致的稀疏微调训练不稳定及精度恢复差的问题。
  • 证明稀疏性不仅可用于计算量减少,还可用于降低内存受限的大语言模型推理中的内存带宽压力。
  • 展示稀疏性与量化技术兼容,可在CPU和GPU硬件上实现叠加的加速效果。
  • 提供可复现的代码和模型,以促进该方法在各类大语言模型应用中的采用与扩展。

提出的方法

  • 在微调过程中应用迭代剪枝,逐步提高稀疏度,同时在下游任务上对模型进行微调。
  • 提出SquareHead,一种基于逐token的ℓ₂知识蒸馏损失,将密集教师模型的输出logits和中间隐藏表征蒸馏到稀疏学生模型中。
  • 使用最小化每一层教师与学生激活之间L2差异的蒸馏损失,提升稀疏微调过程中的泛化能力与稳定性。
  • 利用DeepSparse推理运行时,通过稀疏GEMM内核在CPU上实现稀疏性的推理加速。
  • 实现GPU感知的N:M稀疏格式,以在GPU上实现高效的稀疏推理,结合稀疏性与量化(INT8)。
  • 对稀疏模型应用训练后量化,并评估稀疏性与量化联合使用对精度和延迟的影响。
Figure 1 : Speedups for sparse CPU and GPU kernels on an MPT-7B layer.
Figure 1 : Speedups for sparse CPU and GPU kernels on an MPT-7B layer.

实验结果

研究问题

  • RQ1当微调数据有限且稀疏度较高时,稀疏微调能否在大语言模型中保持高精度?
  • RQ2与标准交叉熵和基于KL散度的蒸馏相比,SquareHead知识蒸馏在稀疏微调中保持精度方面的表现如何?
  • RQ3稀疏性在多大程度上可降低内存受限的大语言模型生成式推理工作负载中的内存带宽压力?
  • RQ4稀疏性与量化能否联合应用以实现更大的推理加速,同时保持精度损失在可接受范围内?
  • RQ5在诸如翻译、语音转录和推理等多样化的大语言模型应用中,稀疏微调的端到端加速与精度权衡如何?

主要发现

  • SquareHead蒸馏使模型在75%稀疏度下仍能实现性能的准确恢复,稀疏MPT-7B模型在GSM8K测试集上达到28.6%的准确率,仅比密集FP32基线的28.2%下降1.6%。
  • 60%稀疏的INT8 MPT-7B模型在单核AMD Ryzen 9 7950X上实现6.7倍加速,而80%稀疏的INT8模型实现9.08倍加速,精度下降7%。
  • 在CPU上,70%稀疏的MPT-7B模型在4核上实现7.49倍加速,达到21.1 tokens/秒,表明稀疏性本身即可带来显著性能提升。
  • 采用SquareHead KD的稀疏微调MPT-7B模型在GSM8K上达到33.0%的准确率,优于密集基线,表明蒸馏有助于提升泛化能力。
  • 稀疏性可降低内存受限生成式模型中的内存带宽压力,即使在计算并非瓶颈的CPU系统中也能实现加速。
  • 该方法与FP32和INT8量化均兼容,稀疏性与量化联合使用可在CPU和GPU上均实现叠加的性能提升。
Figure 2 : BLEU ( $\uparrow$ ) score for variants of loss functions on English-German WMT14 and T5-Small at various compression rates.
Figure 2 : BLEU ( $\uparrow$ ) score for variants of loss functions on English-German WMT14 and T5-Small at various compression rates.

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。