Paper commentary
When to Trust Your Model: Model-Based Policy Optimization
Short model rollouts from real data let policy optimization learn faster
- Problem Model-based reinforcement learning is hard because model errors cap policy quality. Analyses that charge for model error are so pessimistic they argue against using a model at all.
- Method MBPO trains soft actor-critic on short model rollouts branched from real data. Instead of rolling out from the initial state, it starts rollouts from replay-buffer states using a bootstrap ensemble of models.
- Results On Ant, MBPO reaches at 300 thousand environment steps what SAC needs 3 million steps to match. It matches the asymptotic performance of the best model-free methods.
Why model usage is hard to justify
Model-based methods make fast progress from limited real data, yet the learned model caps the quality of the policy that can be extracted from it. Model-free methods reach strong asymptotic results but need far more interaction, which is costly when the system is a physical one.
Monotonic improvement guarantees underpin many model-free methods, while most model-based approaches come without them. Carrying the same style of analysis over to model-based methods produces bounds that depend on pessimistic estimates of model error, which makes it hard to argue for using a model in the first place. The authors show that error rates measured empirically are less pessimistic and can be built into the analysis.
A bound that charges for model error
The procedure repeats three steps: collect real transitions with the current policy, fit the model by maximum likelihood, and optimize the policy under the model with a penalty term.
The guarantee takes the form \(\eta[\pi] \ge \hat{\eta}[\pi] - C\), so a policy that improves its model return by more than \(C\) is guaranteed to improve in the true environment. The first quantity, \(\epsilon_m\), is the maximum over timesteps of the expected total-variation distance between the true and learned transition distributions, taken on the state distribution of the data-collecting policy, and it is estimated from validation loss.
The second quantity, \(\epsilon_\pi\), bounds the total-variation distance between the new policy and the data-collecting policy, and the KL divergence measured in practice relates to it through Pinsker's inequality.
Theorem 4.1 expresses \(C\) in terms of \(\epsilon_m\) and \(\epsilon_\pi\), and the model-error part carries a factor of \(1/(1-\gamma)^2\), so it grows with the square of the effective horizon. The analysis can also fail to deliver: there may be no policy that improves the model return by more than \(C\), and full rollouts through the model let errors compound.
Branched rollouts as a way to limit model use
A branched rollout begins at a state from the previous policy's state distribution and first samples actions from that previous policy. At a chosen point the rollout switches to the learned model with the current policy and continues for \(k\) steps. Setting \(k\) to 1 recovers the Dyna scheme as a special case. Because the model only acts over the \(k\) steps after the branch point, the rollout length directly controls how much model error can enter the training data.
The authors replace the error on the previous policy's distribution with the error \(\epsilon_{m'}\) on the current policy's distribution, which gives Theorem 4.3.
The minimizing rollout length \(k^*\) is positive for sufficiently low \(\epsilon_{m'}\), so this bound favors some model use. Since \(\epsilon_{m'}\) is unavailable before the update, the authors approximate it linearly in policy divergence as \(\hat{\epsilon}_{m'}(\epsilon_\pi)\approx\epsilon_m+\epsilon_\pi\frac{d\epsilon_{m'}}{d\epsilon_\pi}\).
How model error grows with policy shift
Model error increases with the divergence between the current and data-collecting policies, but the rate of this increase depends on how much data the model was trained on.
The authors measure the local change in model error at zero policy divergence and read a shrinking dependence on policy shift as better generalization to nearby distributions. This measurement is reported for Hopper and Walker2d, and it is a local proxy rather than a complete characterization of generalization.
MBPO as a practical algorithm
MBPO settles three design decisions: the parametrization of the model, how the policy is optimized given model samples, and how model samples are drawn for policy optimization. The model is a bootstrap ensemble of probabilistic networks, each outputting a Gaussian with diagonal covariance over the next state and reward. Each network's Gaussian captures aleatoric uncertainty, while the ensemble captures epistemic uncertainty, which matters where data is scarce.
For each prediction one ensemble member is chosen uniformly at random, so different transitions within one rollout can come from different members.
Policy optimization uses soft actor-critic, which alternates a policy evaluation step built on Bellman backups with a policy improvement step that minimizes a KL-divergence objective. Gradient updates to the Q-functions are also needed when SAC is the optimizer, but they are left out of the algorithm listing.
Algorithm 2 alternates \(E\) real environment steps with \(M\) model rollouts, each of length \(k\) and started from states sampled uniformly from the environment dataset. After that, \(G\) gradient updates run on the model dataset, and the policy takes between 20 and 40 gradient steps per environment sample. Earlier model-based methods started rollouts from the initial state distribution, which ties rollout length to the task horizon and forced truncated benchmarks.
Branching replaces a few long rollouts with many short rollouts that start from replay-buffer states.
Learning speed on MuJoCo benchmarks
Experiments use the standard 1000-step versions of the MuJoCo tasks rather than the shortened versions used in some earlier model-based work. The model-free baselines are SAC and PPO, and the model-based baselines are PETS, STEVE and SLBO. PETS plans directly with the model, STEVE uses short rollouts only to improve value estimates, and SLBO rolls out from the initial state distribution.
Each curve averages five trials, and the shaded region shows the standard deviation across those trials.
MBPO learns much faster, by an order of magnitude on some tasks, and reaches comparable final performance. On Ant, MBPO at 300 thousand environment steps matches SAC at 3 million steps. On Hopper and Walker2d, MBPO needs the equivalent of 14 and 40 minutes of simulation time, respectively, if the simulator ran in real time. The authors also point to Ant, a higher-dimensional task where purely model-based approaches such as PETS run into problems, as a case where MBPO still learns.
Some algorithms do not converge within the region plotted, so their asymptotic performance is shown separately. MBPO's asymptotic performance is similar to that of the best model-free algorithms while it stays faster than the model-based baselines.
What the design ablations isolate
The no-model ablation runs SAC without model data but with the same ratio of gradient updates to environment samples that MBPO uses on Hopper. Raising the update count in SAC speeds up learning only marginally, and the model-free version does not reach MBPO's sample efficiency. On Hopper the update ratio alone does not explain the gain, so the model data is the source of the advantage in this ablation.
The best rollout schedule on Hopper rises linearly from \(k = 1\) to \(k = 15\). Fixing the rollout length at 1 for all of training keeps much of that benefit. The authors read this as consistent with their analysis, which favors short rollouts to contain compounding model errors.
Model-based value expansion uses model rollouts to improve the target values of real samples rather than to train the policy directly. The authors augment SAC with an \(H\)-step Q-target and vary \(H\) over 1, 5 and 10. Single-step model rollouts with \(H = 1\) again prove surprisingly competitive. MBPO outperforms model-based value expansion and STEVE, but the policy learning algorithm differs between these methods, so the comparison is confounded.
In preliminary experiments, using improved target value estimates did not improve MBPO.
Model exploitation on Hopper
The model's uncertainty grows and the recognizable sinusoidal motion deteriorates over the rollout.
The returns of a trained policy under the real environment and under the learned model are highly correlated. This suggests the policy does not exploit the model when rollouts are sufficiently short, which the authors attribute to short rollouts more closely following the real dynamics.
Across the evaluated environments, model returns under MBPO tend to underestimate the real environment returns.
Limits of the evidence
The bound is pessimistic, because the analysis makes no assumption about the model's generalization capacity or smoothness, so the scaling of \(\epsilon_m\) with \(\epsilon_\pi\) is worst-case. The linear approximation of error growth is a local estimate measured for Hopper and Walker2d, and it is not established for other settings. The \(k\)-branched bound alone does not identify a rollout length, and it is the linear approximation that yields a positive optimum.
The ablations and the model exploitation analysis use Hopper, and the value expansion comparison with MVE and STEVE is confounded by the policy learner. Rollouts longer than one step were tested only at 200 and 500 steps. The learning curves are averages over five trials, so spread across further seeds is not characterized.
Paper info
- Authors
- Michael Janner, Justin Fu, Marvin Zhang, Sergey Levine
- Venue
- arXiv · Preprint
- First published
- 2019-6-19
- Added
- 2026-11-6
- Updated
- 2021-11-29
- Version
- v3
- arXiv
- 1906.08253
- Category
- cs.LG · cs.AI · stat.ML
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
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.
Quote from the paper
Michael Janner, Justin Fu, Marvin Zhang, Sergey Levine (2019). When to Trust Your Model: Model-Based Policy Optimization. arXiv:1906.08253v3. https://arxiv.org/abs/1906.08253v3
BibTeX
@misc{janner2019when,
title = {{When to Trust Your Model: Model-Based Policy Optimization}},
author = {Michael Janner and Justin Fu and Marvin Zhang and Sergey Levine},
year = {2019},
eprint = {1906.08253},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1906.08253v3}
}