Abstract
Model-Based Reinforcement Learning (MBRL) relies on an agent's ability to simulate environment dynamics through a world model. While Recurrent Neural Networks (RNNs) and Transformers have served as the primary backbones for these models, they suffer from vanishing gradients and quadratic computational scaling, respectively. This paper introduces S4WM, the first world model backbone based on Structured State Space Sequence (S4) models. We demonstrate that S4WM provides a "best of both worlds" solution: the parallel training efficiency of Transformers and the linear-time generation of RNNs. Our evaluation across complex 3D environments and memory-intensive benchmarks shows that S4WM significantly outperforms traditional architectures in long-horizon imagination and state tracking.
1. Introduction
In Model-Based Reinforcement Learning, an agent learns a mental representation of its environment to predict the consequences of its actions. For effective planning in partially observable settings, these world models must possess robust long-term memory. Historically, the field has been dominated by Recurrent Neural Networks (RNNs), such as the Recurrent State Space Model (RSSM). However, RNNs struggle with long-range dependencies due to vanishing gradients.
Transformers emerged as a powerful alternative, utilizing self-attention to provide direct access to all previous time steps. Yet, Transformers face a significant bottleneck: their computational complexity grows quadratically with sequence length ($O(T^2)$), making them prohibitively expensive for the long-horizon simulations required in complex MBRL tasks. This research introduces S4WM, leveraging Structured State Space models to achieve efficient, long-range temporal modeling.
2. Methodology
S4WM is built upon the framework of Parallelizable State Space Models (PSSMs), specifically utilizing the S4 architecture. The model consists of three primary components:
- Latent Variable Modeling: Following the design of state-of-the-art agents like Dreamer, S4WM operates in a compact latent space. A Convolutional Neural Network (CNN) encodes high-dimensional observations (pixels) into latent representations.
- S4 Backbone: The core temporal processing is handled by a stack of S4 blocks. These blocks use a mathematical formulation involving Diagonal Plus Low-Rank matrices, allowing the model to switch between two modes: a convolutional mode for fast, parallelized training and a recurrent mode for efficient, step-by-step imagination.
- Variational Inference: The system is trained by maximizing the Evidence Lower Bound (ELBO), ensuring that the latent states effectively capture the information necessary for environment reconstruction and reward prediction.
3. Experimental Evaluation
We evaluated S4WM against RNN-based (RSSM) and Transformer-based (TSSM) models across several challenging environments:
- 3D Memory Maze: A benchmark requiring the model to navigate and recall the layout of multiple rooms over long trajectories.
- 2D MiniGrid (Distracting Memory): A task where the agent must retain a single piece of information from the start of an episode while ignoring irrelevant visual noise.
- 2D MiniGrid (Multi Doors Keys): A reasoning-heavy task requiring the model to track the status of multiple keys and doors.
- DMLab: Used for quantitative comparisons in video prediction quality against high-end models like TECO.
4. Results and Discussion
4.1 Imagination Fidelity and Horizon
S4WM demonstrated a superior ability to maintain stable, high-fidelity simulations over long horizons. In the "Four Rooms" environment, S4WM achieved a Generation Mean Squared Error (MSE) of 44.0, significantly lower than RSSM-TBTT (219.4) and TSSM-XL (224.4). While RNNs and Transformers often lost track of environment layouts within 50 steps, S4WM maintained coherent simulations for over 500 steps.
4.2 Memory-Based Reasoning
In the "Distracting Memory" task, S4WM achieved 100% accuracy in reward prediction within its imagination. In contrast, the RNN-based model performed at near-random levels (~50%), and the Transformer struggled to maintain accuracy as the imagination horizon extended. Furthermore, S4WM was the only model capable of consistently tracking state changes—such as the consumption of a key—over long sequences, whereas competing models frequently hallucinated the continued existence of used items.
4.3 Computational Efficiency
S4WM proved to be the most efficient model to train due to its parallelizable nature. While RNNs maintain a higher raw throughput for frame generation, S4WM offers a much more scalable alternative to Transformers for long sequences, avoiding the quadratic memory and time costs associated with self-attention.
5. Conclusion and Future Work
S4WM represents a significant advancement in world model architecture, successfully bridging the gap between the training efficiency of Transformers and the inference efficiency of RNNs. It excels in long-horizon tasks that require both high-fidelity imagination and complex state tracking.
Future research will focus on scaling S4WM to even more complex environments, such as the "Ten Rooms" maze where all current models still face challenges. Additionally, integrating S4WM into a complete Reinforcement Learning loop will be critical to determine how improved imagination translates into policy performance in stochastic, real-world scenarios.
Summary updated