[Paper Review] Structured State Space Models for In-Context Reinforcement Learning
The paper adapts the S5 structured state space model for reinforcement learning by enabling hidden-state resets within trajectories, achieving faster inference and improved performance over RNNs on memory-based and meta-RL tasks, including out-of-distribution generalisation.
Structured state space sequence (S4) models have recently achieved state-of-the-art performance on long-range sequence modeling tasks. These models also have fast inference speeds and parallelisable training, making them potentially useful in many reinforcement learning settings. We propose a modification to a variant of S4 that enables us to initialise and reset the hidden state in parallel, allowing us to tackle reinforcement learning tasks. We show that our modified architecture runs asymptotically faster than Transformers in sequence length and performs better than RNN's on a simple memory-based task. We evaluate our modified architecture on a set of partially-observable environments and find that, in practice, our model outperforms RNN's while also running over five times faster. Then, by leveraging the model's ability to handle long-range sequences, we achieve strong performance on a challenging meta-learning task in which the agent is given a randomly-sampled continuous control environment, combined with a randomly-sampled linear projection of the environment's observations and actions. Furthermore, we show the resulting model can adapt to out-of-distribution held-out tasks. Overall, the results presented in this paper show that structured state space models are fast and performant for in-context reinforcement learning tasks. We provide code at https://github.com/luchris429/popjaxrl.
Motivation & Objective
- Motivate and enable effective use of structured state space models (S4/S5) in reinforcement learning.
- Address the challenge of episode boundaries and variable-length rollouts in on-policy RL training.
- Demonstrate that a resettable S5 variant can match or exceed RNN performance while offering faster runtime.
- Showcase generalisation to long-horizon, partially observable, and meta-learning RL tasks with random projections.
Proposed method
- Modify S5 to allow parallel initialisation and resetting of hidden state within a trajectory.
- Introduce a resettable associative operator ⊕ that handles done flags to preserve associative properties.
- Use random linear projections of observations and actions to create a broad meta-learning task distribution.
- Re-implement POPGym environments in JAX to enable faster end-to-end evaluation.
- Evaluate on memory-length bsuite task, POPGym suites, and multi-environment meta-RL with out-of-distribution generalisation.

Experimental results
Research questions
- RQ1Can the S5 architecture be reset within training sequences to handle episode boundaries in RL rollouts?
- RQ2Does the resettable S5 offer practical speedups and performance gains over LSTMs and Transformers in memory-based and meta-RL tasks?
- RQ3Will S5 generalise to long-horizon, partially-observed, and unseen out-of-distribution tasks when exposed to random projections of observations and actions?
- RQ4How does S5 perform in a multi-environment meta-learning setting with random projections of state/action spaces?
- RQ5Is in-context adaptation feasible with S5 in random-projection RL tasks?
Key findings
- S5 with reset capability runs asymptotically faster than Transformers for long sequences and outperforms RNNs on memory-based tasks.
- On bsuite memory-length tasks, S5 achieves higher scores and is nearly twice as fast as the baseline RNN approach.
- In POPGym, S5 outperforms GRU while running over six times faster, solving the Repeat Previous Hard task.
- In a long-context meta-RL setting with random environment and projection, S5 achieves higher returns than LSTMs and shows some out-of-distribution transfer without fine-tuning.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.