Introduction
Vision Transformers (ViTs) have established state-of-the-art performance across various computer vision tasks. However, their deployment is often hindered by high computational costs, primarily stemming from the self-attention mechanism which scales quadratically with the number of input tokens (image patches). A significant inefficiency in standard ViTs is the uniform treatment of all image patches; static architectures process background or redundant information with the same intensity as the primary subject. This paper introduces Adaptive Token Sampling (ATS), a method to mitigate this "computational tax" by dynamically dropping redundant tokens.
The Adaptive Token Sampling (ATS) Module
ATS is a parameter-free and differentiable module designed to prune redundant tokens on the fly. Unlike previous pruning methods that rely on fixed rates or additional learnable parameters, ATS adapts to the specific content of each input image, allowing for content-dependent computation.
Token Scoring and Selection
The ATS module identifies informative tokens through a multi-step process:
- Importance Scoring: ATS leverages the attention weights of the classification (CLS) token from the transformer's self-attention layer. The intuition is that if the CLS token is not "paying attention" to a specific patch, that patch is likely irrelevant to the final prediction. To refine this signal, these weights are multiplied by the $L_2$ norm of the corresponding "Value" vectors ($V$). This ensures that tokens contributing negligible numerical value to the output are deprioritized.
- Inverse Transform Sampling: Rather than employing a rigid "Top-K" selection strategy—which can lead to a loss of contextual diversity—ATS treats the importance scores as a probability distribution. By using Inverse Transform Sampling, the model can select a variable number of tokens ($K'$) based on the image's complexity. This allows the network to allocate more resources to cluttered scenes and fewer to simple, high-contrast subjects.
Integration and Differentiability
A key advantage of ATS is its "plug-and-play" nature. Because it utilizes existing attention weights, it introduces zero additional parameters to the backbone architecture. Furthermore, the sampling mechanism is differentiable, allowing for end-to-end fine-tuning to optimize the selection process.
Experimental Evaluation
The efficacy of ATS was evaluated on both image classification and video action recognition tasks using the following datasets:
- ImageNet-1K: 1.3 million images across 1,000 classes.
- Kinetics-400 and Kinetics-600: Large-scale video datasets for human action recognition.
The module was integrated into several prominent architectures, including DeiT, CvT, PS-ViT, XViT, and TimeSformer.
Key Results
ATS demonstrates a superior trade-off between computational efficiency and model accuracy compared to existing methods like DynamicViT and EViT:
- Efficiency Gains: On ImageNet, integrating ATS into a DeiT-S model reduced GFLOPs by 37% while maintaining a Top-1 accuracy of 79.7% (a negligible 0.1% drop from the baseline).
- Video Performance: For video tasks, which are significantly more computationally demanding, ATS achieved a 39% reduction in GFLOPs for the XViT model with only a 0.2% accuracy loss on Kinetics-400.
- Hardware Throughput: Real-world testing on an NVIDIA RTX 6000 GPU showed that the throughput of DeiT-S increased from 1010 to 1403 images per second after adding the ATS module.
Discussion and Limitations
While ATS significantly reduces theoretical computational complexity (GFLOPs), practical implementation faces certain hurdles. The sampling operation itself introduces a minor I/O overhead, accounting for approximately 1.5% of total computation. Additionally, because ATS results in a variable number of tokens per image, standard batch processing in deep learning frameworks becomes complex. Current solutions involve token rearrangement or padding, though the authors suggest that specialized hardware kernels could further capitalize on these adaptive savings. Future work may also explore applying this adaptive sampling logic to other domains, such as audio processing.
Summary updated