HeatViT: Hardware-Efficient Adaptive Token Pruning for Vision Transformers

Peiyan Dong, Mengshu Sun, Alec Lu, Yanyue Xie, Kenneth Liu, Zhenglun Kong, Xin Meng, Zhengang Li, Xue Lin, Zhenman Fang, Yanzhi Wang

TL;DR

HeatViT is a hardware-software co-design framework that brings high-performance Vision Transformers (ViTs) to resource-constrained edge FPGAs. By combining an image-adaptive token pruning strategy with hardware-friendly 8-bit quantization and polynomial approximations of nonlinear functions, it achieves up to a 4.89× speedup over baseline accelerators with negligible accuracy loss.

What Problem Does This Paper Address?

Vision Transformers have set new benchmarks in computer vision, but they are notoriously "heavy." Their primary bottleneck is the self-attention mechanism, which has a quadratic computational complexity relative to the number of input tokens (image patches).

While researchers have tried to solve this using token pruning (removing less important image patches), existing methods fall into two traps:

  1. Static Pruning: They remove a fixed percentage of tokens regardless of the image content, which is inefficient for complex images and overkill for simple ones.
  2. Hardware Unfriendliness: Many "adaptive" algorithms create sparse data structures or require complex control logic (like argsort) that FPGAs struggle to execute efficiently. This often leads to theoretical "FLOP savings" that don't actually translate to real-world speedups.

Methods

HeatViT introduces a three-pronged approach to make ViTs efficient on hardware:

  • Multi-Head Token Selector & Packaging: Instead of a simple global score, HeatViT uses an attention-based selector that considers features from multiple heads to identify "non-informative" tokens. Crucially, instead of just deleting these tokens, it averages them into a single "package token." This preserves global context and allows the model to "recover" if the selector makes a mistake.
  • Hardware-Efficient Design: The token selector is built using linear layers to reuse the existing General Matrix Multiply (GEMM) hardware engine already present for the backbone ViT. Furthermore, the pruned tokens are concatenated into a dense matrix, avoiding the overhead of sparse matrix computations.
  • Polynomial Approximations: Nonlinear functions like GELU and Softmax are expensive on FPGAs. HeatViT replaces them with 2nd-order polynomial approximations. The authors discovered that these approximations actually have a "regularization effect" that helps mitigate errors introduced by 8-bit fixed-point quantization.
  • Latency-Aware Training: The authors use a multi-stage training strategy that inserts selectors from the back of the model toward the front (since early layers are more sensitive to accuracy loss) and optimizes the pruning rate based on actual hardware latency look-up tables.

Datasets

The framework was evaluated on the ImageNet-1K dataset, the standard benchmark for image classification. The authors applied HeatViT to several widely used architectures:

  • DeiT (Tiny, Small, and Base variants)
  • LV-ViT (Small and Medium variants)

Key Insights and Ideas

  • Information Redundancy is Image-Specific: A picture of a single bird on a clear sky can be pruned much more aggressively than a crowded street scene. HeatViT’s adaptive approach exploits this "data-level sparsity."
  • Dense is Better than Sparse: On hardware, processing a smaller dense matrix is almost always faster than processing a larger sparse one. By reorganizing pruned tokens into a dense format, HeatViT ensures the hardware stays at high utilization.
  • The "Safety Net" of Packaging: By condensing discarded tokens into one "package" rather than deleting them, the model maintains a "summary" of the background, which stabilizes training and improves final accuracy.

Key Results

  • Superior Trade-offs: Compared to SOTA pruning methods like DynamicViT or IA-RED, HeatViT achieves 0.7%–8.9% higher accuracy at similar computation costs.
  • Massive Speedups: On a Xilinx ZCU102 FPGA, HeatViT achieved 3.46× to 4.89× speedup compared to a standard 16-bit baseline without pruning.
  • Energy Efficiency: The FPGA implementation proved to be 3.0× to 4.7× more energy-efficient than an optimized implementation on an NVIDIA Jetson TX2 GPU.
  • Minimal Overhead: The additional logic required for the token selectors only increased hardware resource utilization (DSPs and LUTs) by roughly 5%–11%.

Limitations and Future Work

  • Training Complexity: The multi-stage training and fine-tuning process is more involved than standard training, requiring careful balancing of accuracy and latency targets.
  • Task Scope: This paper focuses on image classification. Future work could explore how these adaptive pruning techniques translate to dense prediction tasks like object detection or semantic segmentation, where maintaining spatial resolution in specific areas is more critical.
  • Quantization Sensitivity: While 8-bit quantization worked well here, the authors noted a slight accuracy drop (1.2%) on the smallest model (DeiT-T), suggesting that extremely small models may require more sophisticated quantization-aware training.

Summary updated

BibTeX
@inproceedings{dong2023heatvit,
  author = {Peiyan Dong and Mengshu Sun and Alec Lu and Yanyue Xie and Kenneth Liu and Zhenglun Kong and Xin Meng and Zhengang Li and Xue Lin and Zhenman Fang and Yanzhi Wang},
  title = {{HeatViT: Hardware-Efficient Adaptive Token Pruning for Vision Transformers}},
  booktitle = {HPCA},
  year = {2023},
  doi = {10.1109/hpca56546.2023.10071047},
}
Figure