Abstract: Vision Transformers (ViTs) are powerful but computationally intensive, hindering their deployment on resource-constrained devices. This paper introduces Patch Slimming, a novel top-down pruning strategy that identifies and removes redundant image patches. By starting from the final layer and working backward, the method preserves patches that contribute most to the final classification. Experimental results on ImageNet demonstrate that Patch Slimming can reduce computational costs (FLOPs) by over 45% with negligible impact on accuracy, outperforming existing state-of-the-art pruning techniques.
Introduction
Vision Transformers have revolutionized computer vision by treating images as sequences of patches. However, the quadratic complexity of self-attention relative to the number of patches leads to significant computational overhead. While channel pruning is effective for Convolutional Neural Networks (CNNs), ViTs require a different approach that accounts for their unique spatial structure. This paper addresses the "huge computational cost" of ViTs by proposing a method to prune redundant patches without compromising the model's representational power.
Methodology: Top-Down Patch Slimming
The authors propose a top-down paradigm for patch pruning, contrasting with traditional bottom-up approaches.
The Top-Down Paradigm
In classification tasks, the "class token" in the final layer is the ultimate representation used for prediction. Patch Slimming identifies which patches in the preceding layer ($l$) contribute most to the class token in layer $l+1$. By working backward from the output to the input, the method ensures that any patch retained in a deep layer has its "ancestors" preserved in earlier layers, maintaining a coherent flow of information.
Impact Estimation and Selection
The core of the framework is a mathematical impact estimation. The authors derive a significance score for each patch, approximating its influence on the reconstruction error of the final output. Patches with low significance scores are iteratively discarded. Following selection, a rapid fine-tuning step is performed on the specific layer to recover performance before moving to the next layer.
Key Insights
Deep Redundancy and the Pyramid Effect
A key motivation for Patch Slimming is the observation that patch similarity increases significantly in deeper layers of the network. As shown in the empirical analysis, the average cosine similarity between patches often exceeds 0.8 in the final layers, indicating that many patches convey redundant information.
The pruning process naturally results in a "pyramid" architecture. Shallow layers retain a high density of patches to capture fine-grained details, while deep layers become highly sparse, focusing only on the most discriminative features of the object of interest.
Class Token Anchoring
By anchoring the pruning logic to the class token, the model effectively learns to "zoom in" on relevant objects while ignoring background noise. This spatial one-to-one correspondence across layers makes patch pruning in ViTs fundamentally different and more intuitive than filter pruning in CNNs.
Experimental Results
The method was evaluated on ImageNet using various architectures, including DeiT, T2T-ViT, and LV-ViT.
- Efficiency Gains: For ViT-Tiny, Patch Slimming reduced FLOPs by 46.2% with only a 0.2% drop in Top-1 accuracy. Throughput increased significantly from 2536 to 3576 images per second.
- Dynamic Pruning: A dynamic variant (DPS-ViT) using a small predictor sub-network achieved a 53.8% FLOP reduction with a mere 0.1% accuracy loss.
- Comparative Performance: Patch Slimming consistently outperformed uniform pruning and other state-of-the-art methods like SCOP and PoWER. For instance, on DeiT-S, the proposed method achieved 79.4% accuracy compared to 77.2% for uniform pruning at similar compression levels.
Conclusion
Patch Slimming provides a highly effective way to compress Vision Transformers by exploiting spatial redundancy. By adopting a top-down approach centered on the final classification token, it achieves substantial computational savings while maintaining high accuracy. Future work may explore extending this logic to dense prediction tasks like segmentation and combining it with weight quantization for further optimization.
Summary updated