arXiv:2504.06949cs.LGcs.AI2025-04被引 4

给遗忘变压器动态剪枝,提速70%且不丢性能

Adaptive Computation Pruning for the Forgetting Transformer

  • 根据遗忘门衰减程度动态设定剪枝阈值,安全去除无效计算
  • 在不同模型和上下文长度下,注意力计算量减少约70%,推理速度提升2-3倍
  • 适合需要高效长序列处理的场景,如大模型训练与部署

最近提出的遗忘变压器(FoX)在softmax注意力中引入遗忘门,表现优于或持平于标准RoPE Transformer。观察发现,其许多注意力头遗忘速度很快,导致每步输出主要依赖局部上下文。基于此,我们提出自适应计算剪枝(ACP),动态剪除被遗忘门显著衰减的输入-输出依赖计算。该方法通过动态设置剪枝阈值实现可证明的安全剪枝,确保被剪掉的注意力权重可忽略。将ACP应用于使用FoX的语言模型预训练,在不同模型规模和上下文长度下,软注意力计算量和内存访问量均减少约70%,注意力运行时间降低50%至70%(即提速2-3倍),端到端训练吞吐量提升10%至40%。更长的上下文带来更大的计算节省。所有加速均无性能损失。代码已开源。

原文摘要 · Abstract (English)

The recently proposed Forgetting Transformer (FoX) incorporates a forget gate into softmax attention and has shown consistently better or on-par performance compared to the standard RoPE-based Transformer. Notably, many attention heads in FoX tend to forget quickly, causing their output at each timestep to rely primarily on local context. Based on this observation, we propose Adaptive Computation Pruning (ACP) for FoX, a method that dynamically prunes computations involving input-output dependencies that are strongly decayed by the forget gate. In particular, our method performs provably safe pruning via a dynamically set pruning threshold that guarantees the pruned attention weights are negligible. We apply ACP to language model pretraining with FoX and show it consistently reduces the number of FLOPs and memory accesses in softmax attention by around 70% across different model sizes and context lengths, resulting in a roughly 50% to 70% reduction in attention runtime (or a 2-3$\times$ speedup) and a roughly 10% to 40% increase in end-to-end training throughput. Furthermore, longer context lengths yield greater computational savings. All these speed improvements are achieved without any performance degradation. Our code is available at https://github.com/zhixuan-lin/forgetting-transformer.

Transformer剪枝高效推理长序列

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。