Sparse Persistent RNNs: Squeezing Large Recurrent Networks On-Chip

Feiwen Zhu, Jeff Pool, Michael Andersch, Jeremy Appleyard, Fung Xie

Introduction

Recurrent Neural Networks (RNNs) are the workhorses of sequence-based tasks like speech recognition and machine translation. However, their efficacy and execution time are heavily dependent on the size of the network, making them notoriously slow and memory-intensive. While "pruning"—deleting unimportant weights to make a model sparse—can drastically reduce a model's size, it rarely translates to faster execution on GPUs. GPUs are designed for dense, regular math; sparse operations often result in irregular memory access patterns that starve the GPU's processing units.

Previous work introduced "Persistent RNNs," which keep dense weights in the GPU's fastest memory (registers) to avoid repeated, slow trips to main memory. Adapting this to sparse weights, however, is difficult. Different threads need different pieces of data at different times, leading to massive "bank conflicts" in shared memory and synchronization bottlenecks. This paper introduces Sparse Persistent RNNs, an efficient way to run large, pruned RNNs by keeping their weights entirely on-chip in GPU registers, overcoming the traditional overhead of sparsity.

Mapping of RNN hidden state blocks to GPU warps, threads, and ultimately register files.

Overcoming the Sparsity Bottleneck

To make Sparse Persistent RNNs viable, the authors propose three key technical optimizations:

  1. Wide Memory Loads: Instead of loading one activation at a time, the system batches four activations from different samples in a minibatch. This ensures that memory requests are better aligned with the GPU's hardware banks, significantly reducing delays.
  2. Bank-Aware Weight Layout: In a sparse matrix, the "random" indices of non-zero weights can cause multiple threads to hit the same memory bank simultaneously. The authors developed a greedy algorithm to reorder how weights are stored within a row, ensuring that threads in a "warp" access different memory banks as much as possible.
  3. Lamport Timestamps: Traditional GPU kernels use "global barriers" to ensure all threads finish one step before starting the next, which is inherently slow. By implementing a version of Lamport timestamps—using flags to signal when specific data is ready—threads can start the next iteration's work as soon as their specific dependencies are met, bypassing the need for a full GPU sync.

Key Insights and Performance Scaling

By keeping sparse weights in registers, the primary bottleneck shifts from global memory bandwidth to shared memory throughput. Because sparse models take up less room in registers, a much larger sparse model can fit on-chip compared to a dense one. For instance, a sparse model with a hidden layer of 5,760 can fit where only a much smaller dense model could previously. This challenges the common assumption that researchers must sacrifice speed for accuracy, showing that a large, sparse model is often both more accurate and faster than a smaller, dense model with the same number of non-zero parameters.

Execution time comparison across different layer sizes, demonstrating the scaling advantage of Sparse Persistent RNNs.

The researchers evaluated their approach using synthetic workloads, WMT15 (English-German) for Neural Machine Translation (NMT), and Deep Speech 2. The results demonstrate significant gains:

  • Raw Speedup: The method achieved over a 6x speedup compared to the next best sparse algorithm (cuSPARSE) for a hidden layer size of 2304 at 30% density.
  • Model Capacity: It enabled models over 5x larger to fit on-chip, providing a 2x speedup for these massive networks compared to traditional off-chip methods.
  • Real-World Impact: In case studies for NMT and Speech Recognition, the recurrent layers saw speedups of up to 3x.
  • Low Batch Size Efficiency: The technique is particularly effective for small batch sizes (1–4), which are critical for edge deployment and real-time applications where latency is paramount.

Limitations and Future Work

While highly effective, the approach has physical constraints. The maximum layer size is strictly limited by the physical size of the GPU's register file and shared memory (e.g., 96KB per block on the V100 used in the study). Additionally, the current implementation assumes unstructured sparsity and works best when the number of non-zero weights is balanced across rows; highly irregular sparsity can lead to thread idling.

Future work could unlock even greater potential. The authors suggest that moving from 32-bit floats to FP16 (half-precision) could potentially double the number of weights stored on-chip. Furthermore, if the pruning were "structured" (e.g., pruning blocks of weights), additional hardware-specific optimizations could be leveraged to push the boundaries of model size and speed even further.

Summary updated

BibTeX
@inproceedings{zhu2018sparse,
  author = {Feiwen Zhu and Jeff Pool and Michael Andersch and Jeremy Appleyard and Fung Xie},
  title = {{Sparse Persistent RNNs: Squeezing Large Recurrent Networks On-Chip}},
  booktitle = {International Conference on Learning Representations},
  year = {2018},
  url = {https://openreview.net/forum?id=HkxF5RgC-},
}
Figure