Counterfactual Debugging the World Model Transfer Gap

Authors
Mingxuan Li1*, Kai-Zhan Lee1*, Michael Dennis2, Elias Bareinboim1
Affiliations
1Columbia University · 2Google DeepMind · *equal contribution
Venue
NeurIPS 2026
World model imaginesreturn 0.00
Real simulatorreturn 0.00
Fix by our algorithm at 6 chunksreturn 0.00
The robot stands up in world model but not in real. A humanoid policy trained by SuperMimic is evaluated in this 30 s clip of a fall-and-get-up sequence. In the real simulator (middle) the robot tips over as it tries to stand, at 15 s, and the episode ends. Inside the world model (left) it stands up and keeps tracking, promising a return of 0.78 against the real 0.39. Fixing the 6 chunks detected by our algorithm to the 94 chunks world model rollout (right) steers the prediction back to align with real. A highlight and a short pause mark those pivotal errors.

TL;DR

Every world model is wrong somewhere, but only a few of its errors make an agent that looks good in the model fail in the real world. We call them pivotal errors.

We show that pivotal errors start as small drifts that look harmless, then grow as the model builds on its own predictions. Pixel or latent prediction error, the most common metric, can't capture them.

We find pivotal errors by asking how much of the transfer gap, between how well the model said the agent would do and how well it did in deployment, would close had each step followed the real world. That is the step's counterfactual Shapley value (from our RLJ 2026 paper). Our algorithm Recursive-φ computes these values efficiently and scales to 1 million steps.

01 · Intuition

Not every world-model error matters

Every learned world model is wrong somewhere. It may blur a background, misplace an object by a few pixels, or mispredict the movement of the agent that cascades into task failures. Standard frame-by-frame visual/latent diffs could flag all such discrepancies. But what an agent needs is narrower: which world model's errors cause the policy to underperform in the real world?

We use a controlled example to contextualize this question. A world model trained PPO agent scores the full 21 points in Pong, but only 15 in a "real" Pong whose screen randomly blacks out. There are 15 blackouts in this episode, and they look equally bad in pixel prediction errors. However, only two of them, at t = 536 and t = 1311, are pivotal errors that cost points. Both come right before the ball reaches the agent's paddle, and the first loss only shows on the scoreboard 64 steps after its pivotal frame.

Cumulative reward of the PPO agent over about 1650 Pong steps: the world-model rollout climbs to 21 while the real rollout with blackouts reaches 15; the blackout steps are marked along the time axis.
Which blackouts should be blamed? The agent scores 21 in the world model but 15 in the real world, whose 15 blackouts are marked along the time axis (paper, Fig. 1).
Pong frames from the world model (top) and the real world (bottom). Left, t = 535 to 537: the real screen blacks out at t = 536 as the ball heads toward the agent's green paddle, a critical blackout. Right, t = 1452 to 1454: a blackout at t = 1453 while the ball moves away from the paddle, a non-critical blackout.
Only blackouts right before the ball reaches the agent's paddle (green) matter. In this episode two blackouts, like the one at t = 536 (left), are pivotal and cost points that are lost more than 50 steps later. Blackouts like the one at t = 1453 (right), with the ball moving away, change nothing. Yet the world model's prediction error spikes on every blackout.

02 · Method

Debugging the Transfer Gap Counterfactually

Let a policy trained in the world model $\mathcal M_{\text{wm}}$ act in the real environment $\mathcal M_{\text{env}}$, producing a trajectory $\tau$. The world-model transfer gap is the difference between the real return and the one the model promised:

$$\Delta(\mathcal M_{\text{env}},\mathcal M_{\text{wm}}) \;=\; Y^{\tau}_{\mathcal M_{\text{env}}} \;-\; \mathbb E^{\pi}_{\mathcal M_{\text{wm}}}[Y].$$

Intuitively, a world model error is pivotal only if the transfer gap would be smaller had that step been from the real world. We ground this intuition by using Counterfactual Shapley Values (φ-values) to attribute the transfer gap to each time step.

φ-values can be calculated as follows:

1

Choose a coalition of steps and rollout counterfactually

A mask $\mathbf z\in\{0,1\}^T$ picks which steps run the world model ($z_t=1$). All other steps keep the transition observed in real world trajectory $\tau$ while the rollout stays on $\tau$; once it leaves $\tau$, later steps are generated by the world model too.

2

Score the counterfactual rollout

