Going Beyond Linear Transformers with Recurrent Fast Weight Programmers

Kazuki Irie, Imanol Schlag, Róbert Csordás, Jürgen Schmidhuber

Introduction

Standard Transformers are the gold standard for sequence processing, but they suffer from a major computational bottleneck: their cost grows quadratically with the length of the sequence ($O(L^2)$). "Linear Transformers" were developed to solve this, reducing complexity to $O(L)$ and maintaining a constant memory state.

However, Linear Transformers often struggle with tasks that require complex state maintenance or hierarchical reasoning. The authors of this paper argue that existing Linear Transformers are too "simple"—they essentially function as single-layer feedforward networks. They lack the "recurrent" power that allows models like LSTMs to maintain and update internal variables over long periods.

This paper bridges the gap between modern Linear Transformers and 1990s-era "Fast Weight Programmers" (FWPs) by introducing recurrence into the architecture. By allowing the model to "reprogram" its own weights through recurrent connections, the authors created Recurrent FWPs (RFWPs) that outperform standard Linear Transformers and LSTMs on complex algorithmic tasks and reinforcement learning environments.

Fast Weight Programmers and Recurrence

The authors frame Linear Transformers as a specific instance of Fast Weight Programmers (FWPs). In an FWP, a "slow" neural network (with fixed weights learned during training) learns to produce rapid, context-dependent weight changes for a "fast" neural network.

To add "memory" and "recurrence" to this setup, the paper introduces several novel variations:

  • The Delta Rule: Instead of just adding new information to the fast weights (the "Sum Rule" used in many Linear Transformers), they use a "Delta Rule." This allows the model to effectively overwrite or update existing information, significantly increasing memory capacity.
  • Delta RNN: Adds a recurrent connection to the "fast" network, allowing the output at time $t$ to depend on the output at $t-1$.
  • Recurrent Delta Net (RDN): Makes the "slow" network (which generates the keys, values, and queries) dependent on the previous output of the fast network.
  • Delta LSTM: A more sophisticated version where the fast network itself has an LSTM-like structure.

These additions allow the models to behave like a hybrid: they possess the associative memory of a Transformer combined with the state-tracking capability of an RNN. While adding recurrence increases the computational cost per step compared to a basic Linear Transformer, it remains $O(L)$ in time and $O(1)$ in space, making it far more scalable than a standard Transformer for very long sequences.

Key Results

The models were evaluated across three distinct domains: synthetic algorithmic tasks, language modeling, and reinforcement learning (Atari 2600).

Algorithmic Superiority

On the Code Execution task—which involves predicting the final value of variables after a sequence of assignment statements and conditionals—standard Linear Transformers failed completely (0% accuracy). In contrast, the proposed RDN and Delta RNN achieved over 85-92% accuracy, rivaling or beating standard LSTMs.

Results on synthetic algorithmic tasks including Code Execution and Sequential ListOps.

Language Modeling

Evaluated on Wikitext-103, a standard benchmark for word-level prediction, the recurrent FWP variants showed strong performance. The Delta LSTM achieved a test perplexity of 33.8, outperforming the baseline Linear Transformer (38.3) and coming very close to the standard $O(L^2)$ Transformer (34.1).

Wikitext-103 language modeling results comparing standard Transformers, Linear Transformers, and novel FWP architectures.

Reinforcement Learning

The models were tested as drop-in replacements for LSTMs in partially observable environments across 20 different Atari 2600 games (using the IMPALA actor-critic setup). The RDN outperformed the standard Linear Transformer in almost every game. Compared to the LSTM, the RDN showed superior performance in 12 out of 20 games at 50 million steps. Furthermore, the authors found that when their models initially trailed behind LSTMs in certain games, simply scaling up the model size often closed the gap or took the lead.

Limitations and Future Work

While RFWPs offer a compelling bridge between Transformers and RNNs, they come with trade-offs:

  • Computational Overhead: The Delta LSTM is significantly slower to train than a basic Linear Transformer (e.g., 14K words/sec vs 66K words/sec).
  • Implementation Complexity: These models require custom CUDA kernels to be efficient, which may hinder immediate adoption by practitioners using standard high-level libraries.
  • Hierarchical Stacking: Preliminary experiments with "Delta Delta Nets" (where the slow weights are also fast weights) showed limited gains, suggesting that the optimal way to stack these "programmers" remains an open question.

Future directions include exploring even more complex fast network architectures and applying these models to extremely long-form sequence tasks where standard Transformers are physically impossible to run.

Summary updated

BibTeX
@inproceedings{irie2021going,
  author = {Kazuki Irie and Imanol Schlag and Róbert Csordás and Jürgen Schmidhuber},
  title = {{Going Beyond Linear Transformers with Recurrent Fast Weight Programmers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=ot2ORiBqTa1},
}
Figure