Abstract
Deployment of Transformer models on edge devices is becoming increasingly challenging due to the exponentially growing inference cost that scales quadratically with the number of tokens in the input sequence. Token pruning is an emerging solution to address this challenge due to its ease of deployment on various Transformer backbones. However, most token pruning methods require computationally expensive fine-tuning, which is undesirable in many edge deployment cases. In this work, we propose Zero-TPrune, the first zero-shot method that considers both the importance and similarity of tokens in performing token pruning. It leverages the attention graph of pre-trained Transformer models to produce an importance distribution for tokens via our proposed Weighted Page Rank (WPR) algorithm. This distribution further guides token partitioning for efficient similarity-based pruning. Due to the elimination of the fine-tuning overhead, Zero-TPrune can prune large models at negligible computational cost, switch between different pruning configurations at no computational cost, and perform hyperparameter tuning efficiently. We evaluate the performance of Zero-TPrune on vision tasks by applying it to various vision Transformer backbones and testing them on ImageNet. Without any fine-tuning, Zero-TPrune reduces the FLOPs cost of DeiT-S by 34.7% and improves its throughput by 45.3% with only 0.4% accuracy loss. Compared with state-of-the-art pruning methods that require fine-tuning, Zero-TPrune not only eliminates the need for fine-tuning after pruning but also does so with only 0.1% accuracy loss. Compared with state-of-the-art fine-tuning-free pruning methods, Zero-TPrune reduces accuracy loss by up to 49% with similar FLOPs budgets.
Introduction
Transformers have set new benchmarks in computer vision, yet their computational demands remain a significant hurdle for edge deployment. The primary bottleneck is the self-attention mechanism, where computational cost scales quadratically with the number of input tokens (image patches). While Token Pruning—the process of identifying and discarding less critical patches—offers a solution, existing state-of-the-art methods typically necessitate extensive fine-tuning. This requirement not only consumes hundreds of GPU hours but also limits flexibility; changing pruning configurations for different hardware budgets often requires training entirely new model variants.
Methodology: Zero-Shot Token Pruning
Zero-TPrune addresses these limitations by introducing a "zero-shot" framework that requires no re-training. The method operates by inserting lightweight pruning layers into pre-trained models, allowing for instantaneous switching between different computational budgets.
The framework consists of two primary stages that leverage the inherent knowledge within the pre-trained Transformer:
1. I-stage: Importance-based Pruning via Attention Graphs
The core innovation of Zero-TPrune is treating the Transformer's attention matrix as an adjacency matrix of a directed complete graph. By applying a custom Weighted Page Rank (WPR) algorithm, the system identifies "influential" tokens—those that other tokens frequently attend to.
To refine this signal, the authors employ:
- Emphasizing Informative Region (EIR): Aggregates importance scores across multiple attention heads using a root-mean-square approach.
- Variance-based Head Filter (VHF): Automatically filters out "noisy" attention heads that might provide misleading importance signals.
2. S-stage: Similarity-based Pruning
Recognizing that high importance does not preclude redundancy (e.g., multiple identical patches of a background), the S-stage uses cosine similarity on "Key" vectors. It identifies clusters of similar tokens and prunes redundant ones, ensuring a diverse and efficient set of representations. The authors utilize a specific I'-S-I sequence (pre-ranking, similarity pruning, then final importance pruning) to ensure that dominant background groups do not overshadow critical, smaller objects.
Experimental Results
Zero-TPrune was primarily evaluated on ImageNet-1K using various Vision Transformer (ViT) backbones, with further validation on several downstream datasets like Flowers-102 and CUB-200-2011.
- Performance Gains: On the DeiT-S backbone, Zero-TPrune achieved a 34.7% reduction in FLOPs and a 45.3% increase in throughput with a minimal 0.4% accuracy drop.
- Competitive Edge: Zero-TPrune outperformed other fine-tuning-free methods (e.g., ToMe, ATS) by reducing accuracy loss by up to 49% at equivalent computational budgets.
- Training-Free Parity: Remarkably, the method performs within 0.1% accuracy of state-of-the-art methods that require over 150 hours of GPU fine-tuning, demonstrating that intelligent pruning can bypass the need for expensive re-training.
Conclusion and Future Directions
Zero-TPrune demonstrates that pre-trained Transformers are robust enough to handle token pruning without fine-tuning if the pruning process intelligently considers both importance and redundancy. This "plug-and-play" capability is ideal for edge devices that must dynamically adjust power consumption. Future work may extend this graph-based approach to other domains such as semantic segmentation or generative modeling, and further optimize for specific hardware architectures.
Summary updated