The coalition's value is the return difference $f(\mathbf z)=Y^{\tau}_{\mathcal M_{\text{env}}}-Y_{\sigma_{\mathbf z}}$ between real trajectory rewards and the counterfactual rollout rewards. The empty coalition reproduces the real rollout and the full coalition gives the world-model rollout.

3

Split the gap fairly

Counterfactual Shapley values average each step's marginal effect over coalitions. By efficiency, exact values add up to the gap, so each $\varphi_t$ is that step's share of it.

$$\varphi_t \;=\; \sum_{\mathbf z\in\{0,1\}^T}\kappa_t(\mathbf z)\,f(\mathbf z)$$
$$\sum_{t=1}^{T}\varphi_t \;=\; \Delta(\mathcal M_{\text{env}},\mathcal M_{\text{wm}})$$

κt is the Shapley kernel weight. See paper Sec. 3.1 for details.

How to collect a counterfactual rollout. The coalition mask chooses, step by step, between the observed real transition and the world model's prediction. If a world-model step takes the rollout off τ, the following steps are generated by the world model as well. Counterfactual rollouts never reset or query the real environment.

Remark. φ-values are different from eligibility traces in that a trace weighs a step by its distance from a TD error, (γλ)t′−t, in a single environment. φt asks how the return would change if step t ran the world model's mechanism instead of the real one.

2.1Recursive-φ: coarse to fine

Exact Counterfactual Shapley Values over T time steps need $2^T$ rollouts, and sampled estimates are high variance at long horizons. But pivotal errors are usually sparse: today's world models are accurate enough that only a few errors drive the transfer gap.

Recursive-φ builds upon this observation. It starts by splitting the steps into a few large blocks, computes block-level φ, discards blocks whose per-step attribution is below a threshold ε, and splits the survivors again recursively. When the number of active blocks is small, it enumerates every coalition exactly.

Below, the algorithm runs live on a toy version of the blackout Pong example in Fig. 1: in a 1860-steps episode, only two blackouts are pivotal errors (t=536, 1311).

Blue blocks are still active, with shade proportional to their per-step |Φ|. Grey blocks were pruned, and every step in them gets φ = 0. The coalition count per round is 2n rollouts for n active blocks when enumerated exactly.

Show the algorithm
Algorithm 1  Recursive-φ
Input: trajectory τ (length T), policy π, world model $\mathcal M_{\text{wm}}$, budget M, split B, threshold ε  ·  Output: per-step attributions φ̂1:T
  1. φ̂1:T ← 0; mark all steps active
  2. for r = 0, 1, …, ⌈logB T⌉ − 1 do
  3.  partition {1,…,T} into min(Br+1, T) contiguous blocks
  4.  $\mathcal A$ ← blocks containing at least one active step
  5.  estimate block values $\{\Phi_j\}_{j\in\mathcal A}$ over counterfactual rollouts // exact if $2^{|\mathcal A|}\le M$, else sampled
  6.  φ̂t ← $\Phi_j/|\mathcal B_j|$ for $t\in\mathcal B_j$, $j\in\mathcal A$
  7.  deactivate block j if $|\Phi_j|/|\mathcal B_j|<\varepsilon$ // its steps keep φ̂ = 0
  8. return φ̂1:T

With K pivotal errors, aggressive pruning shrinks the game from T players to O(K) within a few rounds. The total cost is $O(2^K\log_B T)$ counterfactual rollouts instead of $O(2^T)$.

What the theory guarantees

A causal attribution of the transfer gap should satisfy four desiderata:

  • D1 Causal admissibility: steps that do not cause the gap get zero credit.
  • D2 Causal power: steps that cause the gap get non-zero credit.
  • D3 Causal normality: steps more likely to affect the outcome get more credit.
  • D4 Causal effect scaling: steps that affect the outcome more get more credit.

Theorem 1. φ-values satisfy all four.

Theorem 2 (informal). Assume pivotal errors are sparse (at most K steps with effect ≥ δ), interactions within a block are bounded (η ≪ δ), and pivotal errors share a sign, i.e. errors compound rather than cancel. Then, for a small enough ε and with high probability, Recursive-φ loses no pivotal error, isolates all K of them in logB T rounds, and recovers their attributions up to bounded error while zeroing out the rest.


03 · Evaluations in the wild

Debugging Learned World Models

