Skip to main content
QUICK REVIEW

[论文解读] A Fast Post-Training Pruning Framework for Transformers

Woosuk Kwon, Sehoon Kim|arXiv (Cornell University)|Mar 29, 2022
Advanced Neural Network ApplicationsComputer Science被引用 38
一句话总结

一个用于变换器的剪枝框架,在不重新训练的情况下实现显著的 FLOPs 和延迟降低,使用基于 Fisher 的掩码搜索、重排和掩码微调来剪枝注意力头和 FFN 过滤器,同时保持准确性。

ABSTRACT

Pruning is an effective way to reduce the huge inference cost of Transformer models. However, prior work on pruning Transformers requires retraining the models. This can add high training cost and high complexity to model deployment, making it difficult to use in many practical situations. To address this, we propose a fast post-training pruning framework for Transformers that does not require any retraining. Given a resource constraint and a sample dataset, our framework automatically prunes the Transformer model using structured sparsity methods. To retain high accuracy without retraining, we introduce three novel techniques: (i) a lightweight mask search algorithm that finds which heads and filters to prune based on the Fisher information; (ii) mask rearrangement that complements the search algorithm; and (iii) mask tuning that reconstructs the output activations for each layer. We apply our method to BERT-base and DistilBERT, and we evaluate its effectiveness on GLUE and SQuAD benchmarks. Our framework achieves up to 2.0x reduction in FLOPs and 1.56x speedup in inference latency, while maintaining < 1% loss in accuracy. Importantly, our framework prunes Transformers in less than 3 minutes on a single GPU, which is over two orders of magnitude faster than existing pruning approaches that retrain the models.

研究动机与目标

  • 激励在 FLOPs/延迟约束下面向部署的、无需重新训练的 Transformer 模型实际压缩。
  • 基于信息理论,开发一个三阶段剪枝流水线(掩码搜索、重排、微调),以选择要剪枝的注意力头和 FFN 过滤器。
  • 通过使用少量数据实现快速剪枝,避免全量重新训练,同时在紧张预算内保持准确性。

提出的方法

  • 将剪枝表示为对多头注意力(MHA)头和 FFN 过滤器的受约束二进制掩码优化。
  • 使用基于 Fisher 信息的掩码搜索,在 FLOPs/延迟预算下选择剪枝的头/过滤器。
  • 应用掩码重排阶段,通过分块对角 Fisher 近似来捕捉同层内的相互作用。
  • 进行掩码微调阶段,通过求解逐层线性最小二乘问题来重构层激活。
  • 将该方法扩展到延迟约束,通过对延迟进行分段线性近似并相应地调整搜索。
  • 展示在 BERT_BASE 和 DistilBERT 上的剪枝,在 GLUE 和 SQuAD 上的评估,精度损失极小。

实验结果

研究问题

  • RQ1Transformer 模型是否可以在不重新训练的情况下剪枝以满足 FLOPs/延迟约束?
  • RQ2如何识别应剪枝的头和 FFN 过滤器,以在给定资源约束下最小化准确性损失?
  • RQ3具有掩码搜索、重排和微调的后训练剪枝流水线在效率与准确性权衡方面是否优于基于重新训练的剪枝方法?
  • RQ4在常见基准上,使用无需重新训练的剪枝在实际硬件上可以实现的实际加速是多少?

主要发现

  • 该框架在 FLOPs 上实现高达 2.0× 的降低,推理延迟最高可达 1.56× 的加速,且准确率损失小于1%。
  • 剪枝可在单个 GPU 上完成不到 3 分钟,比基于重新训练的剪枝方法快上两个数量级以上。
  • 在 GLUE 和 SQuAD 上,对 BERT_BASE 和 DistilBERT 进行剪枝,在 1% 精度损失的情况下实现显著的 FLOPs 降低(BERT_BASE 在若干任务上原始 FLOPs 的 60-70%;DistilBERT 大约 50%)。
  • 在 NVIDIA V100 的延迟实验中,在批量大小 256、1% 精度约束下,平均加速约为 1.47× 到 1.56×。
  • 提出的基于 Fisher 的掩码搜索、重排和微调阶段各自有助于恢复或保持准确性,其中掩码微调在准确性恢复中起关键作用。
  • 与先前的结构剪枝方法相比,无重新训练的方法在 FLOPs-准确性权衡方面达到可比或更好的效果,且剪枝成本显著降低(端到端剪枝时间不到一分钟)。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。