Were RNNs All We Needed?

Leo Feng, Frederick Tung, Mohamed Osama Ahmed, Yoshua Bengio, Hossein Hajimirsadeghi · Submission to ICLR 2025 · Rejected

TL;DR

By stripping decades-old recurrent neural networks (LSTMs and GRUs) of their hidden-state gate dependencies and unnecessary activation bounds, the authors derive minLSTM and minGRU—minimal RNNs that can be trained in parallel using standard prefix scans. Despite requiring drastically fewer parameters and only a few lines of PyTorch code, these minimal architectures train thousands of times faster than traditional RNNs and match modern models like Transformers and Mamba across language modeling, reinforcement learning, and long-range reasoning benchmarks.

What Problem Does This Paper Address?

While Transformers dominate sequence modeling, their quadratic self-attention cost makes scaling to long contexts computationally expensive. Modern alternatives—such as State Space Models (e.g., Mamba) and linearized recurrent models—offer linear-time scaling, but often at the cost of significant architectural and mathematical complexity.

Historically, LSTMs and GRUs were abandoned largely because their gates depended sequentially on the previous hidden state ($h_{t-1}$), forcing linear Backpropagation Through Time (BPTT) and preventing parallel training on GPUs. The authors investigate a fundamental historical question: If we remove the sequential training bottleneck from standard LSTMs and GRUs through minimal simplification, can these classic models remain competitive with modern sequence architectures?

Methods

The authors derive minGRU and minLSTM through two primary conceptual modifications:

  1. Dropping Previous State Dependencies from Gates: In standard GRUs and LSTMs, gates ($z_t, f_t, i_t$) and candidate states ($\tilde{h}_t$) are functions of both the current input $x_t$ and the prior hidden state $h_{t-1}$. By conditioning them solely on $x_t$, the recurrence simplifies to an element-wise linear form: $$h_t = a_t \odot h_{t-1} + b_t$$ Because $a_t$ and $b_t$ now depend only on the input sequence, all inputs to the recurrence can be computed concurrently, enabling the entire sequence to be trained in parallel via associative parallel prefix scans.

  2. Removing Range Restrictions and Extraneous Gates:

  3. minGRU: Eliminates the $\tanh$ squashing function on candidate states and drops the reset gate ($r_t$), reducing parameter count from $O(3d_h(d_x + d_h))$ to $O(2d_h d_x)$.
  4. minLSTM: Removes the candidate/hidden state $\tanh$ bounds, drops the output gate ($o_t$), merges cell and hidden states, and normalizes the forget and input gates ($f'_t + i'_t = 1$) to ensure outputs remain time-independent in scale. This reduces parameters from $O(4d_h(d_x + d_h))$ to $O(3d_h d_x)$.
  5. Numerically Stable Log-Space Parallel Scan: To prevent underflow/overflow during repeated multiplications across long contexts, the authors formulate training scans in log-space using logcumsumexp and introduce a small continuous activation $g(x)$ to ensure strictly positive candidate activations.

Datasets

The authors evaluate minLSTM and minGRU across existing public benchmarks without introducing new datasets:

  • Synthetic Content-Aware Reasoning: The Selective Copying Task (from the Mamba evaluation suite).
  • Formal Language / Generalization: Chomsky Hierarchy benchmarks (including regular, context-sensitive, and counter languages like Majority and Majority Count).
  • Long-Context Modeling: Long Range Arena (LRA) subtasks: Retrieval (length 4000), ListOps (length 2048), and Image classification on 32×32 grayscale CIFAR-10 (length 1024).
  • Offline Reinforcement Learning: D4RL continuous control benchmarks (HalfCheetah, Hopper, Walker across Medium, Medium-Replay, and Medium-Expert settings) using a Decision Transformer framework.
  • Language Modeling: Character-level autoregressive modeling on the Shakespeare dataset using the nanoGPT framework.

Key Insights and Ideas

  • Multi-layer stacking restores temporal context: A single layer’s gates depend solely on the input token $x_t$, making them time-independent. However, once layers are stacked, the second layer's inputs are the time-dependent hidden representations $h_{1:n}^{(1)}$ of the first layer. This naturally reintroduces dynamic, input-dependent temporal context without breaking training parallelization.
  • Competitive with zero custom CUDA kernels: Unlike Mamba or FlashAttention, which depend on specialized hardware-aware memory tiling and custom GPU kernels, minGRU and minLSTM demonstrate competitive throughput using vanilla PyTorch primitives.
  • Built-in scale stability: Unlike State-Space Models (SSMs) that often require specialized parameter parameterizations to avoid exploding activations, the normalized convex combination of previous and candidate states keeps hidden-state scales bounded across arbitrary sequence lengths.

Key Results

  • Training Speedup: On a T4 GPU at sequence length 4,096, minGRU and minLSTM were 1,324× and 1,361× faster per training step than traditional GRU and LSTM, performing on par with Mamba.
  • Selective Copying: While older linear SSMs (S4: 18.3%, Hyena: 28.4%) fail, minGRU achieved 99.5% and minLSTM achieved 96.0%, rivaling Mamba’s S6 (99.8%).
  • Long Range Arena & Chomsky: minLSTM achieved an average score of 0.73 across Chomsky and LRA tasks, surpassing Mamba (0.64) and matching or exceeding xLSTM (0.71).
  • Offline RL (D4RL): Across 9 MuJoCo tasks, minGRU (78.2) and minLSTM (78.1) outperformed Decision S4 (68.6) and matched Decision Transformer (76.4) and Decision Mamba (78.8).
  • Language Modeling: On the Shakespeare benchmark, minGRU and minLSTM reached test cross-entropy losses of 1.548 and 1.555, matching Transformers (1.547) while reaching convergence in ~2.5× fewer training steps.

Limitations and Future Work

  • Hardware and Scale Constraints: Experiments were limited to older 16 GB GPUs (NVIDIA T4, P100, Quadro 5000), requiring gradient accumulation and restricting evaluations to smaller architectures rather than billion-parameter language models.
  • Training Memory Footprint: The parallel scan computational graph consumes ~88% more activation memory than sequential BPTT (though still ~56% less memory than standard Mamba).
  • Future Directions: Incorporating hardware-efficient chunking algorithms (similar to FlashAttention or Mamba’s custom kernels) to minimize GPU memory bandwidth bottlenecks, and scaling these minimal RNNs to large language model pretraining.

Summary updated

BibTeX
@misc{feng2024were,
  author = {Leo Feng and Frederick Tung and Mohamed Osama Ahmed and Yoshua Bengio and Hossein Hajimirsadeghi},
  title = {{Were RNNs All We Needed?}},
  year = {2024},
  eprint = {2410.01201},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.01201},
}
Figure