Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

Model Errors & Value-Equivalent Models

Compounding errors, the simulation lemma, and models that only need to get values right.

A model can be wrong about half of everything it predicts and still be perfect for planning, or nearly right everywhere and still mislead the planner. This lesson makes precise what model error costs: an exact identity for the value error, how errors compound along rollouts, why maximum likelihood trains the model on the wrong objective, and the value-equivalence principle, which asks a model to get only values right.

What you’ll learn

  • Prove the simulation lemma in occupancy form, and derive from it the classical sup-norm bound with its (1−γ)−2(1-\gamma)^{-2} compounding factor.
  • Bound how predicted state distributions drift over kk model steps: linearly in total variation, and geometrically in Wasserstein distance for expanding Lipschitz dynamics.
  • Explain objective mismatch, and derive why maximum-likelihood training controls value error only loosely while value-aware losses target it directly.
  • State value equivalence and proper value equivalence, and prove that a model proper-value-equivalent for all deterministic policies plans optimally.

An exact formula for value error

DerivationProof by telescoping inside the model
  1. J^(π)−J(π)=E^[∑t≥0γt(r^(St,At)+γVπ(St+1)−Vπ(St))]\hat J(\pi)-J(\pi)=\hat\E\Big[\sum_{t\ge0}\gamma^t\Big(\hat r(S_t,A_t)+\gamma V^\pi(S_{t+1})-V^\pi(S_t)\Big)\Big]

    Run π\pi in the model from S0∼μS_0\sim\mu and add a telescoping sum of true values, which collapses to −Vπ(S0)-V^\pi(S_0) because VπV^\pi is bounded and γ<1\gamma<1. Writing E^\hat\E for expectations along model trajectories:

  2. E^[r^(St,At)+γVπ(St+1)−Vπ(St)]=E^[r^(St,At)−r(St,At)+γ(P^−P)(⋅∣St,At)⊤Vπ]\hat\E\Big[\hat r(S_t,A_t)+\gamma V^\pi(S_{t+1})-V^\pi(S_t)\Big]=\hat\E\Big[\hat r(S_t,A_t)-r(S_t,A_t)+\gamma\big(\hat P-P\big)(\cdot\mid S_t,A_t)^{\top}V^\pi\Big]

    Condition on (St,At)=(s,a)(S_t,A_t)=(s,a). In the model St+1∼P^(⋅∣s,a)S_{t+1}\sim\hat P(\cdot\mid s,a), and the environment's Bellman equation, averaged over At∼π(⋅∣St)A_t\sim\pi(\cdot\mid S_t), replaces Vπ(St)V^\pi(S_t) by r(St,At)+γP(⋅∣St,At)⊤Vπr(S_t,A_t)+\gamma P(\cdot\mid S_t,A_t)^\top V^\pi in expectation. Each term becomes a one-step error:

  3. Sum over tt with weights γt\gamma^t and group the terms by the pair visited; by definition ∑tγtPr⁡^π(St=s,At=a)=d^μπ(s,a)/(1−γ)\sum_t\gamma^t\widehat{\Pr}_\pi(S_t=s,A_t=a)=\hat d^\pi_\mu(s,a)/(1-\gamma), which gives the identity. ■\blacksquare

The identity says three things. Only the projection onto VπV^\pi matters: an error in P^\hat P that VπV^\pi cannot see costs nothing. Exploitation is built in: the average runs over d^μπ\hat d^\pi_\mu, and a planner that maximizes J^\hat J steers that occupancy toward pairs where the bracket is positive, where the model overrates the future. The classical bound follows. Because (P^−P)⊤1=0(\hat P-P)^\top\mathbf 1=0, any constant can be subtracted from VπV^\pi first; choosing the midpoint of its range gives ∣(P^−P)⊤Vπ∣≤TV(P^(⋅∣s,a),P(⋅∣s,a))⋅span⁡(Vπ)\abs{(\hat P-P)^\top V^\pi}\le\mathrm{TV}\big(\hat P(\cdot\mid s,a),P(\cdot\mid s,a)\big)\cdot\operatorname{span}(V^\pi), where TV\mathrm{TV} is half the L1L_1 distance and span⁡(Vπ)≤Rmax⁡/(1−γ)\operatorname{span}(V^\pi)\le R_{\max}/(1-\gamma) when rewards lie in [0,Rmax⁡][0,R_{\max}].