We apply Recursive-φ to four pretrained neural world models with simulator as the real world:

  • SuperMimic (Liao et al., 2026), a state-space world model of a Unitree G1 humanoid that trains a motion-tracking policy by backpropagating through imagined rollouts. We use NDM Gym's reimplementation and published checkpoints.
  • OmniDreams (NVIDIA, 2026), a video world model of driving scenes that AlpaSim can run in place of its NuRec reconstruction. The policy is Alpamayo 1.5, a 10B vision-language-action model that explains each decision in words.
  • DIAMOND (Alonso et al., 2024), a diffusion world model of Atari Pong (64×64 frames), with its own reward model and actor-critic.
  • LeWM (Maes et al., 2026), a JEPA world model that plans in latent space on OGBench Cube. LeWM predicts latents without pixels so we show each imagined latent as its nearest real frame.

3.1Case study: SuperMimic's world model stands up when the robot can't

Below shows a 30 s of a fall-and-get-up clip. The robot is sitting on the floor and starts to rise at about 14.6 s, and up to then the real and imagined rollouts have earned about the same return. In the simulator it tips over backwards at 15 s and the episode ends while inside the world model the same policy stands up and keeps tracking, so the model promises a return of 0.78 where the simulator delivers 0.39.

This is the typical way this model misses. Across ~1,600 clips we analyzed, the median return gap is only 0.004, yet imagination stands up in 23 of the 28 clips that contain a real fall. We picked this one because it happens in every replay. By injecting real transitions at the six pivotal chunks detected by our method, the transfer gap is fully closed.

World model imaginesreturn 0.00
Real simulatorreturn 0.00
Fix by φreturn 0.00
inject:
real world model imagines with the injected frames φ per chunk, toward the gap against the gap prediction error: mean body-position error (mm) of a one-chunk prediction from the real state highlight and pause: a φ-picked chunk being fixed with real transitions

Fixing the top steps detected by φ closes the transfer gap. With true physics in φ detected six chunks, the robot tips over inside the world model as it does in the real simulator, and the predicted return drops from 0.78 to 0.38, against the real 0.39. With prediction error's top six chunks instead, the robot stays up and the return stays at 0.78.

Real frame at 13.44 sreal
World model's prediction of the frame at 13.44 spredicted
13.44 s body error 16 mm
Real frame at 13.76 sreal
World model's prediction of the frame at 13.76 spredicted
13.76 s body error 14 mm
Frames look similar but hold the pivotal errors.
Real frame at 14.72 sreal
World model's prediction of the frame at 14.72 spredicted
14.72 s body error 144 mm
Real frame at 15.04 sreal
World model's prediction of the frame at 15.04 spredicted
15.04 s body error 151 mm
Real frame at 15.36 sreal
World model's prediction of the frame at 15.36 spredicted
15.36 s body error 250 mm
Frames look completely different but the errors aren't pivotal.
The surprise

The frames that look most wrong can't fix the prediction on their own. Each pair above shows a real frame and the world model's prediction of it, from the same real state with the same actions. From 14.7 s they look like different motions: the real robot falls on its back while the model has it getting up, with errors up to 250 mm. A frame-by-frame check points straight here. Yet making all of 14.1–15.4 s real closes only 3% of the transfer gap, and the robot still stands up.

The pivotal errors look like nothing is wrong. At 13.4 and 13.8 s the real and predicted frames are almost identical, only 14–16 mm apart, so prediction error ranks those chunks 25th and 28th of 94. However, fixing those two chunks close a big share of the whole transfer gap.

3.2Case study: OmniDreams turns a red light green

In this example, we examine world models for autonomous driving with Alpamayo 1.5 trained in AlpaSim. We use NuRec as the real world, a neural reconstruction of a logged drive that renders the camera from wherever the car goes. The world model is OmniDreams, which draws each frame from the HD map, the car's path, the other road users and the frames before it.

At night, the car waits at a red light. The logged human driver waited until 8.0 s, and NuRec renders the light red until 5.5 s, then green by 6.7 s. On NuRec's frames Alpamayo waits too, moving 0.09 m from 1 s to 7.45 s, averaged over 10 seeds. On OmniDreams' frames the red light washes out within a second and is green by 2 s. Alpamayo immediately spots that the light has turned green, and the car rolls forward 3.28 m on average, 5.85 m in this clip.

