Paper commentary
Encoding Memory in World Models with Test-Time Model-Based Reinforcement Learning
Test-time gradient updates encode episode memory into world model parameters
- Problem Model-based agents still fail to beat humans on tasks needing long-term memory. Their world models rely on context alone, so predictions drift in partially observable mazes and the specific layout of each new episode is hard to capture.
- Method TT-MBRL takes gradient steps on the world model during evaluation. It copies the trained weights at the start of each episode and updates them using a dedicated test-time replay buffer, so each episode gets its own adapted world model.
- Results On Memory Maze 15×15, R2I with TT-MBRL scores 244.3, compared to 171.6 without it.

Figure 3 : During training, the world model learns to predict the common patterns shared among multiple episode trajectories collected during exploration. The agent can solely rely on contextual memory to identify patterns that are unique to each new episode, which can lead to incoherent future predictions. At test time, the agent can leverage both contextual and neural memory. This allows the world model to make more accurate predictions and learn an improved policy for each new episode.
Original paper · CC BY 4.0 · Maxime Burchi, Fayaz Ali Dharejo, Radu Timofte · Encoding Memory in World Models with Test-Time Model-Based Reinforcement Learning · Original paper figure · Extracted the figure area from page 4 of the original PDF.Where Dreamer-style world models lose track
Dreamer learns a world model in latent space and imagines trajectories with it, which works well when the environment is fully observable. In Memory Maze the agent sees only part of the maze, so world model prediction error accumulates over time. The imagined trajectories then become increasingly inconsistent with past observations, because the predicted future stops matching what the agent has already seen.

Figure 2 : DreamerV3 failure case where the world model predicts an incoherent future after returning to the original position in Memory Maze.
Original paper · CC BY 4.0Recent work tries to fix this by changing the architecture so that more past context reaches the model. TransDreamer swaps in a Transformer-based world model to process long context with self-attention. TWISTER adds a contrastive predictive coding objective to the Transformer world model to enhance temporal representation learning. SSM-based world models such as R2I and S4WM push the same direction, and Samsami et al.
(2024) report that R2I outperforms earlier approaches on the Memory Maze benchmark.
The authors argue that all of these designs ask a single shared model to carry episode details through context alone. Shared patterns transfer well across episodes, but the specific layout of one new maze is hard to capture that way. Partial observability makes this harder, because the agent must rely on episode-specific information that context alone doesn't expose.
That gap is the problem that TT-MBRL targets, by adapting the world model parameters to each episode instead.
Writing episode memory into the weights
The key idea is to keep updating the world model during evaluation, so each episode leaves traces in the parameters and not only in the context window. The authors draw on test-time training, which adapts model parameters at inference time, and on the view that biological long-term memory is kept as persistent changes in synaptic strengths.
Test-time training helps when training and test data come from different distributions, so the authors apply the same mechanism within a single episode.
Training gives one set of weights shared by every episode in the replay buffer, so the model fits the patterns the episodes have in common. TT-MBRL instead gives each evaluation episode its own world model and policy, initialized from the weights learned during training. At the start of each episode, the agent copies the trained parameters into test-time parameters and fills a dedicated test-time replay buffer with that episode's observations.
The authors expect the adapted model to predict more accurately within that episode, and more accurate predictions give more accurate imagined returns for the actor and critic. Context alone must extract the unique layout of each new episode, which can leave future predictions incoherent.
The update uses the reward and continuation losses only, because the encoder and decoder stay frozen at test time. Half of each training mini-batch comes from the training buffer and half from the test-time buffer, which acts as regularization against overfitting to few test-time observations.
The method's effect on memory is measured on Memory Maze, where the paper reports a 53.7% increase in rewards per step for R2I after 4000 environment steps on Memory Maze 15×15. That gain grows as more test-time observations accumulate in the buffer, which fits the idea that the stored memory comes from the current episode.
How the test-time update runs
At the start of each episode, the test-time parameters ϕ′, θ′ and ψ′ are set to the trained weights ϕ, θ and ψ. The agent stores the observations of the current episode in a dedicated test-time replay buffer. Each mini-batch takes half of its trajectories from the training buffer and the other half from the test-time buffer. The authors describe this split as a regularizer that mitigates overfitting to the limited test-time observations.
The encoder and decoder parameters are frozen, and the reconstruction loss is dropped at test time. Freezing keeps the representation space learned during training fixed, since encoder representations don't depend on temporal ordering. The episode-specific information sits in the sequential and dynamics network parameters, which the test-time update changes.
Unfreezing these parameters would require gradient backpropagation through the decoder and encoder, which lengthens evaluation. Parameter freezing is the default setting because it improves evaluation efficiency without sacrificing performance.
The test-time prediction loss keeps only the reward predictor and continue predictor terms, omitting the reconstruction objective. Here B is the number of sequences in a batch and T the sequence length, and each β weights its loss term. The actor and critic are then optimized on trajectories of H = 15 steps imagined with this adapted model.
By reducing world model prediction errors, the adapted model gives more accurate estimates of imagined returns for the actor and critic.
Memory Maze 2D: where adaptation helps
The 2D variant gives the agent a top-down 3×3 local view centered on its position, with colored borders that name the target color. The observation is flattened and normalized into a vector of dimension 75 = 5×5×3. Scores come from 100M environment steps on four maze sizes, averaged over three runs with 100 evaluation episodes.
On 15×15, R2I scores 244.3 with TT-MBRL, compared to 171.6 without it. The same change lifts DreamerV3 from 46.2 to 185.0 at that size. TWISTER rises from 72.0 to 240.1 on 15×15 under the same setup. On 9×9, R2I stays at 123.1 with and without TT-MBRL, and the authors say the gain appears only where a near optimal policy isn't already reached.
Without adaptation, TWISTER outperforms DreamerV3 on 15×15, which the authors credit to its Transformer-based world model with self-attention. R2I with TT-MBRL outperforms the human score of 201.0 on 15×15. The authors attribute the 9×9 shortfall to the policy failing on a subset of episodes despite doing well on most.
For DreamerV3, the KL divergence drops from 114.6 to 66.0 with TT-MBRL. The authors read these results as lower prediction error in latent space, which gives more accurate predictions.
Memory Maze 3D: gains at the larger sizes
The 3D Memory Maze benchmark has four sizes, with three target objects in the smaller mazes and six in 15×15. At 100M environment steps, R2I on 15×15 moves from 20.3 to 29.3 once TT-MBRL is added. With 400M environment steps, R2I climbs from 42.0 to 54.1 on 15×15 and from 60.1 to 63.0 on 13×13. The authors trained DreamerV3, TWISTER, and R2I for 100M steps on every size, and they added R2I runs out to 400M steps.
Each of these scores is averaged over three runs, except the 400M R2I entries, which use six runs.
The authors report new state-of-the-art results on the 13×13 and 15×15 sizes, and the 15×15 score sits closest to the human result of 67.7. The gains on the smaller mazes are more modest, because DreamerV3 and R2I already come near optimal there. The per-step reward improvement for R2I on 15×15 grows with experience, reaching 53.7% after 4000 environment steps.
The authors also measured world model prediction error on 15×15, where TT-MBRL lowered every metric they reported for R2I. Without test-time optimization the rollout accumulates errors, which the authors link to harder policy learning.