∣J^(π)−J(π)∣ ≤ εr1−γ+γ εTV Rmax⁡(1−γ)2,εr=max⁡s,a∣r^−r∣,εTV=max⁡s,aTV(P^(⋅∣s,a),P(⋅∣s,a))\abs{\hat J(\pi)-J(\pi)}\ \le\ \frac{\varepsilon_r}{1-\gamma}+\frac{\gamma\,\varepsilon_{\mathrm{TV}}\,R_{\max}}{(1-\gamma)^2},\qquad\varepsilon_r=\max_{s,a}\abs{\hat r-r},\quad\varepsilon_{\mathrm{TV}}=\max_{s,a}\mathrm{TV}\big(\hat P(\cdot\mid s,a),P(\cdot\mid s,a)\big)
The simulation lemma of Kearns & Singh (2002), with the constant sharpened by centering. One factor 1/(1−γ)1/(1-\gamma) counts the steps over which errors occur, the other is the range of values an error can redirect: that is compounding. Planning in the model then loses at most twice this bound, since J(π⋆)−J(π^)≤[J(π⋆)−J^(π⋆)]+[J^(π^)−J(π^)]J(\pi^\star)-J(\hat\pi)\le[J(\pi^\star)-\hat J(\pi^\star)]+[\hat J(\hat\pi)-J(\hat\pi)] for a model-optimal π^\hat\pi.
Predict before you look

Rewards are known exactly and lie in [0,1][0,1], γ=0.99\gamma=0.99, and every transition distribution is off by total variation 0.010.01. What does the bound give for ∣J^(π)−J(π)∣\abs{\hat J(\pi)-J(\pi)}?

Show the answer

99

γ εTVRmax⁡/(1−γ)2=0.99×0.01/0.0001=99\gamma\,\varepsilon_{\mathrm{TV}}R_{\max}/(1-\gamma)^2=0.99\times0.01/0.0001=99, while returns lie in [0,100][0,100]: the guarantee is nearly vacuous. A 1% per-step error is not small at an effective horizon of 100 steps. The occupancy form explains why practice is often kinder: errors that are orthogonal to VπV^\pi, or that sit where d^π\hat d^\pi puts little mass, cost nothing.

Compounding: how rollouts drift

Dyna-style methods rarely roll out to the end of the episode: they branch kk steps from states the agent has really visited. The relevant question is then how far the model's kk-step state distribution drifts from the true one. Let ν0\nu_0 be a start distribution, νk\nu_k the true distribution after kk steps of π\pi and ν^k\hat\nu_k the model's.

DerivationProof of (a), and the recursion behind (b)
  1. νk+1−ν^k+1=(νk−ν^k)Pπ+ν^k(Pπ−P^π)\nu_{k+1}-\hat\nu_{k+1}=\big(\nu_k-\hat\nu_k\big)P^\pi+\hat\nu_k\big(P^\pi-\hat P^\pi\big)

    Write distributions as row vectors and Pπ(s,⋅)=∑aπ(a∣s)P(⋅∣s,a)P^\pi(s,\cdot)=\sum_a\pi(a\mid s)P(\cdot\mid s,a). Add and subtract ν^kPπ\hat\nu_kP^\pi:

  2. TV(νk+1,ν^k+1)≤TV(νk,ν^k)+ε⟹TV(νk,ν^k)≤kε\mathrm{TV}(\nu_{k+1},\hat\nu_{k+1})\le\mathrm{TV}(\nu_k,\hat\nu_k)+\varepsilon\quad\Longrightarrow\quad\mathrm{TV}(\nu_k,\hat\nu_k)\le k\varepsilon

    A Markov kernel never increases total variation, so the first term has TV at most TV(νk,ν^k)\mathrm{TV}(\nu_k,\hat\nu_k). Each row of the second differs by at most 2ε2\varepsilon in L1L_1 (average the per-action errors over π\pi), so its TV is at most ε\varepsilon. Starting from ν0=ν^0\nu_0=\hat\nu_0:

  3. Wn≤Δ+Kˉ Wn−1⟹Wn≤Δ(1+Kˉ+⋯+Kˉ n−1)=Δ Kˉ n−1Kˉ−1W_n\le\Delta+\bar K\,W_{n-1}\quad\Longrightarrow\quad W_n\le\Delta\big(1+\bar K+\dots+\bar K^{\,n-1}\big)=\Delta\,\frac{\bar K^{\,n}-1}{\bar K-1}

    In Wasserstein distance the inherited error is not merely carried along but stretched: a KK-Lipschitz kernel can multiply the distance between two distributions by KK. The same decomposition then gives a recursion whose solution is geometric, and taking whichever model's constant is smaller gives Kˉ\bar K:

