Representation Shift: Unifying Token Compression with FlashAttention

Joonmyung Choi, Sanghyeok Lee, Byungoh Ko, Eunseo Kim, Jihyung Kil, Hyunwoo J. Kim

TL;DR

This paper introduces "Representation Shift," a novel, training-free method for identifying important tokens in vision models. By unifying token compression with FlashAttention, it achieves significant speedups (up to 5.5x) without sacrificing accuracy, making large vision models more efficient.

What Problem Does This Paper Address?

Transformers have revolutionized computer vision, but their self-attention mechanism has a quadratic computational cost with respect to the number of tokens. This becomes a bottleneck as models and datasets grow. While techniques like token compression aim to reduce this cost by removing redundant tokens, and fused attention kernels like FlashAttention optimize memory access, these two approaches have been incompatible. Prior token compression methods often rely on attention maps to determine token importance, which FlashAttention avoids to maximize efficiency. This leaves a gap: how to efficiently compress tokens in models that use FlashAttention without retraining or complex learnable modules.

Methods

The core contribution is Representation Shift, a training-free, model-agnostic metric that quantifies how much a token's representation changes after passing through a network layer (specifically, attention or MLP layers). The intuition is that tokens crucial for the model's task will have their representations significantly altered (emphasized or suppressed), while less important tokens will show minimal change.

The authors define representation shift as the distance (e.g., L2 distance) between a token's representation before and after a layer's transformation: $s = D(F(x), x)$. They found that using the MLP layer and L2 distance provides the most effective representation shift for token importance. This metric allows for token pruning without needing attention maps, making it compatible with FlashAttention. The method is applied layer-wise to progressively reduce token count.

Datasets

The paper evaluates its method on several standard vision datasets:

  • ImageNet1K: For image classification tasks.
  • MSRVTT [68], MSVD [10], ActivityNet [6], DiDeMo [2], LSMDC [47], SSV2-Label/Template [31]: For video-text retrieval tasks.
  • MSRVTT-QA [67], MSVD-QA [67]: For video question-answering tasks.

Key Insights and Ideas

  • Representation Shift as a Universal Importance Metric: The core insight is that the change in a token's representation within a layer directly reflects its importance to the model's task. This is a more fundamental and generalizable metric than attention scores.
  • Bridging Token Compression and FlashAttention: The paper successfully bridges the gap between token compression and FlashAttention by proposing a method that doesn't rely on attention maps, thus enabling significant speedups without retraining.
  • Model-Agnostic Applicability: The representation shift metric is shown to be effective not only for Transformers but also for CNNs and State Space Models, highlighting its broad utility.
  • MLP Layer is Key for Representation Shift: Experiments reveal that using the MLP layer to compute representation shift is more effective for token importance than using the attention layer or the entire block, likely because MLPs focus on token-specific transformations.
  • L2 Distance is Optimal: Among tested distance metrics (L1, L2, Cosine), L2 distance proved most robust for estimating representation shift for token importance.

Key Results

  • Significant Speedups: The method achieves impressive throughput improvements, up to 5.5x in UMT-B and 4.4x in UMT-L for video-text retrieval tasks, and 4x/3.83x for video question-answering.
  • Competitive Accuracy: Despite the speedups, the proposed method maintains competitive or even slightly better accuracy compared to attention-based pruning and baseline models. For example, on ImageNet1K with DeiT-T/S/B, it achieved up to +5.7% accuracy gain over attention-based scoring.
  • Qualitative Success: Visualizations show that representation shift effectively captures foreground objects in early layers and salient content in middle layers, aligning with saliency detection and demonstrating its ability to identify informative tokens.
  • CNN and SSM Generalization: The method also provides substantial throughput improvements for CNNs (ResNet) and Vision Mamba (ViM), with at least 18% speedup for ResNet and competitive performance for ViM.

Limitations and Future Work

  • Computational Overhead: While training-free and model-agnostic, computing representation shift still incurs a small computational overhead compared to a model without any pruning. However, this overhead is negligible compared to the gains from FlashAttention and token reduction.
  • Layer-wise Application: The current application is layer-wise. The paper suggests future work could explore more sophisticated strategies for applying representation shift across layers.
  • Further Exploration of Architectures: While demonstrated on CNNs and SSMs, further exploration of its applicability to other architectures could be beneficial.

Summary updated

BibTeX
@inproceedings{choi2025representation,
  author = {Joonmyung Choi and Sanghyeok Lee and Byungoh Ko and Eunseo Kim and Jihyung Kil and Hyunwoo J. Kim},
  title = {{Representation Shift: Unifying Token Compression with FlashAttention}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure