Unified Visual Transformer Compression

Shixing Yu, Tianlong Chen, Jiayi Shen, Huan Yuan, Jianchao Tan, Sen Yang, Ji Liu, Zhangyang Wang

Abstract

Unified Visual Transformer Compression (UVC) is a principled framework that slashes the computational cost of Vision Transformers (ViTs) by jointly optimizing three strategies: structural pruning, layer skipping, and knowledge distillation. By treating compression as a single, budget-constrained optimization problem, UVC can reduce a model's FLOPs by 50% with negligible impact on accuracy, significantly outperforming methods that apply these techniques in isolation.

Introduction

Vision Transformers (ViTs) have revolutionized computer vision, but they come with a heavy "computational tax." Unlike Convolutional Neural Networks (CNNs), which benefit from decades of compression research, ViTs are relatively new and notoriously resource-intensive due to the quadratic complexity of their self-attention modules. While researchers have tried to compress ViTs using techniques like pruning or distillation, most existing work is ad-hoc, focusing on just one or two methods at a time. UVC addresses this by integrating multiple compression techniques into a single, end-to-end framework that automatically finds the best architecture under a specific hardware budget.

The UVC Framework

The UVC framework assembles three distinct "levers" for compression:

  1. Structural Pruning: Instead of removing random individual weights, UVC prunes at the "group" level, targeting the number of attention heads, dimensions within those heads, and the hidden layers of the MLP modules.
  2. Layer Skipping (Skip Manipulation): UVC learns which entire blocks can be skipped during inference. To make this discrete decision differentiable during training, the framework utilizes the Gumbel-Softmax trick.
  3. Knowledge Distillation (KD): To ensure the compressed "student" model maintains performance, a full-sized "teacher" model provides soft labels to guide the training process.
The UVC framework architecture, illustrating the joint optimization of pruning, skip manipulation, and knowledge distillation.

Rather than applying these techniques sequentially, UVC formulates them as a constrained optimization problem. Using a primal-dual algorithm, the framework solves for model weights, pruning masks, and skip configurations simultaneously. This allows the model to trade off between different architectural components to stay under a specific FLOPs budget.

Experimental Evaluation

The researchers evaluated UVC on the ImageNet dataset using several popular ViT backbones, including DeiT (Tiny, Small, and Base) and T2T-ViT.

Performance comparison of UVC against baseline and state-of-the-art methods across various ViT configurations.

UVC consistently set new state-of-the-art benchmarks for ViT efficiency:

  • DeiT-Tiny: Trimmed to 50% of its original FLOPs with only a 0.3% to 0.9% drop in accuracy.
  • DeiT-Small: Achieved 79.44% accuracy while using only 57.6% of the original FLOPs, outperforming competitors like SViTE and PatchSlimming.
  • DeiT-Base: Compressed to 45.5% of its original size while maintaining 80.57% accuracy.

Key Insights

  • Joint Optimization: Optimizing pruning and skipping together is far superior to sequential application. Pruning first can stabilize the architecture, making subsequent layer skipping more effective.
  • Feature Collapse: In deep ViTs, attention maps often become redundant across layers. This "feature collapse" justifies layer skipping, as some layers do not add new information.
  • Architecture-Specific Behavior: For smaller models like DeiT-Tiny, UVC drops attention heads evenly. In larger models like DeiT-Base, it prefers dropping heads in early layers, suggesting early-stage global attention may be more redundant than previously thought.

Conclusion

UVC moves ViT compression from trial-and-error to a mathematically grounded, unified process. While highly effective, future work could expand the framework to include input patch size optimization and weight quantization. UVC brings powerful ViT models closer to efficient deployment on mobile and edge devices.

Summary updated

BibTeX
@inproceedings{yu2022unified,
  author = {Shixing Yu and Tianlong Chen and Jiayi Shen and Huan Yuan and Jianchao Tan and Sen Yang and Ji Liu and Zhangyang Wang},
  title = {{Unified Visual Transformer Compression}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=9jsZiUgkCZP},
}
Figure