Predict before you look

A model's one-step Wasserstein error is Δ=0.01\Delta=0.01 and the smaller Lipschitz constant is Kˉ=1.1\bar K=1.1, slightly expanding dynamics. What does the bound give for the error after n=20n=20 steps?

Show the answer

0.57

Δ(Kˉ20−1)/(Kˉ−1)=0.01×(6.727−1)/0.1≈0.573\Delta(\bar K^{20}-1)/(\bar K-1)=0.01\times(6.727-1)/0.1\approx0.573, almost three times the 20Δ=0.220\Delta=0.2 that linear accumulation would give. At n=50n=50 it is about 11.611.6, more than a thousand times Δ\Delta. With Kˉ<1\bar K<1 the sum instead stays below Δ/(1−Kˉ)\Delta/(1-\bar K): contracting dynamics forget errors, expanding ones amplify them.

Both bounds assume the model is accurate on every input. A learned model is accurate on its training distribution, and a rollout feeds it its own predictions, which drift off that distribution: the same covariate shift that undoes behavior cloning (Compounding Errors & Interactive Imitation). Training procedures respond in kind. Hallucinated replay (Talvitie, 2014) trains the model to correct itself when it produces errors, by feeding it its own sampled predictions and asking for the true next state; Talvitie (2017) reports that this ability to self-correct is more tightly related to model-based RL performance than one-step prediction error. Data as Demonstrator (Venkatraman, Hebert & Bagnell, 2015) casts multi-step prediction as imitation learning: the model's own predicted states become training inputs and the recorded continuation the target, in the spirit of DAgger.

Objective mismatch and value-aware losses

The standard recipe fits P^\hat P by maximum likelihood on observed transitions and then plans. The model is thus trained on one objective, predicting next states, and used for another, choosing actions that earn return. Lambert, Amos, Yadan and Calandra (2020) named this objective mismatch and showed that the likelihood of one-step predictions is not always correlated with control performance: a model that serves a task well need not be accurate everywhere, and an accurate-looking model can serve it badly. How loosely are the two objectives tied?

