Skip to main content
QUICK REVIEW

[论文解读] SliceGPT: Compress Large Language Models by Deleting Rows and Columns

Saleh Ashkboos, Maximilian L. Croci|arXiv (Cornell University)|Jan 26, 2024
Topic Modeling被引用 8
一句话总结

SliceGPT 通过对权重矩阵应用正交变换并删除主行/列来压缩大型语言模型,在性能损失最小的情况下实现高达 30% 的压缩并提升推理速度。

ABSTRACT

Large language models have become the cornerstone of natural language processing, but their use comes with substantial costs in terms of compute and memory resources. Sparsification provides a solution to alleviate these resource constraints, and recent works have shown that trained models can be sparsified post-hoc. Existing sparsification techniques face challenges as they need additional data structures and offer constrained speedup with current hardware. In this paper we present SliceGPT, a new post-training sparsification scheme which replaces each weight matrix with a smaller (dense) matrix, reducing the embedding dimension of the network. Through extensive experimentation, we show that SliceGPT can remove up to 25% of the model parameters (including embeddings) for LLAMA2-70B, OPT 66B and Phi-2 models while maintaining 99%, 99% and 90% zero-shot task performance of the dense model respectively. Our sliced models run on fewer GPUs and run faster without any additional code optimization: on 24GB consumer GPUs we reduce the total compute for inference on LLAMA2-70B to 64% of that of the dense model; on 40GB A100 GPUs we reduce it to 66%. We offer a new insight, computational invariance in transformer networks, which enables SliceGPT and we hope it will inspire and enable future avenues to reduce memory and computation demands for pre-trained models. Code is available at: https://github.com/microsoft/TransformerCompression

研究动机与目标

  • 激励在训练后降低大型语言模型(LLMs)的内存和计算成本。
  • 引入一种新的稀疏化范式,在缩小嵌入和层矩阵的同时保持功能性。
  • 在无需大规模微调的情况下,通过降低对 GPU 的需求实现更快的推理。
  • 提供对 Transformer 网络中计算不变性的理论与经验洞见。

提出的方法

  • 通过使用 PCA 将激活投影到其主成分,将每个权重矩阵替换为更小的密集矩阵。
  • 引入并利用计算不变性:正交变换,在随后使用适当的逆变换时可保持输出。
  • 将 LayerNorm 转换为 RMSNorm 以使不变性变换成为可实现。
  • 对每一层应用正交变换 Q_l,并调整残差连接以维持等价性。
  • 通过删除次主成分来切片,在 W_in、W_out 和 W_embd 中删除相应的行/列,尽量减少对性能的影响。
  • 使用标定数据集对 Q_l 进行标定,并通过层激活的 PCA 进行计算,从而实现数据驱动的切片。

实验结果

研究问题

  • RQ1正交变换是否能够在 RMSNorm 连接的网络中跨层保持 Transformer 的输出?
  • RQ2逐层 PCA 基切片是否在保留零-shot 和生成性能的同时,有效减少参数数量和嵌入?
  • RQ3对大型语言模型(如 OPT、Llama-2、Phi-2)进行最多约 30% 切片时,性能与吞吐的权衡是什么?
  • RQ4切片后是否需要或有益于通过恢复微调以维持精度?

主要发现

  • SliceGPT 可以将 OPT 和 Llama-2 模型的压缩高达 30%(包括嵌入),同时仍保持高任务性能。
  • 在 WikiText-2 数据集上,25% 切片的 SliceGPT 在不同模型规模上维持接近密集模型的困惑度,优于 SparseGPT 2:4 基线。
  • 在零-shot 任务中,SliceGPT 在较大模型上达到可与密集模型相当的精度,其中 OPT 通常比 Llama-2 更易于压缩。
  • 结合使用 Alpaca 风格数据的恢复微调(RFT),切片后的大模型可恢复显著的精度,例如 70B OPT 切片经 RFT 后接近下游任务的密集性能。
  • SliceGPT 带来显著的吞吐提升:在 80GB 的 H100 显卡上,25% 切片的吞吐量最多提升至 1.55x,50% 切片可将最大模型所需显卡从两张降到一张。
  • 该方法仅需要一次性后训练过程(不需要大量再次训练)即可实现显著的参数减少和加速。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

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