Skip to main content
QUICK REVIEW

[论文解读] DiffRate : Differentiable Compression Rate for Efficient Vision Transformers

Mengzhao Chen, Wenqi Shao|arXiv (Cornell University)|May 29, 2023
Advanced Neural Network ApplicationsComputer Science被引用 3
一句话总结

DiffRate 为视觉变换器提出了一种可微分的压缩率机制,通过基于梯度的学习联合优化标记剪枝与合并,实现了无需超参数调优的逐层自动压缩率选择。该方法在不进行微调的情况下,于 ViT-H (MAE) 上实现了 40% 的 FLOPs 减少和 1.5 倍的吞吐量提升,且仅带来 0.16% 的准确率下降,达到了最先进的效率表现。

ABSTRACT

Token compression aims to speed up large-scale vision transformers (e.g. ViTs) by pruning (dropping) or merging tokens. It is an important but challenging task. Although recent advanced approaches achieved great success, they need to carefully handcraft a compression rate (i.e. number of tokens to remove), which is tedious and leads to sub-optimal performance. To tackle this problem, we propose Differentiable Compression Rate (DiffRate), a novel token compression method that has several appealing properties prior arts do not have. First, DiffRate enables propagating the loss function's gradient onto the compression ratio, which is considered as a non-differentiable hyperparameter in previous work. In this case, different layers can automatically learn different compression rates layer-wisely without extra overhead. Second, token pruning and merging can be naturally performed simultaneously in DiffRate, while they were isolated in previous works. Third, extensive experiments demonstrate that DiffRate achieves state-of-the-art performance. For example, by applying the learned layer-wise compression rates to an off-the-shelf ViT-H (MAE) model, we achieve a 40% FLOPs reduction and a 1.5x throughput improvement, with a minor accuracy drop of 0.16% on ImageNet without fine-tuning, even outperforming previous methods with fine-tuning. Codes and models are available at https://github.com/OpenGVLab/DiffRate.

研究动机与目标

  • 为解决在标记压缩方法中手动设置压缩率的挑战,该过程繁琐且次优。
  • 实现跨层端到端的、基于梯度的压缩率优化,以实现自动且自适应的率选择。
  • 将标记剪枝与合并统一到单一可微分框架中,联合提升效率与准确率。
  • 通过在极小数据量下学习最优压缩率,减少对微调的依赖。
  • 在多种约束条件下(FLOPs、延迟、功耗)提升计算效率,同时保持准确率损失最小。

提出的方法

  • 引入可微分离散代理(DDP)模块,通过软到硬采样策略重参数化 top-K 标记选择,使梯度能够反向传播通过离散标记选择过程。
  • 为每层引入可学习的压缩率,其中保留的标记数量通过离散选择过程的可微分松弛进行优化。
  • 通过识别并保留重要性最高的标记,在单次前向传播中同时实现剪枝与合并,基于学习到的重要性度量。
  • 采用基于类别注意力(Ac)的标记重要性度量,该度量可微分且无需额外计算开销。
  • 使用多目标损失函数,在多个约束(FLOPs、延迟、功耗)下优化压缩率。
  • 仅用 3 个训练周期(ViT-B 为 2.7 GPU 小时)完成压缩率优化的训练,展现出极高的训练效率。
Figure 1 : Comparison of different token compression methods including token pruning EViT [ 21 ] , token merging ToMe [ 1 ] and our method. Pruned tokens are represented by black and non-border, while merged tokens are represented by patches with the same inner and border color. ( a ) shows that our
Figure 1 : Comparison of different token compression methods including token pruning EViT [ 21 ] , token merging ToMe [ 1 ] and our method. Pruned tokens are represented by black and non-border, while merged tokens are represented by patches with the same inner and border color. ( a ) shows that our

实验结果

研究问题

  • RQ1压缩率能否通过梯度下降实现端到端优化,从而消除对手动设计超参数的依赖?
  • RQ2能否在一个统一的可微分框架中联合优化标记剪枝与合并,以提升压缩效率?
  • RQ3在不微调主模型的前提下,学习最优压缩率需要多少数据?
  • RQ4在优化压缩率时,计算效率(FLOPs、延迟、功耗)与准确率之间的权衡如何?
  • RQ5所提出的方法能否在不微调视觉变换器主干网络的情况下实现 SOTA 性能?

主要发现

  • DiffRate 在 ViT-H (MAE) 上实现了 40% 的 FLOPs 减少和 1.5 倍的吞吐量提升,ImageNet 上仅带来 0.16% 的准确率下降,且无需任何微调。
  • 该方法实现了 SOTA 性能,优于以往需要微调的方法。
  • 仅需 1,000 张图像即可学习最优压缩率,展现出极高的数据效率。
  • 优化过程仅在 3 个训练周期内收敛(ViT-B 为 2.7 GPU 小时),表明训练效率极高。
  • 使用多种复杂度约束(FLOPs、延迟、功耗)可将延迟减少 2.5ms,功耗降低 8mW,且仅带来 0.03% 的准确率下降。
  • 可视化结果证实,DiffRate 能有效去除背景标记,并将判别性较低的前景标记合并,同时保留显著特征。
Figure 2 : Token compression in a transformer block.
Figure 2 : Token compression in a transformer block.

阅读本论文

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

在 Nubint 中阅读本论文

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