Skip to main content
QUICK REVIEW

[Paper Review] Learned Thresholds Token Merging and Pruning for Vision Transformers

Maxim Bonnaerens, Joni Dambre|arXiv (Cornell University)|Jul 20, 2023
Advanced Neural Network ApplicationsComputer Science9 citations
TL;DR

LTMP combines token merging and pruning with learned thresholds to adaptively reduce Vision Transformer tokens, achieving strong accuracy at various FLOPs reductions with single-epoch fine-tuning.

ABSTRACT

Vision transformers have demonstrated remarkable success in a wide range of computer vision tasks over the last years. However, their high computational costs remain a significant barrier to their practical deployment. In particular, the complexity of transformer models is quadratic with respect to the number of input tokens. Therefore techniques that reduce the number of input tokens that need to be processed have been proposed. This paper introduces Learned Thresholds token Merging and Pruning (LTMP), a novel approach that leverages the strengths of both token merging and token pruning. LTMP uses learned threshold masking modules that dynamically determine which tokens to merge and which to prune. We demonstrate our approach with extensive experiments on vision transformers on the ImageNet classification task. Our results demonstrate that LTMP achieves state-of-the-art accuracy across reduction rates while requiring only a single fine-tuning epoch, which is an order of magnitude faster than previous methods. Code is available at https://github.com/Mxbonn/ltmp .

Motivation & Objective

  • Motivate reducing Vision Transformer computation by adaptive token reduction.
  • Propose a framework that couples token merging and pruning with learnable thresholds.
  • Enable fast convergence by limiting fine-tuning to thresholds only and using a budget-aware loss.
  • Show state-of-the-art accuracy at multiple reduction targets across DeiT variants.

Proposed method

  • Add merging (LTM) and pruning (LTP) modules between MSA and MLP in each transformer block.
  • Use learned threshold masking to decide which tokens to prune or merge in each layer.
  • Modify the attention mechanism to include masked softmax for pruned/merged tokens (Attention_with_mask).
  • Apply a budget-aware training loss that targets a desired FLOPs reduction r_target and computes r_FLOPs from layer-wise token masks.
  • Train only the two thresholds per block while keeping other parameters fixed for single-epoch convergence.
Figure 2: Overview of our approach. LTMP contains a merging and pruning component, each with a learned threshold masking module. The components are added between the Multi-head Self-Attention and MLP components of each transformer block.
Figure 2: Overview of our approach. LTMP contains a merging and pruning component, each with a learned threshold masking module. The components are added between the Multi-head Self-Attention and MLP components of each transformer block.

Experimental results

Research questions

  • RQ1Can token merging and pruning be effectively combined in Vision Transformers without sacrificing accuracy?
  • RQ2Do learned thresholds enable adaptive, layer-wise distribution of token reduction to meet a FLOPs budget?
  • RQ3How does LTMP compare to prior token reduction methods in accuracy and required fine-tuning epochs?

Key findings

  • LTMP achieves strong accuracy across various token-reduction targets, outperforming prior token pruning methods at comparable FLOPs.
  • LTMP converges within a single fine-tuning epoch, introducing only two learnable parameters per transformer block.
  • The budget-aware loss effectively distributes pruning and merging across layers to meet r_target reductions.
  • LTMP shows favorable accuracy-FLOPs trade-offs versus ToMe and other learnable pruning methods, with substantially fewer fine-tuning epochs.
  • Inference latency improvements on mobile devices correlate closely with FLOPs reductions (about 50% latency reduction for DeiT-S at r_FLOPs≈0.5).
Figure 5: Distribution of the number of tokens ( $k$ ) removed by the merging and pruning parts in each layer of LTMP DeiT-S $r_{FLOPs}\approx 0.5$ .
Figure 5: Distribution of the number of tokens ( $k$ ) removed by the merging and pruning parts in each layer of LTMP DeiT-S $r_{FLOPs}\approx 0.5$ .

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.