Policies Learned in Imagination › Latent Imagined Rollouts

Michael BrenndoerferJuly 10, 20266 min read
World Models HandbookAll chapters
Part 7 of 12Planning and Agency
Chapter 40Policies Learned in Imagination › Latent Imagined Rollouts
Reading section 2 of 10 · Latent Imagined Rollouts · 6 minSection 2 of 10 · 6 min

Book contents

Section 2 of 10 · 6 min read

Policies Learned in Imagination › Latent Imagined RolloutsOne section · Sections in this chapter2 / 10 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The first design question is what the rollout operates on. A generative pixel-level model can roll forward in observation space if it predicts action-conditioned future images and rewards. But decoding images can be expensive, while the critic may need only a compact, task-relevant summary. Reconstruction can still be useful supervision for learning that summary even when decoding is unnecessary during behavior learning.

This is where notions of model quality separate. Predictive fidelity asks whether the next-step prediction matches reality. Rollout fidelity asks whether predictions remain useful when fed back over many steps. Representation quality asks whether the latent retains information needed for control. Uncertainty quality asks whether the model signals its limitations. Decision usefulness asks whether a policy trained against it works in the real environment. These properties can diverge. Latent imagination avoids repeated decoding during behavior learning; it does not make the other properties optional.

Latent imagination sidesteps this. Building on the recurrent and transformer state-space architectures from Part V: World-Model Architectures, the world model provides an encoder, a latent transition, and a reward head. The rollout happens entirely inside the latent space:

z^t=qϕ(o≤t,a<t),z^t+1∼pθ(zt+1∣z^t,at),r^t=rψ(z^t,at).\hat z_t = q_\phi(o_{\le t}, a_{<t}), \qquad \hat z_{t+1} \sim p_\theta(z_{t+1} \mid \hat z_t, a_t), \qquad \hat r_t = r_\psi(\hat z_t, a_t).

where:

  • o≤to_{\le t}: the observation history up to and including time tt, which the encoder consumes to produce a latent
  • a<ta_{<t}: the action history before time tt, included so the encoder can account for how the current observation was reached
  • qϕq_\phi: the encoder, parameterized by ϕ\phi, that maps observations and past actions into the latent state z^t\hat z_t
  • pθp_\theta: the latent transition model, parameterized by θ\theta, which defines a distribution over the next latent state given the current latent and action
  • rψr_\psi: the reward head, parameterized by ψ\psi, that predicts the scalar reward from a latent state and action
  • z^t\hat z_t: the inferred latent state at time tt, intended to summarize the task-relevant past; whether it succeeds is empirical
  • r^t\hat r_t: the predicted reward at time tt, used as the synthetic training signal for the actor and critic

The equations resemble a classical control pipeline. The encoder qϕq_\phi is a learned state estimator, though it need not produce a calibrated sufficient belief. The transition model pθp_\theta predicts how that state evolves under control. The reward head rψr_\psi predicts a task reward supplied by the environment; it is not itself a learned preference specification. The actor and critic play the roles of controller and value estimate. Under partial observability, history or a belief estimate is generally useful, although a reactive observation policy can suffice in special tasks.

No observation needs to be decoded during these imagined actor and critic updates. The actor and critic read z^t\hat z_t, while the reward head scores (z^t,at)(\hat z_t,a_t). A decoder may still be important when learning the representation.

There are three practical reasons this matters. First, skipping a high-dimensional decoder can reduce rollout compute, depending on architecture and observation resolution. Second, gradients need not pass through a pixel decoder to reach the policy. Third, reconstruction can pressure a model to preserve visual detail irrelevant to action selection; reward and transition objectives can additionally shape the latent toward control.

The representation question is which information the controller needs. A latent can reconstruct fine visual detail yet omit a small cue that changes the right action; another can reconstruct imperfectly but retain that cue. Neither ordering is guaranteed by the loss alone. Reward and value heads can help shape what the actor extracts from the latent, while the model's training objective still determines what information reaches those heads.

The rollout is then a single vectorized loop. Starting from a batch of BB latent states, at each of HH steps:

  • Sample an action at∼πω(⋅∣z^t)a_t \sim \pi_\omega(\cdot \mid \hat z_t), where πω\pi_\omega is the policy parameterized by ω\omega.
  • Step the transition model to get z^t+1\hat z_{t+1}.
  • Score the reward r^t\hat r_t and query the critic for v^t=vξ(z^t)\hat v_t = v_\xi(\hat z_t), where vξv_\xi is the value function parameterized by ξ\xi.

Because the BB rollouts are independent, each step can be batched on a GPU. There are still HH sequential transition steps and arithmetic scaling with BHBH; batching reduces wall-clock overhead, not the amount of work. This is the concrete form of the amortization bargain: training is expensive in aggregate but parallelizable across starts.

After the loop, query the critic once more at the final latent to get a bootstrap value v^H\hat v_H. With γ=0.99\gamma=0.99 and H=20H=20, that terminal value receives weight γ20≈0.818\gamma^{20}\approx0.818. For an infinite stream of constant rewards, about 82% of the normalized discounted mass lies after the first 20 rewards. In a continuing task, omitting the bootstrap can therefore undervalue delayed payoffs.

The scale 1/(1−γ)=1001/(1-\gamma)=100 describes the geometric discount tail, not a literal cutoff. The first 20 rewards contain 1−0.9920≈18.2%1-0.99^{20}\approx18.2\% of the normalized mass for a constant stream. A terminal value estimate, as in finite-horizon dynamic programming or receding-horizon control, represents the continuing value beyond the sampled prefix. Its usefulness depends on its accuracy.

Whether the loop is differentiable matters. If the latent transition is a continuous distribution, we can sample with the reparameterization trick, z^t+1=μθ(z^t,at)+σθ(z^t,at)⊙ϵ\hat z_{t+1} = \mu_\theta(\hat z_t, a_t) + \sigma_\theta(\hat z_t, a_t) \odot \epsilon with ϵ∼N(0,I)\epsilon \sim \mathcal{N}(0, I), where μθ\mu_\theta and σθ\sigma_\theta are the mean and standard deviation predicted by the latent transition model and ⊙\odot denotes elementwise multiplication, and gradients flow straight through the model. If the latent is discrete, as in many categorical state-space models, the sample is not differentiable. The usual fixes are a straight-through estimator, which passes the gradient of a relaxed sample through a hard sample, or a gradient-free actor update that treats the dynamics as a black box. Each choice changes what the actor gradient estimator can do, which we take up next.

Differentiability determines whether an exact pathwise derivative through sampled transitions is available. Continuous reparameterized models support it directly. Discrete or discontinuous models may use a relaxation, straight-through approximation, smoothing, or score-function estimator; none is automatically robust to model error. The choice affects both gradient bias or variance and the model derivatives the actor can exploit.

Stop-Gradient on the Model

For the separate model-fitting and actor-learning setup here, exclude world-model parameters from the actor optimizer. Otherwise the actor objective also pushes the model toward favorable imagined outcomes. Joint objectives are possible, but they require explicit predictive constraints and separate validation of model accuracy.

If actor gradients could update an unconstrained reward or transition head, the optimizer could improve the reported outcome without improving behavior. That shortcut is a risk, not an inevitable unbounded trajectory: predictive losses, regularization, and head ranges can counter it. In this chapter's code the model is fitted first and frozen during actor learning, so the two objectives remain separate.