Persistent RNNs: Stashing Recurrent Weights On-Chip

Greg Diamos, Shubho Sengupta, Bryan Catanzaro, Mike Chrzanowski, Adam Coates, Erich Elsen, Jesse H. Engel, Awni Y. Hannun, Sanjeev Satheesh

Introduction

Standard deep learning libraries are highly optimized for throughput using large mini-batches. However, Recurrent Neural Networks (RNNs) face a unique "memory wall" challenge: at each timestep, the network must apply the exact same recurrent weight matrix to the current state.

In traditional implementations based on matrix multiplication (GEMM), these weights are repeatedly reloaded from the GPU's main memory (DRAM) to the processing cores for every single timestep. When the mini-batch size is small—a common requirement for low-latency applications or when saving memory to train very deep networks—the time spent moving data from memory completely dwarfs the time spent on actual computation. This bottleneck makes training deep RNNs on small batches incredibly inefficient on standard hardware.

To overcome this, researchers at Baidu developed a "persistent kernel" technique that keeps RNN weights stashed in a GPU's on-chip registers across multiple timesteps. This approach drastically reduces memory footprint, achieves massive speedups at small mini-batch sizes, and enables the training of end-to-end speech recognition models with over 100 layers.

Methods: Exploiting the Inverted Memory Hierarchy

The authors introduce Persistent RNNs, a mapping strategy designed to exploit the GPU’s "inverted memory hierarchy," where the fastest memory (registers) is also the most abundant on-chip resource.

GPU memory and compute hierarchy illustrating the MBSP model across Thread, Core, and GPU levels.

Their approach relies on four core technical pillars:

  1. Persistent Kernels: Instead of launching a new kernel for every timestep (which incurs significant overhead), they deploy a single, long-running kernel. The recurrent weights are loaded into the GPU's register files once at the start of the sequence and "stashed" there for the entire duration.
  2. MBSP Modeling: The researchers utilize the Multi-Bulk-Synchronous-Parallel (MBSP) model to mathematically balance computation, communication, and synchronization costs across the GPU's structural hierarchy (Thread -> Core -> GPU).
  3. Software Barriers: To synchronize between different Streaming Multiprocessors (SMs) without exiting the kernel, they implemented a custom assembly-level global barrier. This software synchronization is roughly 10x faster than the standard approach of relying on repeated hardware kernel launches.
  4. Tiling Strategy: The recurrent weight matrix is divided into contiguous row blocks, with each block assigned to a specific SM. This strategic division avoids the need for expensive inter-SM reductions during computation.

Key Insights

  • Registers as Cache: The collective register files on a TitanX GPU provide about 6MB of high-speed storage. Recognizing this as the largest source of on-chip memory, the authors manually managed it as a cache for recurrent weights.
  • The Batch Size/Depth Trade-off: By making small mini-batches (e.g., size 4) computationally efficient, the memory footprint of activations was reduced by 16x. This "saved" memory was repurposed to stack more layers, allowing the team to explore models with 100+ layers that previously could not fit on a single GPU.
  • Synchronization is the Bottleneck: At high execution speeds, the overhead of the operating system or driver launching a kernel becomes the primary limit on performance. This necessitates the shift to persistent, software-synchronized kernels.
  • Skip Connections are Vital: Similar to findings in computer vision (e.g., ResNets), the authors discovered that as RNNs scale past 50 layers, residual skip connections and batch normalization become essential for the model to converge during training.

Results and Performance

The researchers evaluated their approach on a large-scale speech recognition task using a 500-hour internal dataset of English speech, with models inspired by the Deep Speech architectures.

  • Massive Speedup: The persistent implementation sustained 2.8 TFLOP/s at a mini-batch size of 4 on an NVIDIA TitanX. In stark contrast, standard GEMM-based approaches achieved only 0.099 TFLOP/s at the same batch size—a remarkable 30x improvement.
  • Strong Scaling: The persistent approach scales nearly linearly up to 128 GPUs, achieving a sustained throughput of 250 TFLOP/s across the entire system.
  • Increased Model Capacity: The technique allowed for training models with 12x more parameters on the same hardware footprint.
  • Accuracy Gains: The team demonstrated that Word Error Rate (WER) continues to improve as RNN depth increases, provided the necessary architectural adjustments (skip connections) are made.

Limitations and Future Work

While highly effective, the persistent RNN approach has constraints. Because weights must fit entirely into the register file, there is a hard upper limit on the hidden layer size (approximately 1152 units for a TitanX). Larger layers require spilling weights back to slower memory, negating the performance benefits. Additionally, while the authors note that GRUs and LSTMs can utilize this technique, the primary evaluation focused on unidirectional RNNs with specific context constraints.

Looking forward, the paper notes that future GPU architectures featuring 16-bit floating-point support and larger register files will likely expand the capacity and speed of persistent RNNs even further.

Summary updated

BibTeX
@inproceedings{diamos2016persistent,
  author = {Greg Diamos and Shubho Sengupta and Bryan Catanzaro and Mike Chrzanowski and Adam Coates and Erich Elsen and Jesse H. Engel and Awni Y. Hannun and Sanjeev Satheesh},
  title = {{Persistent RNNs: Stashing Recurrent Weights On-Chip}},
  booktitle = {International Conference on Machine Learning},
  year = {2016},
}
Figure