SparseViT: Revisiting Activation Sparsity for Efficient High-Resolution Vision Transformer

Xuanyao Chen, Zhijian Liu, Haotian Tang, Li Yi, Hang Zhao, Song HanCVPR 2023

Abstract

High-resolution images enable neural networks to learn richer visual representations. However, this improved performance comes at the cost of growing computational complexity, hindering their usage in latency-sensitive applications. As not all pixels are equal, skipping computations for less-important regions offers a simple and effective measure to reduce the computation. This, however, is hard to be translated into actual speedup for CNNs since it breaks the regularity of the dense convolution workload. In this paper, we introduce SparseViT that revisits activation sparsity for recent window-based vision transformers (ViTs). As window attentions are naturally batched over blocks, actual speedup with window activation pruning becomes possible: i.e., ~50% latency reduction with 60% sparsity. Different layers should be assigned with different pruning ratios due to their diverse sensitivities and computational costs. We introduce sparsity-aware adaptation and apply the evolutionary search to efficiently find the optimal layerwise sparsity configuration within the vast search space. SparseViT achieves speedups of 1.5x, 1.4x, and 1.3x compared to its dense counterpart in monocular 3D object detection, 2D instance segmentation, and 2D semantic segmentation, respectively, with negligible to no loss of accuracy.

Introduction

High-resolution visual representations are essential for modern computer vision tasks, particularly those requiring fine-grained spatial awareness like 3D object detection and semantic segmentation. However, the computational cost of processing high-resolution inputs is a significant bottleneck for real-time applications. While activation pruning—the practice of skipping computations for less informative regions—is a theoretically sound solution, it has historically struggled to provide actual wall-clock speedups on modern hardware. In traditional Convolutional Neural Networks (CNNs), pruning creates irregular, "holey" data structures that conflict with the dense execution patterns of GPUs.

SparseViT addresses this challenge by reimagining activation sparsity for window-based Vision Transformers (ViTs). By leveraging the naturally batched structure of window attention, SparseViT translates theoretical sparsity into tangible latency reductions, achieving significant speedups across multiple vision benchmarks.

The SparseViT Framework

The core innovation of SparseViT lies in its ability to maintain hardware efficiency while aggressively pruning redundant information. The framework is built upon three technical pillars:

1. Window-Wise Execution

Unlike pixel-level pruning, which is too fine-grained for efficient GPU utilization, SparseViT operates at the granularity of $7 \times 7$ windows. By modifying the transformer architecture so that every operation is performed on local windows, the pruning process becomes a simple batch reduction. The GPU effectively processes a smaller batch of windows, a task for which it is highly optimized. This "Goldilocks" granularity is large enough to maintain hardware regularity but small enough to accurately isolate important visual features.

2. Sparsity-Aware Adaptation

Training a model to be robust to missing data is a non-trivial task. SparseViT utilizes a sparsity-aware adaptation strategy where the model is trained by randomly sampling different sparsity configurations. This teaches the network to maintain high performance even when a significant portion of its input windows are pruned. To determine which windows to keep during inference, the model uses a simple yet effective L2 magnitude score of the activations; windows with low energy are deemed background and discarded.

3. Evolutionary Search for Mixed Sparsity

Not all layers in a ViT contribute equally to the final output, nor do they share the same computational profile. Early layers often handle massive feature maps, while later layers may be more sensitive to information loss. SparseViT employs an evolutionary search algorithm to automatically navigate the vast search space of layer-wise sparsity. This allows the framework to find the optimal configuration for a specific latency target, typically resulting in more aggressive pruning in the early stages of the network.

Experimental Results

The researchers evaluated SparseViT across several demanding benchmarks, comparing it against dense baselines and traditional scaling methods (like reducing image resolution or model width).

  • Monocular 3D Object Detection (nuScenes): SparseViT achieved a 1.5x speedup with no loss in the NuScenes Detection Score (NDS).
  • 2D Instance Segmentation (COCO): The framework delivered a 1.4x speedup over the dense Swin-T baseline.
  • 2D Semantic Segmentation (Cityscapes): SparseViT provided a 1.3x speedup while maintaining high accuracy.

Across these tasks, a consistent trend emerged: it is more effective to process a high-resolution image with 60% sparsity than to process a downsampled, low-resolution image at 100% density. The sparse high-resolution approach preserves the sharp edges and small-scale details that are often lost during downsampling.

Discussion and Insights

SparseViT demonstrates that non-uniform sparsity is essential for maximizing efficiency. The evolutionary search revealed that the model prefers to prune heavily in the initial stages, where raw pixel redundancy is highest. Furthermore, the success of window-based pruning suggests that the "window" is the ideal unit of computation for balancing biological-inspired attention with modern hardware constraints.

While SparseViT represents a major step forward, future work may explore dynamic, per-block scoring mechanisms and further kernel optimizations to enhance the gather/scatter operations required for window management. Currently, the framework is optimized for window-based ViTs, and extending these hardware-friendly techniques to global ViT architectures remains an open area of research.

Conclusion

SparseViT provides a practical path toward efficient high-resolution vision. By aligning the algorithmic benefits of activation sparsity with the structural requirements of GPU hardware, it achieves up to 1.5x real-world speedups. This framework proves that we do not need to sacrifice resolution for speed, provided we are smart about where we spend our computational budget.

Summary updated

BibTeX
@inproceedings{chen2023sparsevit,
  author = {Xuanyao Chen and Zhijian Liu and Haotian Tang and Li Yi and Hang Zhao and Song Han},
  title = {{SparseViT: Revisiting Activation Sparsity for Efficient High-Resolution Vision Transformer}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  url = {https://openreview.net/forum?id=C61vDRc6dK},
}
Figure