Block-Sparse Recurrent Neural Networks

Sharan Narang, Eric Undersander, Gregory F. DiamosarXiv 2017

Introduction

Deep learning models, particularly Recurrent Neural Networks (RNNs) used in speech recognition and language modeling, have grown increasingly massive. While weight pruning—the process of setting unimportant weights to zero—is a common technique to reduce model size, it typically results in unstructured sparsity. Modern hardware, such as GPUs and TPUs, is optimized for regular, dense computations. Randomly scattered zeros lead to irregular memory access patterns, preventing the use of efficient array data-paths like Tensor Cores. Consequently, a model with 90% unstructured sparsity may not exhibit significant speedups over its dense counterpart. This paper introduces block-sparse RNNs, where weights are pruned in organized $N \times N$ chunks to bridge the gap between theoretical sparsity and practical hardware performance.

Methodology

The researchers explored three primary techniques to induce block sparsity:

  1. Block Pruning (BP): This method utilizes a monotonically increasing threshold during training. To determine if a block should be pruned, the maximum absolute value of any weight within that block is used as a representative. If this value falls below the threshold, the entire block is zeroed.
  2. Group Lasso Regularization (GL): A penalty term proportional to the $\ell_2$ norm of each block is added to the loss function, encouraging entire groups of weights to shrink toward zero simultaneously.
  3. Combined Approach (GLP): The most effective results were achieved by using Group Lasso to "guide" the pruning process, pushing blocks toward zero before the pruning mask is applied.
Block pruning mechanism using max-reduction to determine mask values.

The study evaluated various block sizes, from $4 \times 4$ to $32 \times 32$ grids. Larger blocks reduce indexing overhead—storing one index per block rather than per weight—but require careful management to maintain accuracy.

Experimental Setup

The models were evaluated on a large-scale speech recognition task using the Deep Speech 2 architecture. The training set comprised 2100 hours of English speech, with validation and independent test sets of 3.46 and 2.9 hours, respectively. Performance was measured using the Character Error Rate (CER).

Key Results and Discussion

The proposed methods achieved significant model compression and hardware speedups:

  • Compression and Sparsity: The authors achieved 80% to 90% block sparsity with minimal accuracy loss, resulting in approximately 10x model compression.
  • Performance Recovery: By starting with a larger, over-parameterized baseline (e.g., 3072 hidden units) and pruning it, the researchers could recover baseline accuracy while maintaining a 2.5x to 5x reduction in total parameters.
  • Hardware Speedup: Benchmarks on NVIDIA TitanX GPUs demonstrated that block-sparse matrices achieve significantly higher throughput than unstructured sparse matrices.
Speedup comparison across different batch sizes for weight pruning (WP) and block pruning (BP) configurations.

As shown in the speedup analysis, block-sparse configurations (BP 4x4 and BP 16x16) consistently outperform standard weight pruning (WP) across various batch sizes. While unstructured weight pruning (WP) shows diminishing returns and even performance degradation as batch size increases, block pruning maintains a significant speedup advantage by aligning with hardware data-paths.

Conclusion and Future Work

Block-sparse RNNs offer a viable path toward deploying massive models on resource-constrained hardware. While larger blocks are more hardware-efficient, they present a steeper accuracy-sparsity trade-off. Future work includes exploring "sparse training" from the outset to save compute during the training phase and developing optimized kernels for a broader range of processors, including mobile ARM units.

Summary updated

BibTeX
@misc{narang2017block,
  author = {Sharan Narang and Eric Undersander and Gregory F. Diamos},
  title = {{Block-Sparse Recurrent Neural Networks}},
  year = {2017},
  eprint = {1711.02782},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1711.02782},
}
Figure