Abstract
Current methods for training recurrent neural networks are based on backpropagation through time, which requires storing a complete history of network states, and prohibits updating the weights 'online' (after every timestep). Real Time Recurrent Learning (RTRL) eliminates the need for history storage and allows for online weight updates, but does so at the expense of computational costs that are quartic in the state size. This renders RTRL training intractable for all but the smallest networks, even ones that are made highly sparse. We introduce the Sparse n-step Approximation (SnAp) to the RTRL influence matrix, which only keeps entries that are nonzero within n steps of the recurrent core. SnAp with n=1 is no more expensive than backpropagation, and we find that it substantially outperforms other RTRL approximations with comparable costs such as Unbiased Online Recurrent Optimization. For highly sparse networks, SnAp with n=2 remains tractable and can outperform backpropagation through time in terms of learning speed when updates are done online. SnAp becomes equivalent to RTRL when n is large.
Introduction: The Memory Bottleneck in RNN Training
Recurrent Neural Networks (RNNs) are essential for sequence modeling but face a significant "memory problem." Standard training via Backpropagation Through Time (BPTT) requires storing the entire history of network states to compute gradients. For long sequences, memory requirements become prohibitive.
Real-Time Recurrent Learning (RTRL) offers an alternative by updating weights at every timestep without history storage. However, RTRL tracks an "influence matrix" representing how every parameter affects every hidden unit. This results in a computational cost that scales quartically ($O(k^4)$) with the number of hidden units $k$, making it intractable for large networks. The challenge is finding a middle ground: an algorithm that is "online" like RTRL but computationally efficient like BPTT.
The SnAp Framework: Approximating RTRL
The Sparse n-step Approximation (SnAp) addresses this by sparsifying the RTRL influence matrix. The core heuristic is that a parameter primarily influences neurons it is directly connected to, and its influence on the broader network diffuses or becomes less relevant over time.
- SnAp-1: Tracks the influence of a parameter only on the specific hidden unit it feeds into. This makes the influence matrix effectively diagonal and keeps costs comparable to BPTT.
- SnAp-n: Tracks influence over $n$ timesteps. As $n$ increases, the approximation approaches full RTRL but with higher computational cost.
- Leveraging Sparsity: SnAp is particularly effective for sparse RNNs. By using sparse matrix operations, the computational burden is reduced by a factor proportional to the square of the network's sparsity, making large-scale online learning viable.
Experimental Evaluation
The authors evaluated SnAp on two primary benchmarks: WikiText103, a large-scale character-level language modeling task, and a synthetic 'Copy' task, which specifically tests the ability to learn long-term dependencies.
Key Results
- WikiText103 Performance: SnAp-1 achieved validation scores nearly identical to the BPTT "gold standard," significantly outperforming other online approximations like UORO, which failed to beat random-initialization baselines.
- Long-Term Dependencies: On the Copy task, Truncated BPTT (T=1) failed completely. However, fully online SnAp-2 and SnAp-3 successfully learned the task, proving they can capture dependencies that truncation normally kills.
- Efficiency: For a 1000-unit RNN with 99% sparsity, SnAp-2 is approximately 100x faster than full RTRL, making it a practical choice for real-time applications.
Discussion and Insights
- Sparsity as a Feature: Sparse RNNs offer more capacity per parameter than dense ones. SnAp is designed to exploit this, making large, sparse RNNs viable for online learning.
- Staleness Tolerance: In online learning, weights change while the influence matrix is being calculated (leading to "stale" Jacobians). The authors found that this staleness does not significantly impede learning at reasonable learning rates.
- Trade-offs: There is a clear bias-compute tradeoff. Higher-order approximations (SnAp-2 or 3) require extreme network sparsity (e.g., >99%) to remain as fast as BPTT.
Limitations and Future Work
SnAp's primary limitation is its reliance on high sparsity for computational efficiency. Current deep learning hardware (GPUs/TPUs) is optimized for dense matrix multiplication, meaning the theoretical speedups of SnAp require better software and hardware support for truly sparse operations. Additionally, approximation bias can accumulate late in training, suggesting a need for future research into bias-tempering strategies or better sparse training methods.
In conclusion, SnAp provides a practical roadmap for training massive, sparse RNNs on infinite sequences, bridging the gap between the memory efficiency of RTRL and the computational tractability of BPTT.
Summary updated