Introduction
Vision Transformers (ViTs) have fundamentally changed the landscape of computer vision, offering superior performance across a wide range of tasks. However, their widespread adoption is hindered by the "attention tax"—the quadratic computational and memory complexity of the self-attention mechanism. As the number of input image patches (tokens) increases, the resource requirements grow exponentially.
Existing efficiency techniques often rely on "token pruning" or "merging," which discard or combine less informative patches as they progress through the network. While effective for global tasks like image classification, these methods are unsuitable for "dense prediction" tasks such as depth estimation or semantic segmentation. In these scenarios, maintaining a feature for every pixel is critical; once a token is pruned, its spatial information is lost. ToSA (Token Selective Attention) addresses this by providing a mechanism that reduces computation without discarding data.
The ToSA Framework
The core innovation of ToSA is the Token Selector module, which is strategically placed between consecutive transformer layers. Instead of deleting tokens, ToSA identifies which tokens require the full, expensive self-attention operation and which can simply "skip" it while remaining in the feature pipeline.
The Token Selection Process
- Predictive Modeling: The Token Selector analyzes the un-normalized attention maps ($QK^T$) from the current layer to predict the attention patterns of the subsequent layer. This approach leverages the inherent redundancy in how ViTs process information across layers.
- Importance Scoring: Based on these predicted maps, the system calculates an importance score for every token. A user-defined ratio (e.g., 80%) is used to select the "Top-K" most salient tokens.
- Selective Attention: Only the Top-K tokens participate in the self-attention mechanism of the next layer (the ToSA Transformer Layer). The remaining "skip tokens" bypass the attention operation entirely, significantly reducing FLOPs.
- Feature Re-integration: Following the attention step, the attended tokens and the skipped tokens are concatenated back together. This ensures that the network maintains a complete set of features for every original image patch throughout the entire backbone, preserving the density required for spatial tasks.
The Token Selector is trained using a KL-Divergence loss, allowing it to learn and mimic the attention distributions of a full-scale, non-optimized pretrained model.
Experimental Evaluation
The researchers evaluated ToSA across three major benchmarks to test both classification and dense prediction capabilities: ImageNet-1K (classification), NYU Depth V2 (indoor depth estimation), and KITTI (outdoor depth estimation).
Key Results
- Efficiency and Accuracy: When applied to the DeiT-Tiny architecture, ToSA achieved a 25.8% reduction in FLOPs. Remarkably, this efficiency gain was accompanied by an accuracy boost, with Top-1 accuracy on ImageNet-1K increasing from 72.2% to 73.9%. This suggests that selective attention may act as a form of regularization, forcing the model to focus on salient features and ignore noise.
- Dense Prediction Performance: On the NYU Depth V2 and KITTI benchmarks, ToSA-equipped models maintained depth accuracy nearly identical to full-attention baselines while operating with significantly fewer active tokens in the attention layers.
Visualizations confirm that the Token Selector intelligently prioritizes the primary subject of an image (e.g., a cat) for attention in every layer, while selectively alternating which background patches are processed at different stages of the network.
Discussion and Future Work
ToSA demonstrates that computational efficiency in ViTs does not have to come at the cost of spatial information. By allowing tokens to skip attention rather than exiting the model entirely, ToSA remains the first efficiency-focused ViT technique fully compatible with dense prediction tasks.
Despite these promising results, several avenues for future research remain. The current implementation uses fixed selection ratios; a dynamic approach that adjusts the number of skip tokens based on image complexity could further optimize performance. Additionally, while FLOP reductions are significant, the real-world "wall-clock" speedup on hardware like mobile GPUs will depend on the optimized implementation of the concatenation and selection operations. Future work will also explore scaling ToSA to larger architectures beyond the DeiT-Tiny backbone used in this initial study.
Summary updated