Figure 6 : Impact of TT-MBRL on world model predictions. We let the agent explore and learn about the environment, then we compare world model predictions to real observations. First row shows unseen real environment observations. Second row shows world model predictions with TT-MBRL. Third row shows world model predictions without TT-MBRL. Without test-time optimization, the model accumulates prediction errors and struggles to make accurate long-term predictions. This makes it difficult to learn an optimal policy for the actor-critic.
Original paper · CC BY 4.0Which buffer and freezing choices hold up
Sampling only test-time trajectories with no prefill helps many episodes but hurts others. The authors explain that the model overfits to limited early observations, which leads to suboptimal policies. A delay mechanism that waits for 1024 samples before learning reduces that overfitting. That delay, however, postpones the benefits of adaptation.
Mixing test-time trajectories with samples from the training replay buffer (Test+Train Data, No Prefill) acts as a regularizer. This mix mitigates early overfitting while still allowing immediate adaptation.
To check whether the gain comes from extra inference compute, the authors ran a compute-matched evaluation. That comparison used training trajectories only (Train Data Only), so the extra compute had no test-time data.
Freezing the encoder and decoder keeps the representation learned during training, while the sequential and dynamics networks carry the episode-specific information. Unfreezing them forces gradient backpropagation through the decoder and encoder, which lengthens evaluation. Memory Maze observations are 64×64 pixel images, so this cost matters most there.
The authors therefore keep freezing as the default, because it improves evaluation efficiency without sacrificing performance.
Non-memory benchmarks: no loss
DeepMind Control Suite has 20 continuous control tasks, and Atari 100k has 26 games with discrete actions. Both benchmarks are largely fully observable, so the agent doesn't need long-term memory to solve them. The authors used these benchmarks to check that test-time adaptation doesn't hurt domains built for other skills.
On DMC, the authors report mean and median scores across all 20 tasks in Table 7. The IQM rises from 0.502 to 0.514.
Overall, TT-MBRL doesn't degrade DreamerV3 on either benchmark. The gains are small, so the authors make a modest claim rather than a claim of large improvement. TT-MBRL consistently improves performance on Reacher Hard and Finger Turn Hard, where the agent occasionally fails to reach the target sphere. The authors say TT-MBRL helps the agent detect and correct such errors.
Per-task results for these tasks are in Appendix A.9.
Limitations and future work
The main limitation of TT-MBRL is evaluation cost, because gradient-based optimization runs at test time for every episode. Each evaluation episode needs its own world model and behavior policy, which adds computational cost and longer evaluation times. Freezing the encoder and decoder already cuts this cost, since unfreezing them adds gradient backpropagation through the decoder and encoder.
The authors plan to extend TT-MBRL to operate during the exploration phase, which they see as the main direction for future work. They don't test this idea in the paper, so the exploration benefit remains a hypothesis. Improving the computational efficiency of the approach is, in their view, required before it becomes practical for online adaptation during exploration.
The 400M-step R2I runs used six runs, while the other 3D rows in Table 3 used three runs with 100 episodes. The paper doesn't test whether the gains carry over to exploration or to other environments.
Paper info
- Authors
- Maxime Burchi, Fayaz Ali Dharejo, Radu Timofte
- Venue
- arXiv · Preprint
- First published
- 2026-11-6
- Added
- 2026-11-9
- Updated
- 2026-11-6
- Version
- v1
- arXiv
- 2611.09625
- Category
- cs.LG · cs.AI · cs.CV
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
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.
Quote from the paper
Maxime Burchi, Fayaz Ali Dharejo, Radu Timofte (2026). Encoding Memory in World Models with Test-Time Model-Based Reinforcement Learning. arXiv:2611.09625v1. https://arxiv.org/abs/2611.09625v1
BibTeX
@misc{burchi2026encoding,
title = {{Encoding Memory in World Models with Test-Time Model-Based Reinforcement Learning}},
author = {Maxime Burchi and Fayaz Ali Dharejo and Radu Timofte},
year = {2026},
eprint = {2611.09625},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.09625v1}
}