NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Width & Depth Pruning for Vision Transformers

Fang Yu, Kun Huang, Meng Wang, Yuan Cheng, Wei Chu, Li Cui

Introduction

Vision Transformers (ViTs) have fundamentally changed the landscape of computer vision, delivering state-of-the-art performance across various tasks. However, their deployment is often hindered by a significant "computational tax"—massive parameter counts and high FLOP (Floating Point Operations) requirements that make them unsuitable for resource-constrained edge devices.

While previous research has explored model pruning, most efforts focus exclusively on width pruning (reducing attention heads or weight matrix dimensions). This paper introduces WDPruning, a novel framework that simultaneously prunes both the width and depth (entire transformer blocks) of ViTs. By optimizing both dimensions, WDPruning achieves substantial computational savings while maintaining, or in some cases improving, model accuracy.

Methodology

WDPruning employs a dual-pronged strategy to streamline the transformer architecture without sacrificing representational power.

Width Pruning via Learnable Saliency

Instead of relying on heuristic-based neuron removal, WDPruning treats pruning as a learning problem. The framework assigns a learnable "saliency score" to every weight and learns a per-layer threshold using a sigmoid-based parameterization. To ensure the model adheres to specific resource constraints (e.g., a 30% reduction in parameters), the authors utilize the Augmented Lagrangian method. This approach dynamically adjusts pruning pressure during the training process, allowing the model to converge on an optimal sparse structure.

Figure 1: Overview of the masked operation and width pruning mechanisms for linear matrices and attention heads.

Depth Pruning via Plug-in Classifiers

Depth pruning is often more hardware-friendly than width pruning because removing entire blocks reduces synchronization overhead and memory fragmentation. WDPruning implements depth pruning by attaching auxiliary, shallow "classifier heads" to intermediate transformer blocks. During training, the model learns to perform classification at these early exit points. Post-training, the architecture can be truncated after the best-performing intermediate classifier, effectively turning a deep model into a shallower, faster version without requiring extensive fine-tuning.

Figure 4: Depth pruning strategy using intermediate plug-in classifiers to identify optimal truncation points.

Experimental Results

The researchers evaluated WDPruning on standard benchmarks including ImageNet (ILSVRC-12), CIFAR-10, and Market-1501. The results demonstrate that the framework produces highly efficient, structured models:

  • DeiT-Base: The framework achieved a 22.3% reduction in FLOPs and a 19.9% reduction in parameters. Remarkably, this was accompanied by a 0.14% increase in Top-1 accuracy, suggesting that pruning acts as a beneficial regularizer for over-parameterized ViTs.
  • Swin-Small: WDPruning reduced parameters by 30.6%, leading to a 15.3% increase in GPU throughput with a minimal 1.2% drop in accuracy.
  • Hardware Efficiency: Real-world testing on an AMD EPYC CPU showed a latency drop for DeiT-Base from 783ms to 590ms, a ~25% improvement.

Key Insights

  1. Non-Uniform Sparsity: The learnable thresholding revealed that different layers require different levels of pruning. Manual, uniform pruning across layers resulted in a significant accuracy loss (over 4%) compared to the learnable approach.
  2. Orthogonality: WDPruning is compatible with other compression techniques, such as patch pruning (removing unimportant tokens), offering a path toward even more extreme model compression.
  3. Generalization: Pruned backbones maintained high performance when transferred to downstream tasks like person re-identification (TransReID), demonstrating the robustness of the learned features.

Conclusion and Future Work

WDPruning provides a robust, hardware-friendly framework for slimming Vision Transformers. By addressing both width and depth, it overcomes the limitations of traditional pruning methods. Future research directions include automating the placement of plug-in classifiers and extending the framework to Video Transformers, where the temporal dimension adds further computational complexity.

Summary updated

BibTeX
@inproceedings{yu2022width,
  author = {Fang Yu and Kun Huang and Meng Wang and Yuan Cheng and Wei Chu and Li Cui},
  title = {{Width \& Depth Pruning for Vision Transformers}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i3.20222},
}
Figure