Encoding Memory in World Models with Test-Time Model-Based Reinforcement Learning
Organizations: Computer Vision Lab, CAIDAS & IFI, University of Würzburg, Germany
Abstract
Model-based reinforcement learning (MBRL) approaches have demonstrated strong performance across diverse domains in recent years, learning accurate world models from agent trajectories. However, despite this progress, current approaches still struggle to surpass human performance on tasks that require long-term memory and planning. In this work, we address the problem of long-term memory in MBRL by moving beyond the commonly studied paradigm of architecture design. We introduce Test-Time Model-Based Reinforcement Learning (TT-MBRL), using gradient descent at test time to encode the memory of episode observations into world model parameters. This enables the agent to learn a distinct world model for each episode, improving memory capabilities compared to traditional approaches that solely rely on contextual memory. We first establish a proof of concept on a simplified two-dimensional variant of the Memory Maze environment, which we refer to as Memory Maze 2D, showing consistent improvements across different world model architectures. We then demonstrate the effectiveness of TT-MBRL in the 3D domain, achieving new state-of-the-art results on the Memory Maze benchmark. Finally, we show that TT-MBRL maintains strong performance on non-memory benchmarks such as DeepMind Control and Atari 100k.
Figures & tables
| Mem Maze 2D 9×9 | Mem Maze 2D 11×11 | Mem Maze 2D 13×13 | Mem Maze 2D 15×15 | |
|---|---|---|---|---|
| Method | ||||
| Human | ||||
| Oracle | ||||
| DreamerV3 (TBTT) | ||||
| + TT-MBRL (Ours) | ||||
| TWISTER |
| Method | KL div | FVD | PSNR | SSIM | LPIPS |
|---|---|---|---|---|---|
| DreamerV3 (TBTT) | |||||
| + TT-MBRL (Ours) | |||||
| TWISTER | |||||
| + TT-MBRL (Ours) | |||||
| R2I | |||||
| + TT-MBRL (Ours) |
| Mem Maze 9×9 | Mem Maze 11×11 | Mem Maze 13×13 | Mem Maze 15×15 | |
|---|---|---|---|---|
| Method | ||||
| Human | ||||
| Oracle | ||||
| IMPALA † | ||||
| IMPALA † (400M steps) | ||||
| DreamerV3 (TBTT) |
| Method | KL div | FVD | PSNR | SSIM | LPIPS |
|---|---|---|---|---|---|
| DreamerV3 (TBTT) | |||||
| + TT-MBRL (Ours) | |||||
| TWISTER | |||||
| + TT-MBRL (Ours) | |||||
| R2I | |||||
| + TT-MBRL (Ours) |
| Method | w/o TT-MBRL | Train Data Only | Test Data Only | Test+Train Data | ||
|---|---|---|---|---|---|---|
| No Prefill | 1024 Prefill | No Prefill | 1024 Prefill | |||
| DreamerV3 | ||||||
| TWISTER | ||||||
| R2I | ||||||
| Method | w/o TT-MBRL | Episode Score | Eval. Time (hours) | ||
|---|---|---|---|---|---|
| Frozen | Unfrozen | Frozen | Unfrozen | ||
| Memory Maze 2D 15 15 | |||||
| DreamerV3 | |||||
| TWISTER | |||||
| R2I | |||||
| Memory Maze 15 15 | |||||
Appendix figures & tables32 assets
Supplementary material from the paper’s appendix.
Appendix
| Method | PAD | TT-MBRL | w/o KL loss | w/o rwd-cont loss | w/o actor-critic loss |
|---|---|---|---|---|---|
| DreamerV3 | |||||
| TWISTER | |||||
| R2I |
| Method | w/o TT-MBRL | 100/0 (train-only) | 75/25 | 50/50 | 25/75 | 0/100 (test-only) |
|---|---|---|---|---|---|---|
| DreamerV3 | ||||||
| TWISTER | ||||||
| R2I |
| Policy Step/Grad Step | w/o TT-MBRL | 32 | 16 | 8 | 4 | 2 | 1 | 1/2 |
|---|---|---|---|---|---|---|---|---|
| DreamerV3 | ||||||||
| TWISTER | ||||||||
| R2I |
| #Env Steps | Training Time (days/task) | |||||
|---|---|---|---|---|---|---|
| Environment | #Tasks | Method | GPU | #GPUs | ||
| Memory Maze 2D | 4 | DreamerV3 | L40 | 1 | 100M | 8 |
| Memory Maze 2D | 4 | TWISTER | L40 | 1 | 100M | 6 |
| Memory Maze 2D | 4 | R2I | L40 | 1 | 100M | 2.9 |
| Memory Maze | 4 | DreamerV3 | L40 | 1 | 100M | 13.5 |
| Memory Maze | 4 | TWISTER | L40 | 1 | 100M | 23 |
| Mem Maze 2D 9×9 | Mem Maze 2D 11×11 | Mem Maze 2D 13×13 | Mem Maze 2D 15×15 | |
|---|---|---|---|---|
| Parameter | ||||
| Number of actions | ||||
| Observation dim | ||||
| Number of colors | ||||
| Number of rooms | ||||
| Room size |
| Step time (ms) | 9×9 | 11×11 | 13×13 | 15×15 |
|---|---|---|---|---|
| Memory Maze 2D | ||||
| Memory Maze |
| Hyperparameter | Memory Maze 2D | Memory Maze |
| General | ||
| Batch Size (B) | 64 | 16 |
| Sequence Length (T) | 64 | 64 |
| Environment Instances | 8 | 32 |
| Policy Step per Grad Step | 64 | 64 |
| Replay Buffer Capacity | 10M | 10M |
| Hyperparameter | Memory Maze 2D | Memory Maze |
| General | ||
| Batch Size (B) | 4 | 4 |
| Sequence Length (T) | 1024 | 1024 |
| Environment Instances | 8 | 32 |
| Policy Step per Grad Step | 64 | 64 |
| Replay Buffer Capacity | 10M | 10M |
| Hyperparameter | Memory Maze 2D | Memory Maze |
| General | ||
| Batch Size (B) | 4 | 4 |
| Sequence Length (T) | 1024 | 1024 |
| Environment Instances | 8 | 40 |
| Policy Step per Grad Step | 64 | 64 |
| Replay Buffer Capacity | 10M | 10M |
Model-Based RL
Model-based reinforcement learning uses environment models to plan actions and learn policies with fewer real-world interactions.
See all 257 papers