Abstract
Vision Transformers (ViTs) have achieved impressive performance over various computer vision tasks. However, modelling global correlations with multi-head self-attention (MSA) layers leads to two widely recognized issues: the massive computational resource consumption and the lack of intrinsic inductive bias for modelling local visual patterns. To solve both issues, we devise a simple yet effective method named Single-Path Vision Transformer pruning (SPViT), to efficiently and automatically compress the pre-trained ViTs into compact models with proper locality added. Specifically, we first propose a novel weight-sharing scheme between MSA and convolutional operations, delivering a single-path space to encode all candidate operations. In this way, we cast the operation search problem as finding which subset of parameters to use in each MSA layer, which significantly reduces the computational cost and optimization difficulty, and the convolution kernels can be well initialized using pre-trained MSA parameters. Relying on the single-path space, we further introduce learnable binary gates to encode the operation choices, which are jointly optimized with network parameters to automatically determine the configuration of each layer. We conduct extensive experiments on two representative ViTs showing that our SPViT achieves a new SOTA for pruning on ImageNet-1k. For example, our SPViT can trim 52.0% FLOPs for DeiT-B and get an impressive 0.6% top-1 accuracy gain simultaneously.
Introduction
Vision Transformers (ViTs) have revolutionized computer vision, yet they face significant deployment challenges. The primary bottleneck is the Multi-Head Self-Attention (MSA) layer, which exhibits quadratic complexity relative to input tokens. Furthermore, unlike Convolutional Neural Networks (CNNs), ViTs lack an inherent "inductive bias" for local patterns—edges and textures—which are essential for effective early-stage visual processing.
Existing solutions often involve manual architectural adjustments or expensive multi-path Neural Architecture Search (NAS). SPViT (Single-Path Vision Transformer pruning) addresses these issues by automatically transforming computationally heavy MSA layers into efficient convolutional layers within a unified, single-path framework.
Methodology
SPViT simplifies the architectural search through three core innovations:
- Weight-Sharing between MSA and Conv: The framework leverages the mathematical insight that a bottleneck convolutional layer can be represented as a subset of MSA parameters. This allows convolution kernels to be directly initialized from pre-trained MSA weights, ensuring a strong starting point for optimization.
- Single-Path Search Space: Traditional NAS often uses a "multi-path" supernet where parallel branches are trained simultaneously, which is computationally prohibitive. SPViT uses a single path where learnable binary gates determine the operation for each layer: full MSA, a specific bottleneck convolution (e.g., 3x3 or 5x5), or a skip-connection.
- Fine-grained FFN Pruning: Beyond attention layers, learnable gates are applied to the Feed-Forward Network (FFN) hidden dimensions, allowing the model to automatically optimize the expansion ratio for every layer.
Experimental Results
Evaluated on ImageNet-1k using DeiT and Swin Transformer architectures, SPViT demonstrates state-of-the-art performance. A key insight from the search process is that the model consistently prunes early (shallow) layers into convolutional operations while retaining MSA in deeper layers. This validates the intuition that early layers benefit from local inductive bias, while later layers require global context.
As shown in the results table, SPViT often achieves an "accuracy gain" through pruning:
- DeiT-B: Achieved a 52.0% reduction in FLOPs with a 0.6% top-1 accuracy improvement (82.4% vs 81.8%).
- DeiT-S: Reduced FLOPs by 28.3% while gaining 0.4% accuracy.
- Swin-S: Maintained a SOTA accuracy of 83.0% while reducing FLOPs by approximately 30%.
By utilizing a single-path approach, the search cost was reduced by over 50% compared to traditional multi-path methods, making the optimization process significantly more stable and efficient.
Conclusion
SPViT provides a robust framework for compressing ViTs while simultaneously improving their inductive bias through localized convolutional layers. While the current method prunes at a coarse layer-wise granularity, future work will explore head-level pruning to enable hybrid layers that perform both convolution and attention. This research paves the way for more efficient, high-performance vision models suitable for resource-constrained environments.
Summary updated