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

Korbinian Pöppel, Maximilian Beck, Sepp Hochreiter
12/10/2024
cs.LGcs.AI

Official code: NX-AI/flashrnn (188 stars, last commit 2025-10-20).

Abstract

While Transformers and other sequence-parallelizable neural network architectures seem like the current state of the art in sequence modeling, they specifically lack state-tracking capabilities. These are important for time-series tasks and logical reasoning. Traditional RNNs like LSTMs and GRUs, as well as modern variants like sLSTM do have these capabilities at the cost of strictly sequential processing. While this is often seen as a strong limitation, we show how fast these networks can get with our hardware-optimization FlashRNN in Triton and CUDA, optimizing kernels to the register level on modern GPUs. We extend traditional RNNs with a parallelization variant that processes multiple RNNs of smaller hidden state in parallel, similar to the head-wise processing in Transformers. To enable flexibility on different GPU variants, we introduce a new optimization framework for hardware-internal cache sizes, memory and compute handling. It models the hardware in a setting using polyhedral-like constraints, including the notion of divisibility. This speeds up the solution process in our ConstrINT library for general integer constraint satisfaction problems (integer CSPs). We show that our kernels can achieve 50x speed-ups over a vanilla PyTorch implementation and allow 40x larger hidden sizes compared to our Triton implementation. Our open-source kernels and the optimization library are released here to boost research in the direction of state-tracking enabled RNNs and sequence modeling: https://github.com/NX-AI/flashrnn

View on arXivView PDF

Code Implementations(1)

NX-AI/flashrnnOfficial100%

FlashRNN - Fast RNN Kernels with I/O Awareness

18817C, C++Nov 10, 20241 years agoNOASSERTION

Similar Papers

Cite this paper

@article{pppel2024flashrnn,
  title  = {FlashRNN: I/O-Aware Optimization of Traditional RNNs on modern hardware},
  author = {Korbinian Pöppel and Maximilian Beck and Sepp Hochreiter},
  year   = {2024},
  eprint = {2412.07752},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.07752v3},
  journal = {ICLR 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2412.07752.svg)](https://codeofpaper.com/paper/2412.07752)

Discussion