Skip to main content
QUICK REVIEW

[Paper Review] DiffRate : Differentiable Compression Rate for Efficient Vision Transformers

Mengzhao Chen, Wenqi Shao|arXiv (Cornell University)|May 29, 2023
Advanced Neural Network ApplicationsComputer Science3 citations
TL;DR

DiffRate proposes a differentiable compression rate mechanism for Vision Transformers that jointly optimizes token pruning and merging via gradient-based learning, enabling layer-wise automatic compression rate selection without hyperparameter tuning. It achieves state-of-the-art efficiency with 40% FLOPs reduction and 1.5× throughput gain on ImageNet using ViT-H (MAE) with only 0.16% accuracy drop, even without fine-tuning.

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.

Motivation & Objective

  • To address the challenge of manually setting compression rates in token compression methods, which is tedious and sub-optimal.
  • To enable end-to-end, gradient-based optimization of compression rates across layers, allowing automatic and adaptive rate selection.
  • To unify token pruning and merging into a single differentiable framework that jointly improves efficiency and accuracy.
  • To reduce dependency on fine-tuning by learning optimal compression rates with minimal data.
  • To improve computational efficiency under multiple constraints (FLOPs, latency, power) without significant accuracy loss.

Proposed method

  • Introduces a Differentiable Discrete Proxy (DDP) module that reparameterizes top-K token selection using a soft-to-hard sampling strategy, enabling gradient back-propagation through discrete token selection.
  • Uses a learnable compression rate per layer, where the number of tokens to preserve is optimized via differentiable relaxation of the discrete selection process.
  • Applies both pruning and merging in a single forward pass by identifying and preserving top-importance tokens via a learned importance metric.
  • Employs a token importance metric based on class attention (Ac), which is differentiable and requires no additional computation.
  • Optimizes compression rates under multiple constraints (FLOPs, latency, power) using a multi-objective loss function.
  • Trains the compression rate optimization in only 3 epochs (2.7 GPU hours for ViT-B), demonstrating high training efficiency.
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

Experimental results

Research questions

  • RQ1Can compression rates be optimized end-to-end via gradient descent, eliminating the need for handcrafted hyperparameters?
  • RQ2Can both token pruning and merging be jointly optimized in a single differentiable framework to improve compression efficiency?
  • RQ3How much data is required to learn optimal compression rates without fine-tuning the main model?
  • RQ4What is the trade-off between computational efficiency (FLOPs, latency, power) and accuracy when optimizing compression rates?
  • RQ5Can the proposed method achieve state-of-the-art performance without fine-tuning the vision transformer backbone?

Key findings

  • DiffRate reduces FLOPs by 40% and improves throughput by 1.5× on ViT-H (MAE) with only a 0.16% accuracy drop on ImageNet, without any fine-tuning.
  • The method achieves state-of-the-art performance, outperforming previous methods that require fine-tuning.
  • Only 1,000 images are sufficient to learn optimal compression rates, demonstrating high data efficiency.
  • The optimization converges in just 3 training epochs (2.7 GPU hours for ViT-B), indicating high training efficiency.
  • Using multiple complexity constraints (FLOPs, latency, power) reduces latency by 2.5ms and power by 8mW with only a 0.03% accuracy drop.
  • Visualizations confirm that DiffRate effectively removes background tokens and merges less-discriminative foreground tokens while preserving salient features.
Figure 2 : Token compression in a transformer block.
Figure 2 : Token compression in a transformer block.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.