Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

Dreamer: Actor–Critic in Latent Imagination

Recurrent state-space models, imagined rollouts and DreamerV3’s robustness tricks.

Dreamer learns to act almost entirely inside its own model. That needs three things to go right at once: a latent model whose imagined states match what its filter infers from real data, an actor gradient that survives a 15-step trip through that model, and losses whose scales need no retuning for each new game. This lesson derives the recurrent state-space model's objective as an evidence lower bound, compares pathwise and REINFORCE actor gradients, proves what KL balancing and free bits do to the gradient, and dissects the transformations that let DreamerV3 run one configuration across more than 150 tasks.

What you’ll learn

  • Write the RSSM and derive its training loss as an evidence lower bound on the action-conditioned likelihood of observation sequences.
  • Derive the pathwise and score-function (REINFORCE) actor gradients, compute their variances in a Gaussian example, and explain why model-based actors use each.
  • Prove the gradient decomposition behind KL balancing, and explain free bits and categorical latents with straight-through gradients.
  • Analyze DreamerV3's symlog transform, two-hot regression and percentile return normalization, and state what its ablations and scaling results do and do not show.

The RSSM and its evidence lower bound

PlaNet (Hafner et al., 2019) introduced the recurrent state-space model (RSSM) that every Dreamer version builds on. Its state has two parts: a deterministic vector ht\mathbf h_t carried by a recurrent network (a GRU), which can remember reliably, and a stochastic vector zt\mathbf z_t, which can represent uncertainty about what comes next. PlaNet explains the split, and its ablations support it. A purely deterministic model cannot represent several possible futures and, in the paper's words, makes it easy for the planner to exploit inaccuracies; a purely stochastic one finds it hard to carry information over many steps.

