Abstract
Vision Transformers (ViTs) have achieved state-of-the-art results in computer vision but are computationally expensive due to their massive parameter counts and high FLOP requirements. This paper introduces Visual Transformer Pruning (VTP), a structured pruning method designed to reduce redundancy in ViT linear projections. By employing learnable importance scores and $L_1$ regularization, VTP identifies and removes less critical feature dimensions. Experimental results on ImageNet-1K demonstrate that VTP can reduce parameters and FLOPs by over 40% with negligible accuracy degradation, making ViTs more viable for deployment on resource-constrained edge devices.
Introduction
While Vision Transformers have set new benchmarks in computer vision, they are notorious "resource hogs." Their significant memory footprint and high computational demands make them difficult to deploy on edge devices like smartphones or robotics. While pruning techniques are well-established for Convolutional Neural Networks (CNNs), they have been less explored for the unique architecture of transformers. This paper specifically targets the redundancy within the linear projections found in the Multi-Head Self-Attention (MHSA) and Multi-Layer Perceptron (MLP) blocks of the transformer.
Methodology
The authors propose a three-stage pipeline to slim the transformer architecture by identifying and removing redundant feature dimensions:
- Training with Sparsity Regularization: A "soft gate"—a vector of learnable importance scores—is introduced to multiply the features in each layer. During training, $L_1$ regularization is applied to these scores, forcing the network to identify critical dimensions while pushing redundant ones toward zero.
- Dimension Pruning: Importance scores are ranked, and dimensions falling below a threshold based on the target pruning rate are "hard pruned" (removed entirely), resulting in a compact, discrete architecture.
- Fine-tuning: The resulting slimmed model is fine-tuned on the original dataset to recover any performance lost during pruning.
Unlike weight-wise pruning, which creates irregular sparse matrices that are difficult to accelerate, VTP prunes entire dimensions. This results in smaller, dense matrices that provide immediate speedups on standard hardware. The "important" dimensions emerge automatically from the data during the training process rather than being chosen by a manual heuristic.
Experimental Setup
The method was evaluated on two primary benchmarks:
- ImageNet-1K: The standard large-scale image classification dataset used for main performance comparisons.
- ImageNet-100: A smaller subset used for ablation studies to test hyperparameters like sparse penalty and pruning rates.
Key Results
The results demonstrate that Vision Transformers contain significant redundancy. On ImageNet-1K, using DeiT-Base as a baseline, VTP achieved the following:
- 20% Pruning: Reduced parameters from 86.4M to 67.3M and FLOPs from 17.6B to 13.8B, with accuracy dropping only 0.5% (from 81.8% to 81.3%).
- 40% Pruning: Reduced parameters to 48.0M (~44% reduction) and FLOPs to 10.0B (~43% reduction) while maintaining a high accuracy of 80.7%.
As shown in the comparison table, pruned VTP models outperformed standard CNNs like ResNet-152 in both accuracy and efficiency. For instance, a 40% pruned VTP model achieved 80.7% accuracy with 10B FLOPs, whereas a RegNetY-16GF achieved 80.4% with 15.9B FLOPs.
Discussion and Future Work
Currently, VTP focuses on pruning dimensions within linear layers. It does not yet address reducing the number of attention heads or the total number of layers, which are also significant sources of overhead. Additionally, the three-stage process (sparsity training, pruning, and fine-tuning) is more computationally intensive than "one-shot" pruning methods. Future research may combine dimension-wise pruning with head and layer pruning to achieve even higher compression ratios.
Summary updated