TL;DR
Training recurrent neural networks (RNNs) is notoriously slow because they process sequences one step at a time. This paper introduces a way to break that serial bottleneck by using "parallel scan" algorithms on linear recurrences. This approach allows for up to a 9x speedup in training and grants models the ability to handle sequences with over a million timesteps—lengths previously considered unreachable.
The Sequential Bottleneck
The "sequential bottleneck" is the Achilles' heel of RNNs. In a standard LSTM or GRU, the hidden state at time $t$ depends non-linearly on the state at $t-1$. This means you cannot calculate the 100th step until you have finished the 99th.
While researchers usually mitigate this by processing many sequences simultaneously (minibatching), this approach has diminishing returns. Large minibatches consume massive amounts of GPU memory and can actually hurt the model's ability to generalize. For researchers working with very long sequences—like those found in robotics, audio, or medical monitoring—the serial nature of RNNs makes training agonizingly slow or technically impossible.
Methodology: Parallel Scans and Linear Surrogates
The authors observe that if the recurrence relation is linear, it can be parallelized using an algorithmic trick called a parallel scan (or prefix sum).
- Parallel Linear Recurrence: By ensuring the recurrence follows the form $h_t = \Lambda_t h_{t-1} + x_t$, the authors can use the parallel scan algorithm to distribute the computation across thousands of GPU cores. To keep the math efficient, they restrict $\Lambda_t$ to be a diagonal matrix, turning matrix-vector products into simple element-wise multiplications.
- Linear Surrogate RNNs (LS-RNNs): Since most popular RNNs are non-linear, the authors propose "linearizing" them. They decouple the state used for the next time step from the state passed to other layers. They introduce the GILR-LSTM (Gated Impulse Linear Recurrent LSTM), a version of the LSTM where the core "memory" update is linear and thus parallelizable.
- CUDA Implementation: They developed a custom CUDA kernel for TensorFlow that implements this parallel scan, specifically optimized for the architecture of modern GPUs (using "warps" as individual processors).
Key Insights and Results
A major insight from this work is that you don't actually need non-linearities inside the recurrent loop to solve complex problems. By stacking linear recurrent layers separated by non-linear activations, you get the best of both worlds: deep non-linear expressivity and fast parallel training. Furthermore, this method allows for high GPU utilization even with a batch size of 1, because it parallelizes across the length of the sequence.
Model Speedup
The custom parallel scan kernel achieved up to 40x higher throughput than a serial implementation for very long sequences. When integrated into full architectures like the Simple Recurrent Unit (SRU) or Quasi-RNN (QRNN), the authors saw end-to-end training speedups of up to 9x.
Breaking the 1M Barrier
To test pathological long-term dependencies, the authors evaluated the models on a synthetic sequence classification task where the network must remember the sign of the very first element to classify the entire sequence correctly at the end.
The GILR-LSTM successfully learned this task with a staggering one-million-step dependency. In comparison, the standard CuDNN-optimized LSTM was significantly slower and failed to converge on the longest sequences within a reasonable timeframe. On a sequence of 8,192 steps, the GILR-LSTM converged in 0.10 hours, while the CuDNN LSTM took 0.58 hours.
Limitations and Future Work
- Linear Constraint: This technique is strictly for linear recurrences. It cannot accelerate traditional LSTMs or GRUs without modifying their architecture into a "surrogate" form.
- Sequence Awareness: Parallel scan requires the entire sequence to be known upfront. This makes it perfect for training and "offline" inference (like processing a recorded audio file), but it offers no benefit for "online" streaming inference where inputs arrive one by one.
- Diagonal Restriction: While using diagonal matrices is fast, it might limit the model's ability to perform complex state rotations in a single layer compared to full-matrix RNNs, though the authors argue that stacking layers mitigates this.
Summary updated