Real-Time Recurrent Learning using Trace Units in Reinforcement Learning

Esraa Elelimy, Adam White, Michael Bowling, Martha White · DOI

Presented at NeurIPS 2024, this research introduces Recurrent Trace Units (RTUs), a novel architectural building block designed to enable memory-efficient, real-time learning for reinforcement learning (RL) agents. By leveraging a specialized rotational parameterization, RTUs allow for exact Real-Time Recurrent Learning (RTRL) with linear computational complexity, overcoming the historical bottlenecks of online recurrent neural network (RNN) training.

The Challenge: Memory vs. Efficiency in Online RL

In many real-world RL scenarios, agents operate in Partially Observable Markov Decision Processes (POMDPs), where the current observation does not contain all the information needed for optimal decision-making. To succeed, agents must maintain a memory of past observations, typically implemented via RNNs.

However, training RNNs online presents a significant dilemma:

  1. Backpropagation Through Time (BPTT): The standard approach requires storing long sequences of data and "unrolling" the network backward. This is memory-intensive and introduces "truncation bias," where the agent fails to learn dependencies longer than the unroll window.
  2. Real-Time Recurrent Learning (RTRL): This method provides exact gradient updates without storing history, but it is traditionally computationally prohibitive. Its cost scales at the fourth power of the hidden layer size ($O(n^4)$), making it unusable for modern deep learning architectures.

RTUs bridge this gap by providing the exact, history-free updates of RTRL with the $O(n)$ efficiency required for real-time robotics and continual learning.

Methodology: Recurrent Trace Units

The RTU architecture builds upon the concept of Linear Recurrent Units (LRUs), which use complex-valued diagonal recurrent weights to simplify the mathematics of gradient calculation. RTUs refine this approach through two primary innovations:

1. Rotational Cosine Representation

Instead of using explicit complex numbers—which can be unstable or poorly supported in some deep learning frameworks—RTUs utilize a "rotational" form. The hidden state is represented as two real-valued vectors that interact via a 2x2 rotation matrix. This maintains the representational power of complex-valued eigenvalues while ensuring stability in a real-valued space.

2. Non-Linearity in the Recurrent Loop

While LRUs are strictly linear in their recurrence, the authors found that incorporating a non-linearity (such as ReLU) inside the recurrent update significantly boosts performance in RL tasks. Although this breaks the strict mathematical equivalence to dense linear RNNs, the empirical gains in complex environments are substantial.

The authors integrated RTUs with Proximal Policy Optimization (PPO) and derived specific gradient "traces" that allow the model parameters to be updated efficiently at every timestep.

Experimental Evaluation

The researchers evaluated RTUs across several diverse benchmarks designed to test temporal dependency and control:

  • Trace Conditioning: A task requiring the agent to associate a stimulus with a reward that arrives after a significant delay.
  • MuJoCo POMDP: Standard physics-based control tasks (Ant, Walker, Hopper, Cheetah) where velocity or position data is hidden to necessitate memory.
  • POPGym: A benchmark specifically designed to evaluate long-term memory in RL.
  • Reacher POMDP: A task where the target location is only visible in the initial frame.

Key Insights and Results

Efficiency and Scaling

In the Trace Conditioning task, RTUs achieved near-zero error with significantly fewer floating-point operations (FLOPs) than standard GRUs. Furthermore, RTUs demonstrated a clean scaling law: unlike GRUs, which can show inconsistent performance as size increases, RTUs consistently improved as more parameters and compute were allocated.

Superior Control in POMDPs

On the MuJoCo POMDP benchmark, RTUs consistently outperformed both GRUs and standard LRUs. In the "Ant-P" environment, for instance, RTUs achieved higher rewards than competitors while maintaining the same parameter count. The authors also confirmed that RTU updates take constant time per step, regardless of sequence length, whereas BPTT costs grow with the look-back window.

The Role of "Stale" Gradients

In PPO, gradients are typically re-computed on a batch. The authors discovered that using "stale" gradients—traces calculated during the agent's actual interaction—actually improved performance. They hypothesize that this staleness acts as a natural regularizer, helping the agent stay within the PPO "trust region" and preventing destabilizing policy shifts.

Limitations and Future Directions

Despite their success, RTUs face certain constraints:

  • Multi-layer Complexity: The $O(n)$ efficiency currently applies only to a single recurrent layer. Stacking multiple RTU layers causes gradients between layers to become dense, returning the complexity to higher orders. Maintaining linear complexity in deep stacks remains an open research question.
  • Parallelization: RTRL is optimized for sequential online learning and does not yet benefit from the massive parallelization (e.g., parallel scans) used to train Transformers on GPUs.
  • Theoretical Foundations: The inclusion of non-linearities inside the recurrence means the formal proof of equivalence to dense linear RNNs is lost. While empirically superior, the theoretical implications of this architectural choice require further study.

Summary updated

BibTeX
@inproceedings{elelimy2024real,
  author = {Esraa Elelimy and Adam White and Michael Bowling and Martha White},
  title = {{Real-Time Recurrent Learning using Trace Units in Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=4UvMOnZMam},
}
Figure