DerivationWhat maximum likelihood controls
  1. ∣(P^−P)(⋅∣s,a)⊤V∣≤∥V∥∞ ∥P^(⋅∣s,a)−P(⋅∣s,a)∥1≤∥V∥∞2 DKL(P(⋅∣s,a) ∥ P^(⋅∣s,a))\big|(\hat P-P)(\cdot\mid s,a)^\top V\big|\le\norm V_\infty\,\big\lVert\hat P(\cdot\mid s,a)-P(\cdot\mid s,a)\big\rVert_1\le\norm V_\infty\sqrt{2\,\KL\big(P(\cdot\mid s,a)\,\|\,\hat P(\cdot\mid s,a)\big)}

    Fix a pair (s,a)(s,a) and a bounded function VV. Hölder's inequality and then Pinsker's inequality, ∥p−q∥1≤2DKL(p ∥ q)\norm{p-q}_1\le\sqrt{2\KL(p\,\|\,q)}, give

  2. ED∣(P^−P)⊤V∣≤∥V∥∞2 EDDKL(P ∥ P^),EDDKL(P ∥ P^)=ED[−log⁡P^(S′∣S,A)]−ED[H(P(⋅∣S,A))]\E_D\big|(\hat P-P)^\top V\big|\le\norm V_\infty\sqrt{2\,\E_D\KL(P\,\|\,\hat P)},\qquad\E_D\KL(P\,\|\,\hat P)=\E_D\big[-\log\hat P(S'\mid S,A)\big]-\E_D\big[\mathcal H\big(P(\cdot\mid S,A)\big)\big]

    Average over the data distribution DD of pairs and apply Jensen's inequality to the concave square root. The expected KL divergence equals the negative log-likelihood minus an entropy that does not depend on P^\hat P, so maximum likelihood minimizes exactly the quantity under the root:

  3. So likelihood does control value error, but loosely, through a square root and a worst case over every bounded VV, and indiscriminately: it pays as much for the flicker of a screen in the background of a camera image as for the position of the ball the robot must catch. It also weights errors by the data distribution DD, while the simulation lemma weights them by where the policy goes in the model.

The value-equivalence principle

DerivationProof of the corollary
  1. vπ~=v~π~v_{\tilde\pi}=\tilde v_{\tilde\pi}

    Let the model be PVE for Πdet⁡\Pi_{\det} and let π~\tilde\pi be optimal in the model; in a finite MDP it can be chosen deterministic, so PVE applies to it:

  2. vπ=v~π≤v~π~=vπ~v_\pi=\tilde v_\pi\le\tilde v_{\tilde\pi}=v_{\tilde\pi}

    For any deterministic π\pi, PVE and the optimality of π~\tilde\pi in the model give, state by state,

  3. v⋆=vπ⋆≤vπ~v^\star=v_{\pi^\star}\le v_{\tilde\pi}

    The environment has a deterministic optimal policy π⋆\pi^\star, so take π=π⋆\pi=\pi^\star: v⋆≤vπ~v^\star\le v_{\tilde\pi}, and π~\tilde\pi is optimal. ■\blacksquare The condition is sufficient, not necessary: the flicker-bit model is not PVE for policies that condition on bb, yet it plans optimally.

This is the theory behind MuZero, whose model is trained only to predict rewards, values and policies along observed action sequences, never observations. Grimm et al. (2021) show that, under a mild smoothness condition, minimizing MuZero's loss minimizes an upper bound on a squared PVE loss with respect to a single policy, the one that generated the data. MuZero learns a value-equivalent model of the behavior it has seen, not of the world (MuZero: Planning with a Learned Model).

Think first If value equivalence is all planning needs, why not always learn the smallest value-equivalent model?

Because the sets Π\Pi and V\mathcal V are not known in advance. A model that is value equivalent only for the policies seen so far says nothing reliable about the policy that planning will produce next, which is exactly where the simulation lemma's d^π\hat d^\pi wanders. A model that is value equivalent for one reward function is useless for a new task. And value-equivalent states need not mean anything, which complicates exploration, transfer and inspection. Richer prediction targets buy robustness to these shifts at the price of modeling more than the current task needs.

Key takeaways

  • Simulation lemma, occupancy form: J^(π)−J(π)=11−γEd^μπ[r^−r+γ(P^−P)⊤Vπ]\hat J(\pi)-J(\pi)=\frac{1}{1-\gamma}\E_{\hat d^\pi_\mu}\big[\hat r-r+\gamma(\hat P-P)^\top V^\pi\big]. Errors count only through VπV^\pi and only where the policy goes in the model.
  • Centering gives the classical bound εr/(1−γ)+γεTVRmax⁡/(1−γ)2\varepsilon_r/(1-\gamma)+\gamma\varepsilon_{\mathrm{TV}}R_{\max}/(1-\gamma)^2: per-step error, times horizon, times value range.
  • Rollout distributions drift at most kεk\varepsilon in total variation, but in Wasserstein distance a Lipschitz constant Kˉ>1\bar K>1 amplifies errors geometrically, Δ(Kˉ n−1)/(Kˉ−1)\Delta(\bar K^{\,n}-1)/(\bar K-1).
  • Maximum likelihood bounds value error only through ∥V∥∞2 EDKL\norm V_\infty\sqrt{2\,\E\KL}, for every VV at once and on the data distribution: objective mismatch. Value-aware losses weight model errors by the value functions that matter.
  • Value equivalence asks a model to reproduce Bellman updates, not observations; a model proper-value-equivalent for all deterministic policies plans optimally, and MuZero's loss bounds a PVE loss for the data-generating policy.

Check yourself

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

Question 1

Which property of a model guarantees that an optimal policy computed in the model is optimal in the environment?

  1. Total-variation error below 0.010.01 at every state–action pair
  2. Maximum-likelihood training on a very large dataset
  3. Proper value equivalence with respect to all deterministic policies
  4. Value equivalence with respect to the policy that generated the data
Show the answer

C. Proper value equivalence with respect to all deterministic policies

If every deterministic policy has the same value in the model as in the environment, the model's optimal deterministic policy is at least as good as the environment's optimal one. Small TV error only bounds the loss, by an amount that can be large at long horizons, and equivalence for one policy says nothing about others.

Question 2

In the occupancy form of the simulation lemma, the one-step model errors are averaged over which distribution?

  1. The distribution of the training data
  2. The occupancy measure of π\pi in the true environment
  3. The uniform distribution over state–action pairs
  4. The occupancy measure of π\pi inside the model
Show the answer

D. The occupancy measure of π\pi inside the model

Telescoping runs along model trajectories, so the weights are d^μπ\hat d^\pi_\mu. That is the formal face of model exploitation: optimizing J^\hat J moves d^μπ\hat d^\pi_\mu toward the pairs where the model overestimates, even if those pairs are rare in the data.

Question 3

Two learned models have the same tiny one-step error. One models a stable system (Kˉ=0.9\bar K=0.9), the other an unstable one (Kˉ=1.2\bar K=1.2). What do the Lipschitz bounds say about 50-step rollouts?

  1. Both errors grow linearly with the number of steps
  2. The stable system's error stays below 10Δ10\Delta, while the unstable system's bound grows geometrically, by a factor of about 1.21.2 per step
  3. Both errors stay bounded, because the one-step errors are tiny
  4. The unstable system's model is more accurate because it moves faster
Show the answer

B. The stable system's error stays below 10Δ10\Delta, while the unstable system's bound grows geometrically, by a factor of about 1.21.2 per step

The bound Δ∑i<nKˉ i\Delta\sum_{i<n}\bar K^{\,i} is at most Δ/(1−Kˉ)=10Δ\Delta/(1-\bar K)=10\Delta for Kˉ=0.9\bar K=0.9, while for Kˉ=1.2\bar K=1.2 and n=50n=50 it is Δ(1.250−1)/0.2≈45,500 Δ\Delta(1.2^{50}-1)/0.2\approx45{,}500\,\Delta. Expanding dynamics stretch every inherited error.

Question 4

In the sup-norm simulation bound γ εTVRmax⁡/(1−γ)2\gamma\,\varepsilon_{\mathrm{TV}}R_{\max}/(1-\gamma)^2, what do the two factors of 1/(1−γ)1/(1-\gamma) account for?

  1. One for the number of steps over which errors occur, one for the range of values a one-step error can redirect
  2. Both for the variance of the return
  3. One for the reward error and one for the transition error
  4. They are an artifact of the proof and cancel in practice
Show the answer

A. One for the number of steps over which errors occur, one for the range of values a one-step error can redirect

The occupancy form sums one-step errors over the effective horizon, giving one factor, and each one-step error moves probability mass between next states whose values can differ by up to Rmax⁡/(1−γ)R_{\max}/(1-\gamma), giving the other.

Further reading

  • M. Kearns & S. Singh, "Near-optimal reinforcement learning in polynomial time," Machine Learning 49 (2002), 209–232.
  • K. Asadi, D. Misra & M. L. Littman, "Lipschitz continuity in model-based reinforcement learning," ICML (2018).
  • A.-m. Farahmand, A. M. S. Barreto & D. N. Nikovski, "Value-aware loss function for model-based reinforcement learning," AISTATS (2017).
  • C. Grimm, A. Barreto, S. Singh & D. Silver, "The value equivalence principle for model-based reinforcement learning," NeurIPS (2020).
  • C. Grimm, A. Barreto, G. Farquhar, D. Silver & S. Singh, "Proper value equivalence," NeurIPS (2021).