Balanced Sparsity for Efficient DNN Inference on GPU

Zhuliang Yao, Shijie Cao, Wencong Xiao, Chen Zhang, Lanshun Nie

Introduction

Deep Neural Networks (DNNs) are often significantly over-parameterized, with up to 98% of weights being redundant. While pruning these weights can reduce model size, translating these savings into actual inference speedups on general-purpose hardware like GPUs remains a significant challenge. Researchers typically face a "Sparsity-Efficiency Dilemma": Unstructured (Fine-grained) Pruning maintains high accuracy but creates irregular matrices that GPUs struggle to process efficiently. Conversely, Coarse-grained Pruning (e.g., block or filter pruning) is hardware-friendly but often severely degrades model accuracy.

This paper introduces Balanced Sparsity, a novel pruning strategy designed to bridge this gap. By ensuring an equal number of non-zero weights across partitioned blocks in a matrix, the authors achieve the high accuracy of fine-grained pruning alongside the hardware-accelerated speed of structured approaches, resulting in up to a 3.1x practical speedup on standard GPUs.

The Balanced Sparsity Approach

The core of the proposed method is the Balanced Sparsity pattern and a balance-aware iterative pruning algorithm. Instead of pruning the entire matrix globally, each row is divided into multiple equal-sized blocks. A strict constraint is enforced: every block must contain the exact same number of non-zero weights. This structure allows for local flexibility—weights can be "randomly" distributed within a block based on their importance—while maintaining a global regularity that hardware can exploit.

Illustration of the Balanced Sparsity pattern where each row is partitioned into blocks with an equal number of non-zero elements.

To implement this, the Balance-aware Iterative Pruning algorithm sorts weights within each block by their absolute magnitude and zeros out the smallest elements until the target sparsity is reached. To maximize performance, the authors developed a custom GPU kernel. Since every block has the same workload, computational tasks are perfectly balanced across GPU threads, eliminating "thread divergence." The implementation also utilizes shared memory to avoid bank conflicts, ensuring high-bandwidth memory access.

Evaluation and Results

The effectiveness of Balanced Sparsity was evaluated across three domains: Computer Vision (VGG-16 on ImageNet), Language Modeling (LSTM on PTB), and Speech Recognition (Bi-LSTM on TIMIT). The results demonstrate that Balanced Sparsity effectively resolves the Sparsity-Efficiency Dilemma. As shown in the comparison of perplexity versus inference time, Balanced Sparsity achieves perplexity levels comparable to random (unstructured) sparsity while delivering inference times significantly lower than both random and block-based methods.

Comparison of Perplexity vs. Inference Time across different sparsity strategies.

Key performance highlights include:

  • Significant Speedup: On the PTB LSTM model, Balanced Sparsity achieved a 3.1x speedup over random sparse models using NVIDIA's cuSPARSE library.
  • High Compression: For VGG-16, the method reached 92% sparsity (over 12x compression) with no loss in top-5 accuracy.
  • Superior Efficiency: In speech recognition tasks, it achieved 87.5% sparsity with a much lower error rate than block or vector sparsity, while being the fastest implementation tested.

Key Insights

  • Workload Balancing: The primary bottleneck for unstructured pruning on GPUs is load imbalance. Balanced Sparsity ensures every thread performs the same amount of work, maximizing hardware utilization.
  • Flexibility within Structure: By allowing random distribution within blocks, the model retains its most critical connections. Theoretical analysis confirms that the error introduced by this balanced constraint is negligible compared to purely random pruning.
  • Robustness: The method is highly robust to block size variations. Unlike traditional block pruning, which degrades quickly as block sizes increase, Balanced Sparsity maintains stable accuracy across different "balance ranges."

Conclusion and Future Work

Balanced Sparsity provides a practical path for deploying highly compressed DNNs on standard GPU hardware without sacrificing performance. While the method shows near-ideal theoretical speedups at larger batch sizes, future work is needed to reduce communication overhead for low-latency, batch-size-1 scenarios. Additionally, integrating these custom kernels into mainstream frameworks like PyTorch or TensorFlow and extending the approach to modern architectures like Transformers remain important next steps.

Summary updated

BibTeX
@inproceedings{yao2019balanced,
  author = {Zhuliang Yao and Shijie Cao and Wencong Xiao and Chen Zhang and Lanshun Nie},
  title = {{Balanced Sparsity for Efficient DNN Inference on GPU}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.1609/aaai.v33i01.33015676},
}
Figure