sequence model:ht=fϕ(ht−1,zt−1,at−1)posterior (filter):zt∼qϕ(zt∣ht,ot)prior (transition):z^t∼pϕ(z^t∣ht)heads:pϕ(ot∣st),pϕ(rt∣st),pϕ(ct∣st),st=(ht,zt)\begin{aligned}&\text{sequence model:}&&\mathbf h_t=f_\phi(\mathbf h_{t-1},\mathbf z_{t-1},a_{t-1})\\&\text{posterior (filter):}&&\mathbf z_t\sim q_\phi(\mathbf z_t\mid\mathbf h_t,o_t)\\&\text{prior (transition):}&&\hat{\mathbf z}_t\sim p_\phi(\hat{\mathbf z}_t\mid\mathbf h_t)\\&\text{heads:}&&p_\phi(o_t\mid\mathbf s_t),\quad p_\phi(r_t\mid\mathbf s_t),\quad p_\phi(c_t\mid\mathbf s_t),\qquad\mathbf s_t=(\mathbf h_t,\mathbf z_t)\end{aligned}
The RSSM in DreamerV3's form. The posterior sees the observation oto_t; the prior must guess zt\mathbf z_t without it, and imagination runs on the prior alone. Here rtr_t and ctc_t are the reward and continuation flag that arrive together with oto_t (the papers write xtx_t for observations).
DerivationA sequence evidence lower bound
  1. pϕ(o1:T∣a1:T)=∫∏t=1Tpϕ(zt∣ht) pϕ(ot∣ht,zt) dz1:Tp_\phi(o_{1:T}\mid a_{1:T})=\int\prod_{t=1}^{T}p_\phi(\mathbf z_t\mid\mathbf h_t)\,p_\phi(o_t\mid\mathbf h_t,\mathbf z_t)\,d\mathbf z_{1:T}

    Treat rewards and continuation flags as further observations and focus on o1:To_{1:T}. Given the actions, the model's likelihood integrates over latent paths; ht\mathbf h_t is a deterministic function of z<t\mathbf z_{<t} and a<ta_{<t}:

  2. ln⁡pϕ(o1:T∣a1:T) ≥ Eq[∑t=1Tln⁡pϕ(ot∣ht,zt)+ln⁡pϕ(zt∣ht)−ln⁡qϕ(zt∣ht,ot)]\ln p_\phi(o_{1:T}\mid a_{1:T})\ \ge\ \E_q\Big[\sum_{t=1}^{T}\ln p_\phi(o_t\mid\mathbf h_t,\mathbf z_t)+\ln p_\phi(\mathbf z_t\mid\mathbf h_t)-\ln q_\phi(\mathbf z_t\mid\mathbf h_t,o_t)\Big]

    Multiply and divide by the filtering distribution q(z1:T)=∏tqϕ(zt∣ht,ot)q(\mathbf z_{1:T})=\prod_tq_\phi(\mathbf z_t\mid\mathbf h_t,o_t), which conditions only on the past and present, and apply Jensen's inequality to the concave logarithm:

  3. ln⁡pϕ(o1:T∣a1:T) ≥ ∑t=1T(Eq[ln⁡pϕ(ot∣ht,zt)]−Eq[DKL(qϕ(⋅∣ht,ot) ∥ pϕ(⋅∣ht))])\ln p_\phi(o_{1:T}\mid a_{1:T})\ \ge\ \sum_{t=1}^{T}\Big(\E_q\big[\ln p_\phi(o_t\mid\mathbf h_t,\mathbf z_t)\big]-\E_q\Big[\KL\big(q_\phi(\cdot\mid\mathbf h_t,o_t)\,\|\,p_\phi(\cdot\mid\mathbf h_t)\big)\Big]\Big)

    Take the expectation over each zt\mathbf z_t conditional on the earlier latents. The last two terms become a KL divergence between filter and transition at every step:

  4. The first sum is reconstruction, the second complexity (PlaNet's equation 3). The gap in the bound is the KL divergence from q(z1:T)q(\mathbf z_{1:T}) to the model's exact posterior over latent paths, which also conditions on future observations, so a filtering qq leaves a gap in general. It is used anyway because it is what the agent can compute online while acting. ■\blacksquare

For control, the complexity term matters more than its name suggests. It is the only loss that trains the prior, and the prior is all that imagination has. If the prior cannot predict what the filter will infer, imagined trajectories drift away from the states the actor will meet in reality, however good the reconstructions are. PlaNet also proposed latent overshooting, which trains multi-step prior predictions; its final RSSM agent did not need it, and Dreamer did not use it.

Two ways to push the actor

Behavior learning holds the world model fixed. From each filtered state the actor πθ\pi_\theta imagines HH steps, the critic vψv_\psi is regressed onto λ-returns GkλG^\lambda_k with stopped gradients, and the actor is updated to raise ∑kGkλ\sum_kG^\lambda_k. Every term of GkλG^\lambda_k depends on θ\theta through the imagined actions and states, and there are two classical ways to differentiate such an expectation.

DerivationPathwise versus score-function gradients
  1. g^SF=f(a) a−μσ2,g^PW=f′(μ+σϵ),E g^SF=E g^PW=J′(μ)\hat g_{\mathrm{SF}}=f(a)\,\frac{a-\mu}{\sigma^2},\qquad\hat g_{\mathrm{PW}}=f'(\mu+\sigma\epsilon),\qquad\E\,\hat g_{\mathrm{SF}}=\E\,\hat g_{\mathrm{PW}}=J'(\mu)

    Take the simplest case: one Gaussian action a∼N(μ,σ2)a\sim\mathcal N(\mu,\sigma^2), a return f(a)f(a), and the objective J(μ)=E[f(a)]J(\mu)=\E[f(a)]. The score-function (REINFORCE) estimator differentiates the density; the pathwise (reparameterization) estimator writes a=μ+σϵa=\mu+\sigma\epsilon with ϵ∼N(0,1)\epsilon\sim\mathcal N(0,1) and differentiates ff. Both are unbiased:

  2. Var⁡[g^PW]=0,Var⁡[g^SF]=μ2σ2+3−1=2+μ2σ2\Var\big[\hat g_{\mathrm{PW}}\big]=0,\qquad\Var\big[\hat g_{\mathrm{SF}}\big]=\frac{\mu^2}{\sigma^2}+3-1=2+\frac{\mu^2}{\sigma^2}

    Let f(a)=af(a)=a, so J′(μ)=1J'(\mu)=1. The pathwise estimate equals 1 for every sample. The score-function estimate is (μ+σϵ)ϵ/σ=μϵ/σ+ϵ2(\mu+\sigma\epsilon)\epsilon/\sigma=\mu\epsilon/\sigma+\epsilon^2; with Eϵ3=0\E\epsilon^3=0 and Eϵ4=3\E\epsilon^4=3:

  3. A baseline helps but cannot close the gap: with the ideal baseline b=f(μ)b=f(\mu) the estimator (f(a)−b)(a−μ)/σ2=ϵ2(f(a)-b)(a-\mu)/\sigma^2=\epsilon^2 still has variance 2. In an actor–critic the critic plays the baseline's role: the advantage Gkλ−vψ(sk)G^\lambda_k-v_\psi(\mathbf s_k) multiplies ∇θln⁡πθ(ak∣sk)\nabla_\theta\ln\pi_\theta(a_k\mid\mathbf s_k).

  4. Pathwise gradients need f′f', and in imagination f′f' is the derivative of the learned model's rewards and transitions, chained through up to HH steps. A model can predict values well and still have wrong or exploding derivatives, and a pathwise actor follows them: low variance is bought with a bias toward the model's errors. REINFORCE uses only the values of returns, so it is unbiased with respect to the model's predictions, but noisy.

Predict before you look

For f(a)=af(a)=a with μ=3\mu=3, σ=1\sigma=1 and no baseline, what is the variance of a single-sample score-function estimate of J′(μ)=1J'(\mu)=1?

Show the answer

11

2+μ2/σ2=2+9=112+\mu^2/\sigma^2=2+9=11: the estimate's standard deviation is about 3.3 times the gradient it estimates, while the pathwise estimate is exact. Subtracting the baseline f(μ)=3f(\mu)=3 brings the variance down to 2.

The Dreamer versions chose differently. Dreamer backpropagated GλG^\lambda through reparameterized actions and latent states, with straight-through gradients for discrete actions. DreamerV2 mixed the two estimators with a weight ρ\rho and found REINFORCE substantially better on Atari (ρ=1\rho=1, entropy weight η=10−3\eta=10^{-3}) and backpropagation through the dynamics substantially better for continuous control (ρ=0\rho=0, η=10−4\eta=10^{-4}). DreamerV3's preprint kept that split; its published version uses REINFORCE for both discrete and continuous actions.

L(θ)=E∑k[−ρ ln⁡πθ(ak∣sk) sg⁡(Gkλ−vψ(sk))−(1−ρ) Gkλ−η H[πθ(⋅∣sk)]]\mathcal L(\theta)=\E\sum_{k}\Big[-\rho\,\ln\pi_\theta(a_k\mid\mathbf s_k)\,\operatorname{sg}\big(G^\lambda_k-v_\psi(\mathbf s_k)\big)-(1-\rho)\,G^\lambda_k-\eta\,\mathcal H\big[\pi_\theta(\cdot\mid\mathbf s_k)\big]\Big]
DreamerV2's actor loss (minimized). The first term is REINFORCE with the critic as baseline; the second backpropagates the λ-return through the model; the third is an entropy bonus. sg⁡\operatorname{sg} stops gradients.

Categorical latents, KL balancing and free bits

DreamerV2 replaced the Gaussian zt\mathbf z_t with 32 categorical variables of 32 classes each, so a sample is a sparse binary vector of length 1,024 with 32 ones. Sampling a category is not differentiable, so gradients pass by the straight-through estimator: the one-hot sample is used in the forward pass and the gradient of the probabilities in the backward pass.

python
import torch
import torch.nn.functional as F

def sample_latent(logits, unimix=0.01):
    """logits: (..., 32, 32). One-hot samples with straight-through gradients."""
    probs = F.softmax(logits, dim=-1)
    probs = (1 - unimix) * probs + unimix / probs.shape[-1]   # DreamerV3: 1% uniform mixture
    idx = torch.distributions.Categorical(probs=probs).sample()
    onehot = F.one_hot(idx, probs.shape[-1]).to(probs.dtype)
    return onehot + probs - probs.detach()   # value: the one-hot; gradient: that of probs

DreamerV2's straight-through trick (its Algorithm 1) with DreamerV3's "unimix": mixing in 1% of a uniform distribution keeps every class's probability at least 0.01/320.01/32, so log-probabilities and KL divergences cannot blow up.

Categorical latents beat Gaussian ones on 42 of 55 Atari games in DreamerV2's ablation (worse on 8, tied on 5). The authors offered hypotheses rather than an explanation: a mixture of categoricals is again categorical, so the prior can match the aggregate posterior; sparsity may help generalization; straight-through gradients may be easier to optimize; and discrete latents may suit discrete events such as entering a new room. Which of these matters is still unsettled. The KL term changed too.

DerivationProof
  1. ∇ϕDKL(qϕ ∥ pϕ)=∂ϕ2F⏟∇ϕprior+∂ϕ1F⏟∇ϕpost\nabla_\phi\KL(q_\phi\,\|\,p_\phi)=\underbrace{\partial_{\phi_2}F}_{\nabla^{\mathrm{prior}}_\phi}+\underbrace{\partial_{\phi_1}F}_{\nabla^{\mathrm{post}}_\phi}

    Write F(ϕ1,ϕ2)=DKL(qϕ1 ∥ pϕ2)F(\phi_1,\phi_2)=\KL(q_{\phi_1}\,\|\,p_{\phi_2}) and evaluate at ϕ1=ϕ2=ϕ\phi_1=\phi_2=\phi. By the multivariable chain rule the total derivative is the sum of the two partial derivatives:

  2. A stop-gradient freezes one argument: DKL(sg⁡(qϕ) ∥ pϕ)\KL(\operatorname{sg}(q_\phi)\,\|\,p_\phi) has value FF and gradient ∂ϕ2F\partial_{\phi_2}F, and DKL(qϕ ∥ sg⁡(pϕ))\KL(q_\phi\,\|\,\operatorname{sg}(p_\phi)) has value FF and gradient ∂ϕ1F\partial_{\phi_1}F. Mixing them with weights α\alpha and 1−α1-\alpha gives value FF and gradient α ∂ϕ2F+(1−α) ∂ϕ1F\alpha\,\partial_{\phi_2}F+(1-\alpha)\,\partial_{\phi_1}F. ■\blacksquare

  3. The two parts do different jobs. The prior part moves the prior toward the posterior: better predictions. The posterior part moves the posterior toward the prior, which can lower the KL by throwing information away. DreamerV2 used α=0.8\alpha=0.8, so the prior learns four times faster than the posterior is regularized; KL balancing beat the plain KL on 44 of 55 games (worse on 6, tied on 5).

L(ϕ)=Eq∑t[βpred Lpred+βdynmax⁡(1,DKL[sg⁡(qϕ) ∥ pϕ])+βrepmax⁡(1,DKL[qϕ ∥ sg⁡(pϕ)])]\mathcal L(\phi)=\E_q\sum_{t}\Big[\beta_{\mathrm{pred}}\,\mathcal L_{\mathrm{pred}}+\beta_{\mathrm{dyn}}\max\big(1,\KL[\operatorname{sg}(q_\phi)\,\|\,p_\phi]\big)+\beta_{\mathrm{rep}}\max\big(1,\KL[q_\phi\,\|\,\operatorname{sg}(p_\phi)]\big)\Big]
DreamerV3 writes the same split as two losses, each clipped below by free bits. Lpred\mathcal L_{\mathrm{pred}} is the negative log-likelihood of observation, reward and continuation, and KLs are in nats. The published version uses βpred=1\beta_{\mathrm{pred}}=1, βdyn=1\beta_{\mathrm{dyn}}=1, βrep=0.1\beta_{\mathrm{rep}}=0.1 (the preprint had βdyn=0.5\beta_{\mathrm{dyn}}=0.5). Below 1 nat, max⁡(1,⋅)\max(1,\cdot) is constant and passes no gradient: once the posterior is within a nat of the prior, the KL stops pulling and the model concentrates on its predictions. This prevents the degenerate solution in which the latents are easy to predict because they say little about the input.
Predict before you look

Above the free-bits threshold, DreamerV3's published weights βdyn=1\beta_{\mathrm{dyn}}=1 and βrep=0.1\beta_{\mathrm{rep}}=0.1 act like KL balancing with which α\alpha, after rescaling the total?

Show the answer

0.909

α=βdyn/(βdyn+βrep)=1/1.1≈0.909\alpha=\beta_{\mathrm{dyn}}/(\beta_{\mathrm{dyn}}+\beta_{\mathrm{rep}})=1/1.1\approx0.909: the prior is trained ten times harder than the posterior is regularized. The preprint's 0.5 and 0.1 give α≈0.83\alpha\approx0.83, close to DreamerV2's 0.8.

DreamerV3: transformations instead of tuning

Fixed hyperparameters fail across domains mostly through scales: rewards of 0.01 in one task and 10,000 in another, observation vectors with large entries, returns that are sparse here and dense there. DreamerV3 handles each scale problem with a transformation rather than a constant tuned per domain.

DerivationSymlog and two-hot regression
  1. symlog⁡(x)=sign⁡(x) ln⁡(1+∣x∣),symexp⁡(x)=sign⁡(x)(e∣x∣−1)\operatorname{symlog}(x)=\sign(x)\,\ln\big(1+\abs x\big),\qquad\operatorname{symexp}(x)=\sign(x)\big(e^{\abs x}-1\big)

    Symlog. Predict a transformed target and invert the transformation when reading the prediction out:

  2. symlog⁡(106)=ln⁡(1,000,001)≈13.8\operatorname{symlog}(10^6)=\ln(1{,}000{,}001)\approx13.8

    Near zero, ln⁡(1+u)=u−u2/2+O(u3)\ln(1+u)=u-u^2/2+\order{u^3}, so symlog⁡(x)=x−12x∣x∣+O(x3)\operatorname{symlog}(x)=x-\tfrac12x\abs x+\order{x^3} and small targets are almost unchanged. For large ∣x∣\abs x it grows like ln⁡∣x∣\ln\abs x, and its derivative 1/(1+∣x∣)1/(1+\abs x) shrinks the gradients of huge targets: a squared error on symlog targets turns a miss of 10610^6 into a loss of about 13.82≈19113.8^2\approx191 instead of 101210^{12}. DreamerV3 symlogs vector observations at the encoder's input and as the decoder's targets.

  3. wk=bk+1−ybk+1−bk,wk+1=y−bkbk+1−bk,wkbk+wk+1bk+1=yw_k=\frac{b_{k+1}-y}{b_{k+1}-b_k},\qquad w_{k+1}=\frac{y-b_k}{b_{k+1}-b_k},\qquad w_kb_k+w_{k+1}b_{k+1}=y

    Two-hot regression. For rewards and values the network outputs a softmax p\mathbf p over fixed bins b1<⋯<bKb_1<\dots<b_K, exponentially spaced (symexp⁡\operatorname{symexp} of equally spaced points in [−20,20][-20,20]), and predicts y^=∑ipibi\hat y=\sum_ip_ib_i. This is the published version; the preprint applied the same construction to the symlog of the target, with K=255K=255 equally spaced bins, and read out symexp⁡(∑ipibi)\operatorname{symexp}\big(\sum_ip_ib_i\big). A target yy with bk≤y≤bk+1b_k\le y\le b_{k+1} is encoded as weights on its two neighboring bins:

  4. So the two-hot vector's mean is exactly the target, and the loss is the cross-entropy −∑iwiln⁡pi-\sum_iw_i\ln p_i. Its gradient with respect to the logits is p−w\mathbf p-\mathbf w, every entry between −1-1 and 11 whatever the size of yy: the scale of the gradient no longer depends on the scale of the target. The predicted distribution can also be bimodal, which suits sparse rewards whose returns are often either zero or large.

J(θ)=E∑k[sg⁡(Gkλ−vψ(sk)max⁡(1,S))ln⁡πθ(ak∣sk)+η H[πθ(⋅∣sk)]],S=EMA⁡(Per⁡95(Gλ)−Per⁡5(Gλ), 0.99)\mathcal J(\theta)=\E\sum_k\Big[\operatorname{sg}\Big(\frac{G^\lambda_k-v_\psi(\mathbf s_k)}{\max(1,S)}\Big)\ln\pi_\theta(a_k\mid\mathbf s_k)+\eta\,\mathcal H\big[\pi_\theta(\cdot\mid\mathbf s_k)\big]\Big],\qquad S=\operatorname{EMA}\big(\operatorname{Per}_{95}(G^\lambda)-\operatorname{Per}_{5}(G^\lambda),\ 0.99\big)
Return normalization: the published DreamerV3 actor objective (maximized), with entropy weight η=3×10−4\eta=3\times10^{-4}. SS is the spread between the 5th and 95th percentiles of the batch's λ-returns, smoothed by an exponential moving average with decay 0.99.

The floor max⁡(1,S)\max(1,S) is the point. With dense rewards the returns might span 100 to 900; dividing by S=800S=800 brings advantages to order one, where η=3×10−4\eta=3\times10^{-4} is a gentle exploration bonus. With sparse rewards the returns might all lie between 0 and 0.05; dividing by S=0.05S=0.05 would multiply the noise in those near-zero returns by twenty and drown the entropy term, making the policy deterministic before it has found any reward. With the floor they are left unscaled, and the entropy bonus keeps the policy exploring. Percentiles rather than the minimum and maximum keep a few unusually easy episodes from shrinking everyone else's advantages.

DreamerV3 componentProblem it addresses
Symlog inputs and decoder targetsLarge vector observations and reconstruction gradients
Two-hot reward and criticReward and return scales that vary by orders of magnitude; multimodal returns
KL balancing with free bitsLatents too informative to predict, or too predictable to inform
Unimix categoricals (1% uniform)KL spikes from near-deterministic distributions
Return normalization floored at 1Exploring under sparse rewards without hurting dense ones
Critic regularized toward its own moving average; zero-initialized output weightsUnstable bootstrapped targets; spurious large predictions early in training
DreamerV3's ablations on 14 tasks found that every technique contributed, most of all the world model's KL objective, then return normalization and two-hot regression, and that each was critical on some tasks while not affecting others.

What the evidence shows

With these changes DreamerV3 ran one configuration across 8 domains (Atari, ProcGen, DMLab, Atari 100k, continuous control from proprioception and from pixels, BSuite and Minecraft), and its authors report that it outperformed specialized, tuned methods across more than 150 tasks. Three further findings matter for the field.

  • Scaling. Six model sizes from 12M to 400M parameters trained robustly with the same hyperparameters. Larger models reached higher scores and needed fewer environment interactions, and higher replay ratios predictably improved performance.
  • The world model does most of the work. Stopping the task-specific reward and value gradients from shaping the representation mattered less than stopping the reconstruction gradients; in the authors' words, Dreamer "rests predominantly on the unsupervised objective of its world model". DreamerV2's ablation had pointed the same way: blocking image gradients hurt 51 of 55 Atari games.
  • Minecraft. Diamonds from scratch with one GPU for 9 days, where VPT, which also used human demonstrations, trained on 720 GPUs for 9 days; with faster block breaking, as noted in the Bootstrapping lesson.

Key takeaways

  • The RSSM splits the state into a deterministic memory ht\mathbf h_t and a stochastic zt\mathbf z_t. Its loss is a sequence ELBO, reconstruction minus a per-step KL between filter and prior, and that KL is the only signal that trains the prior used in imagination.
  • Pathwise actor gradients have low variance but follow the learned model's derivatives; REINFORCE with a critic baseline is unbiased with respect to the model but noisy (variance 2+μ2/σ22+\mu^2/\sigma^2 against 0 in the Gaussian example). DreamerV2 chose per domain; published DreamerV3 uses REINFORCE throughout.
  • KL balancing is the chain rule made explicit: the KL's gradient is a prior part plus a posterior part, which DreamerV2 weights 0.8 and 0.2; free bits switch both off below 1 nat.
  • DreamerV3 removes scale sensitivity with transformations instead of tuned constants: symlog targets, two-hot classification whose gradient is bounded whatever the target, and return normalization by a percentile range floored at 1.
  • The evidence: one configuration across more than 150 tasks, gains from larger models and higher replay ratios, a world-model objective that carries most of the learning, and diamonds in a modified Minecraft. Why categorical latents help, and any theory for the whole system, remain open.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

DreamerV2 uses KL balancing with α=0.8\alpha=0.8. What does the larger weight do?

  1. It regularizes the posterior four times harder than it trains the prior
  2. It changes the value of the KL loss reported during training
  3. It trains the prior toward the posterior four times faster than it pulls the posterior toward the prior
  4. It increases the number of classes per latent variable
Show the answer

C. It trains the prior toward the posterior four times faster than it pulls the posterior toward the prior

The balanced loss has the value of the plain KL but the gradient 0.8 ∇prior+0.2 ∇post0.8\,\nabla^{\mathrm{prior}}+0.2\,\nabla^{\mathrm{post}}. Training the prior harder favors better predictions over discarding information from the posterior, and it beat the plain KL on 44 of 55 Atari games.

Question 2

What does clipping DreamerV3's KL losses below 1 nat (free bits) accomplish?

  1. Once the posterior is within 1 nat of the prior, the KL terms pass no gradient, so the model stops trading information about its input for predictability
  2. It guarantees that the prior matches the posterior exactly
  3. It caps the reconstruction loss
  4. It makes the KL divergence symmetric
Show the answer

A. Once the posterior is within 1 nat of the prior, the KL terms pass no gradient, so the model stops trading information about its input for predictability

max⁡(1,DKL)\max(1,\KL) is constant below 1 nat, so its gradient vanishes there and only the prediction loss shapes the latents. That prevents the degenerate solution in which latents are easy to predict because they say little about the observations.

Question 3

In a sparse-reward task, every imagined λ-return in a batch lies between 0 and 0.05. What does DreamerV3's return normalization do to the advantages?

  1. Divides them by about 0.05, multiplying them by twenty
  2. Sets them to zero until a reward is found
  3. Divides them by their standard deviation
  4. Leaves them unscaled, because max⁡(1,S)=1\max(1,S)=1, so the fixed entropy bonus keeps the policy exploring
Show the answer

D. Leaves them unscaled, because max⁡(1,S)=1\max(1,S)=1, so the fixed entropy bonus keeps the policy exploring

The divisor is max⁡(1,S)\max(1,S) with SS the smoothed 5th-to-95th-percentile range. Small returns are never scaled up, which would amplify their noise and drown the entropy term; large ones are scaled down to order one.

Question 4

A world model predicts returns accurately along the data, but its derivatives with respect to actions are badly wrong. Which actor update is directly affected?

  1. REINFORCE with a critic baseline
  2. The pathwise update that backpropagates the λ-return through the model
  3. Neither, since both use only predicted returns
  4. Both equally
Show the answer

B. The pathwise update that backpropagates the λ-return through the model

The pathwise gradient is built from the model's derivatives, chained through the imagined trajectory, so wrong derivatives give wrong updates even when the values are right. REINFORCE multiplies the score of the sampled action by a return, using values only.

Further reading

  • D. Hafner, T. Lillicrap, I. Fischer, R. Villegas, D. Ha, H. Lee & J. Davidson, "Learning latent dynamics for planning from pixels," ICML (2019).
  • D. Hafner, T. Lillicrap, J. Ba & M. Norouzi, "Dream to control: learning behaviors by latent imagination," ICLR (2020).
  • D. Hafner, T. Lillicrap, M. Norouzi & J. Ba, "Mastering Atari with discrete world models," ICLR (2021).
  • D. Hafner, J. Pasukonis, J. Ba & T. Lillicrap, "Mastering diverse control tasks through world models," Nature 640, 647–653 (2025); preprint "Mastering diverse domains through world models," arXiv:2301.04104 (2023).
  • S. Mohamed, M. Rosca, M. Figurnov & A. Mnih, "Monte Carlo gradient estimation in machine learning," Journal of Machine Learning Research 21 (2020).