AlpaSim's own driving score barely tells the two worlds apart, with a median reward difference of 0.006 over 50 replays. So we use the metres driven along the logged path from 1 s to 7.45 s as the score, just after NuRec's light has turned green. Averaged over 10 seeds, NuRec's frames in the top two chunks ranked by φ cut the imagined 3.28 m to 0.42 m on average, while prediction error's top two only cut it to 1.13 m.

World model imaginesmoved 0.00 m
Real simulator (NuRec)moved 0.00 m
Fix by φmoved 0.00 m
inject:
real world model imagines with the injected frames φ per chunk, this drive prediction error per chunk: mean pixel difference (out of 255) of frames predicted from the real state highlight and pause: a φ-picked chunk being fixed with real transitions

Fixing the top steps detected by φ closes the transfer gap. Our algorithm ranks the 1.05–1.85 s frames as the pivotal error. With NuRec's frames in that one chunk, OmniDreams no longer turns the light green, Alpamayo decides to wait, and the car does not move at all, against 0.10 m in the real drive and 5.85 m in imagination. Fixing by prediction error's top chunk, 5.05–5.85 s, leaves the car rolling 4.79 m, and its top two and three still let it roll 1.05 m and 0.59 m.

NuRec frame at 1.15 s, red lightreal
OmniDreams' prediction of the frame at 1.15 s from the real state, red lightpredicted
1.15 s
NuRec frame at 1.75 s, red lightreal
OmniDreams' prediction of the frame at 1.75 s from the real state, red lightpredicted
1.75 s
The pivotal chunk looks right.
NuRec frame at 5.92 s, the light still redreal
OmniDreams' frame at 5.92 s, just after NuRec's frames in prediction error's top chunk, 5.05–5.85 s, with the light already greenpredicted
5.92 s
NuRec frame at 6.02 s, the light still redreal
OmniDreams' frame at 6.02 s, just after NuRec's frames in prediction error's top chunk, 5.05–5.85 s, with the light already greenpredicted
6.02 s
Prediction error's picks are too late to steer things back.
The surprise

OmniDreams misprediction starts with very small drifts on the pixel level. On the pixel level, the pivotal chunk detected by φ, 1.05–1.85 s, is the third least wrong of nine. Yet swapping in NuRec's frames in just that chunk is enough: the red still fades, but OmniDreams ends on amber instead of green, and the car never moves. Such situations make debugging by the prediction error nearly impossible.

3.3Case study: DIAMOND imagines a win

In this example Pong game clip, nobody scores. But DIAMOND, rolled out with the same agent acting on its own imagined frames, lets the ball pass the opponent's paddle at t = 66 and credits the agent with +1 and from t = 67 its own scoreboard shows the point. This is a dynamics error since in the real game the opponent returns the ball at t = 64. Recursive-φ (budget M = 1500) assigns non-zero φ to steps 46–67 only which close the transfer gap. Neither top latent prediction error nor top pixel space prediction error captures these pivotal errors in their top ranks.

DIAMOND imagines0
Real simulator0
Fix by φ0
inject:
real world model imagines with the injected frames φ per step, toward the gap against the gap prediction error after one step, from the real state, on frames and on latents highlight and pause: a φ-picked step being fixed with real transitions

Fixing the top steps detected by φ closes the transfer gap. Injecting the real transition at t = 61, the first of six steps tied at the top of φ, brings the score back to the real 0 in place of DIAMOND's imagined +1. The top steps by prediction error on frames and on latents, t = 70 and t = 4, each leave the imagined point in place. Ranked by these errors, the repair needs 9 and 10 steps.

3.4Case study: LeWM imagines picking the cube back up

In this OGBench example, the task is to move the red cube to a goal location and we measure the planner's goal cost, the latent distance to the goal image. The episode starts with the cube in the gripper. Inside the model the predicted cost ends at 42, so the plan looks like a success, and LeWM's final imagined latent is nearest to a frame with the cube in the gripper. However, in the real simulator, the gripper opens within the first few steps, the cube lands on the table and is never picked up again, and the final cost is 424. Our method finds the pivotal error in the block starting at step 35, which, when injected with the real transition, moves LeWM's plan cost back to 418.

LeWM imaginescost —
Real simulatorcost —
Fix by φcost —
inject:
real LeWM imagines with the injected frames exact φ per 5-step block, toward the gap against the gap latent prediction error per 5-step block, from the real state highlight and pause: a φ-picked step being fixed with real transitions

