FlashRNN: I/O-Aware Optimization of Traditional RNNs on modern hardware

Korbinian Pöppel, Maximilian Beck, Sepp Hochreiter

TL;DR

FlashRNN is an open-source library that brings modern hardware efficiency to traditional Recurrent Neural Networks (RNNs) like LSTMs and GRUs. By utilizing I/O-aware kernel fusion and a custom integer constraint solver (ConstrINT) to optimize memory access, the authors achieve up to 50x speedups over vanilla PyTorch, making state-tracking architectures highly competitive for modern sequence modeling.

The Problem: State-Tracking vs. Speed

While Transformers dominate current AI research due to their highly parallelizable nature, they struggle with "state-tracking"—the ability to maintain and update a precise internal memory over long sequences. This capability is critical for tasks involving time-series data or complex logical reasoning. Traditional RNNs excel at state-tracking but are notoriously slow on modern GPUs because their processing is strictly sequential.

Most modern deep learning speedups rely on parallelizing across the sequence dimension (like Attention), which RNNs cannot natively do. Furthermore, existing optimized RNN libraries (like NVIDIA’s cuDNN) are closed-source and inflexible, making it difficult for researchers to experiment with novel variants like the recently proposed sLSTM. FlashRNN bridges this gap by providing a flexible, high-performance, and open-source framework for RNN-style architectures.

Methodology: I/O-Aware Optimization

The core innovation of FlashRNN is I/O-aware optimization. In standard implementations, the GPU constantly moves data between slow global memory (HBM) and fast on-chip memory (SRAM/Registers). FlashRNN minimizes this bottleneck through three primary techniques:

  1. Kernel Fusion: FlashRNN fuses the recurrent matrix multiplication and pointwise activations into a single "persistent" kernel. This allows the recurrent weights and biases to stay cached in registers or SRAM across multiple time steps, drastically reducing HBM reads and writes.
  2. Head-wise Parallelization: Borrowing a concept from Transformers, FlashRNN splits the hidden state into multiple "heads." This renders the recurrent matrix block-diagonal, allowing different heads to be processed in parallel across different GPU thread blocks without synchronization overhead.
  3. ConstrINT Library: To handle the complexity of different GPU architectures (which have varying cache and register sizes), the authors developed ConstrINT, an integer constraint satisfaction solver. It automatically finds the optimal tiling and looping parameters for a specific model and hardware setup by treating hardware limits as mathematical constraints.
FlashRNN Kernel Overview: Comparing fused kernels that leverage caching vs. alternating kernels that require frequent HBM access.

Experiments and Key Insights

The authors evaluated FlashRNN across three distinct regimes: a synthetic parity task (testing state-tracking and sequence extrapolation), the SlimPajama dataset (training 165M parameter language models), and extensive runtime benchmarks on NVIDIA H100 and A100 GPUs.

Key Findings

  • RNNs are Memory-Bound, not Compute-Bound: The sluggishness of standard RNNs isn't due to computational complexity, but the overhead of loading weights from memory at every single time step. By caching the recurrent matrix in registers, FlashRNN drastically increases arithmetic intensity.
  • Massive Speedups: FlashRNN kernels achieved up to 50x speedups over vanilla PyTorch implementations and significantly outperformed the open-source Haste library.
  • Scaling Hidden States: The fused kernels allow for 40x larger hidden sizes compared to standard Triton implementations because they manage memory at a much more granular level.
  • State-Tracking Superiority: In the synthetic Parity Task, traditional RNNs (LSTM, GRU, sLSTM) achieved 100% accuracy, while Transformers and modern State Space Models (like Mamba) failed, hovering near random chance.
Comparison of LSTM runtimes across different head dimensions. FlashRNN backends (Triton and CUDA fused) consistently outperform vanilla PyTorch and other baselines.

Limitations and Future Work

Despite these significant optimizations, RNNs remain fundamentally sequential ($O(T)$ complexity). Transformers will likely always be faster for massive-scale pre-training on very long sequences due to their sequence-level parallelism. Additionally, the authors noted minor numerical deviations between their fused kernels and standard implementations, which warrant further investigation. Future work includes leveraging newer hardware features, such as asynchronous memory loading and inter-SRAM connections available on NVIDIA's Hopper architecture, to push performance even further.

Summary updated

BibTeX
@inproceedings{poppel2025flashrnn,
  author = {Korbinian Pöppel and Maximilian Beck and Sepp Hochreiter},
  title = {{FlashRNN: I/O-Aware Optimization of Traditional RNNs on modern hardware}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=l0ZzTvPfTw},
}
Figure