Fixing the top steps detected by φ closes the transfer gap. The real transition at step 35 is the block with the largest |φ|. Injecting real transitions here moves LeWM's predicted final cost from 42 to 418, against the real 424. Latent prediction error's top block is step 0 which only brings the goal cost to 293. And the repair would need six blocks if ranked by prediction error.


04 · Evaluations under controlled setting

Recursive-φ finds all injected errors

To test localisation against ground truth, we use a sim-to-sim protocol: an unchanged simulator serves as the world model, and a perturbed copy plays the real world. Each method is scored by whether repairing its top-K steps closes the transfer gap. K is used only for scoring. On MiniGrid it is the number of planted errors; otherwise it is identified by design or from Recursive-φ's output and verified before use. On the Pong blackouts it is the smallest top-K of Recursive-φ that restores the clean return. The same K is given to every baseline. Baselines are Flat-φ (the same φ-values without recursion), SHAP and LIME. Tables average over 10 seeds with a 5k rollout cap.

4.1Observation blackouts on Atari Pong

At random steps the real world zeroes the observation, as if a sensor disconnected. On the full ~1860-step trajectory, Recursive-φ puts all of its mass on the two pivotal blackouts and zero everywhere else. The baselines' attribution spikes scatter across the horizon.

The full episode. Left: the world model (the unperturbed simulator). Right: the real world as the agent sees it. One frame per step; each blackout is held for two seconds with an orange border. The two pivotal blackouts, t = 536 and t = 1311, appear at 0:30 and 1:05 of this clip.
Per-step attribution traces over the Pong trajectory for Recursive-phi, Flat-phi, SHAP and LIME; only Recursive-phi spikes exactly at steps 536 and 1311.
Localisation. Only Recursive-φ (blue) captures the two pivotal errors, 536 and 1311.

Transfer gap explained

Share of the gap closed by repairing each method's top-K blackouts (%, 10 seeds).

Recursive-φFlat-φSHAPLIME

Rollouts needed

Smallest budget at which the gap is fully explained (log scale). Missing points: not enough seeds succeed within the 5k cap.

Recursive-φFlat-φSHAPLIME

4.2Mechanism shifts on ProcGen CoinRun

Two shifts that stay visually plausible. Poisonous coin: every collected coin pays −10 instead of +10, and the pixels do not change at all. Windy day: 70% of jumps are pushed one cell left and fall short. Recursive-φ recovers 100% of the transfer gap in every variant and length, using 30–300 rollouts with zero seed variance. Flat-φ and SHAP need roughly 10–100× more rollouts when they recover at all; LIME never exceeds 30%.

CoinRun poisonous-coin variant illustration
Variant A · poisonous coin
CoinRun windy-day variant illustration
Variant B · windy day

4.3Scaling to a million steps on MiniGrid

A hand-crafted MiniGrid agent loops around a 5×5 room before reaching the goal, so the trajectory length L can be set anywhere up to 106. A penalty is planted at K = 1, 2 or 5 steps. Recursive-φ recovers 100% of the gap at every L up to 1M. Flat-φ needs more than 105 rollouts already at L = 500 for K = 5, and is exhausted past L = 2000 even at the largest budget we swept.

Transfer gap explained versus trajectory length L up to one million, for K = 1, 2, 5
Transfer gap explained vs. L
Rollouts required (linear axis up to 100k) versus trajectory length L (log axis, 100 to 1M): Flat-phi needs about 100k rollouts at L = 500 for K = 5, Recursive-phi stays low
Rollouts required vs. L

05 · Takeaway

Find the pivotal errors

  • Not all world-model errors matter for the outcome. The few that do, the pivotal errors, decide whether an agent that works in the world model also works in reality.
  • Pivotal errors often start as small drifts that look harmless when they happen, and it takes causal reasoning instead of pixel/latent errors or eligibility traces.
  • Counterfactual debugging with Recursive-φ yields accurate per-step attributions over world model transfer gap, providing principled, actionable insights for model-based policy learning.

Citation

BibTeX

@inproceedings{li2026ctfdebug,
  title={Counterfactual Debugging the World Model Transfer Gap},
  author={Mingxuan Li and Kai-Zhan Lee and Michael D Dennis and Elias Bareinboim},
  booktitle={The Fortieth Annual Conference on Neural Information Processing Systems},
  year={2026},
  url={https://openreview.net/forum?id=5SUeNVcFWj}
}