Breaking the Curse of Horizon
Marginalized importance sampling and the DICE family.
Trajectory importance weights multiply one ratio per step, and their variance grows exponentially with the horizon. But in a Markov process the past matters only through the present state. Reweighting each transition by how much more often the target policy visits its state and action, , needs no products at all. This lesson derives the equations that pin down, the DICE estimators that learn it from transitions without knowing the behavior policy, the linear program behind them, and the error bounds, including the lower bounds that say when even this fails.
What you’ll learn
- Derive the marginalized importance-sampling identity and the flow equations that determine the ratio , in discounted and average-reward problems.
- Compute marginal ratios in a small chain and compare their size with that of trajectory weights.
- Derive DualDICE's change of variables and its minimax form, and the error bound of minimax weight learning.
- Derive the Lagrangian of the occupancy linear program for policy evaluation, and show that it is exact when either the weights or the action values are correct.
- State the error bound of tabular marginalized importance sampling and the lower bounds that limit estimation with function approximation.
From products of ratios to a ratio of distributions
Use the normalized discounted occupancy measure , started from , and the normalized value . Let the logged transitions have state–action distribution , from one behavior policy or several, with wherever . A change of measure gives the marginalized importance sampling identity
Each transition is reweighted on its own; no product over the trajectory appears. Liu, Li, Tang and Zhou (2018) proposed this to break the curse of horizon, first for average-reward problems, with a ratio of state distributions times the one-step action ratio .
Two states. In , stay keeps you in and go moves you to ; from you always return to . The reward is 1 in and 0 in , averaged over a long run. The behavior goes with probability 0.2, the target with probability 0.5. A chain that leaves with probability spends a fraction of its time in :
The marginal ratios are modest numbers, and reweighting the behavior's transitions by them recovers the target's average reward:
The trajectory weight multiplies at every visit to : 2.5 after go, 0.625 after stay. Its second moment obeys a linear recursion over the current state, with matrix entries for each move : from , 0.3125 back to and 1.25 to ; from , 1 to . The largest eigenvalue is about 1.285, so starting from :
In the same chain, the target now goes with probability 0.8 (the behavior still 0.2). What is the state ratio ?
Show the answer
2.67
and , so , still a modest number. The trajectory weight now multiplies 4 after every go and 0.25 after every stay; its second moment grows like instead of .
The variance of a reweighted estimate is governed by , a divergence between occupancies; the trajectory weight's second moment is between trajectory distributions, which compounds step by step. If is the behavior's own discounted occupancy, the occupancy is the image of the trajectory distribution under "pick a geometric random time and report ", a map applied identically to both policies, so by the data-processing inequality the first divergence can never exceed the second.
The catch is that is unknown: it depends on the dynamics through . The rest of the lesson is about estimating it from the logged transitions alone.
Pinning the ratio down: the flow equations
The occupancy measure satisfies a flow equation, the dual side of the Bellman equation (Occupancy Measures & the Dual View). Testing it against an arbitrary function gives an identity that, after a change of measure, involves only the data.
Telescope and multiply by . For every , with :
Change measure to the data. The true ratio makes the following vanish for every test function :
Conversely, if for all , the measure solves , where is here the state–action transition matrix under . Since is invertible, : the test identifies wherever . In the average-reward case () the initial term disappears and the solution is fixed only up to scale, so estimators add the normalization .
Liu et al. (2018) turned this into an estimator: restrict to the unit ball of a reproducing kernel Hilbert space, where has a closed form, a kernel-weighted quadratic in the residuals of the flow equation that resembles a maximum mean discrepancy, and minimize it over . Their state-ratio version needs the behavior's action probabilities for the one-step ratio. The next estimators do not.
Learning the ratio: DualDICE and minimax weights
DICE estimators (stationary distribution correction estimation) learn the ratio from transitions alone, without the behavior's probabilities, so the data may come from several unknown policies or from people. DualDICE (Nachum, Chow, Dai & Li, 2019) found a change of variables that turns the flow equations into a convex minimization.
Let , a Bellman operator with zero reward, and minimize over functions :
Write . By the telescoping identity of the previous step (with ), the second term is , so the objective is a pointwise quadratic:
It is minimized at , and every is reachable because is invertible. The optimum's Bellman residual is the ratio:
The square of a conditional expectation cannot be estimated without bias from one sampled next state (the double-sampling problem). DualDICE therefore uses the Fenchel dual and solves a saddle-point problem whose inner maximizer is the ratio itself, :
Nachum et al. also replace by other convex functions such as ; worked best in their experiments. GenDICE (Zhang, Dai, Li & Schuurmans, 2020) covers the average-reward case, where DualDICE's initial-state term vanishes, by minimizing a variational divergence between the reweighted data distribution and its image under one step of the target's dynamics, with a penalty enforcing . GradientDICE (Zhang, Liu & Whiteson, 2020) observed that GenDICE's saddle-point problem stops being convex–concave once a nonlinearity is used to keep positive, and replaced the divergence with an objective that is convex–concave with linear function approximation and provably convergent.
Proof. Take . The Bellman equation gives , so . Since is linear in , its maximum over bounds its value at any point of the convex hull.
The discriminator class only needs to contain the right value function, and the weights only need to satisfy the flow equations against that class, a weak, test-function notion of accuracy. Swapping the roles gives minimax Q-learning (MQL): fit with weights as discriminators, , which is accurate when the true ratio lies in the convex hull of .
The Lagrangian behind DICE
For a fixed the occupancy measure is the unique solution of the flow constraints, so the linear program "maximize subject to the flow constraints" has value . Give each constraint a Lagrange multiplier and write .
Collecting the terms of each variable, the Lagrangian in is
Correct , any . If , the Bellman residual has conditional mean zero given , so the second term vanishes:
Correct , any . If , the second term is an expectation under , and the telescoping identity cancels every term against the first:
Combining the two facts, the error of any pair is a product of the two errors, with (a version of this identity appears in Uehara et al., 2020):
This is double robustness in marginal form: the estimate is exact if either argument is, and its error is second order when both are close, which is what lets Kallus and Uehara's estimator reach the efficiency bound (Importance Sampling & Doubly Robust Estimators). Setting recovers the weighting estimate ; setting recovers the direct estimate ; and minimax weight learning's test function is . Yang, Nachum, Dai, Li and Schuurmans (2020) showed that the DICE estimators are regularized versions of this Lagrangian. Because is bilinear, its saddle points are fragile to optimize; convex regularizers on or on make the problem better conditioned, at the price of bias unless chosen carefully, and DualDICE and GenDICE correspond to particular choices.
Error bounds, and their limits
Tabular, finite horizon. Xie, Ma and Wang (2019) estimate the target's state distribution at each step recursively from the empirical transition model, , and reweight. For episodes of a non-stationary episodic MDP, in their indexing ( is the reward at step ), the mean squared error is
within a factor of the Cramér–Rao bound for Markov problems (Jiang & Li, 2016). It was the first off-policy evaluation error bound with only polynomial dependence on the horizon, and Yin and Wang (2020) later showed that a simple modification of the tabular estimator attains the Cramér–Rao bound asymptotically when the action space is finite.
Function approximation. Minimax weight learning's bound says what is needed: a discriminator class that contains and a weight class that can nearly satisfy the flow equations against it. Two cautions remain.
- The ratio itself can be large. is the single-policy concentrability of Pessimism: The Theory of Offline RL, and the variance of a reweighted estimate scales with . Marginalizing stops the mismatch from compounding; it does not remove it.
- Realizability is not enough. Wang, Foster and Kakade (2021) constructed problems in which every policy's value is linear in known features and the data cover all feature directions well, yet any estimator needs a number of samples exponential in the horizon. Their bound covers marginalized estimators too: realizing in the discriminator class does not help when no tractable weight class can approximate the true ratio.
Key takeaways
- Marginalized importance sampling reweights each transition by . No products appear, and in a Markov chain these ratios can stay bounded while the trajectory weight's second moment grows exponentially ( in the two-state example).
- The flow equations, tested against all functions, identify from transitions alone; in the average-reward case they fix it only up to scale. DualDICE turns them into a convex problem whose optimal Bellman residual is , and minimax weight learning is accurate whenever its discriminator class contains .
- The evaluation Lagrangian is exact if either argument is exact, with an error that is a product of the two errors; the DICE estimators are its regularized versions.
- Tabular marginalized importance sampling has error polynomial in , within a factor of the Cramér–Rao bound. With function approximation the ratio can still be large, , and realizability alone cannot avoid exponential lower bounds.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Why can marginalized importance sampling avoid the exponential growth of trajectory-wise importance weights?
- It ignores the mismatch between the policies
- It assumes deterministic dynamics
- In a Markov process each transition can be reweighted by a ratio of state–action distributions, which involves no product over the trajectory
- It uses only the first step of each episode
Show the answer
C. In a Markov process each transition can be reweighted by a ratio of state–action distributions, which involves no product over the trajectory
The past affects the future only through the current state, so what matters is how much more often the target visits , not the probability of the whole action sequence. The ratio can stay bounded (2 in the two-state chain) while the trajectory weight's second moment grows like .
DualDICE minimizes , where is the Bellman operator with zero reward. What is the Bellman residual of the minimizer?
- The ratio
- The action-value function
- Zero
- The behavior policy's action probabilities
Show the answer
A. The ratio
With , the telescoping identity turns the objective into , minimized pointwise at . The residual of the optimal is the correction ratio.
In the evaluation Lagrangian , when does equal exactly?
- Only when both and are exact
- Only when is exact
- Only when is exact
- When either or is exact
Show the answer
D. When either or is exact
With the Bellman residual has conditional mean zero, so any gives . With the telescoping identity cancels every term. The general error is a product of the two errors: double robustness in marginal form.
Minimax weight learning's error bound requires which assumption?
- The weight class contains the true ratio
- The discriminator class contains, in its convex hull, the true action-value function
- The behavior policy is known
- The dynamics are deterministic
Show the answer
B. The discriminator class contains, in its convex hull, the true action-value function
exactly, and is linear in , so if is in the convex hull of the worst case over bounds the error. The weight class only needs some member that nearly satisfies the flow equations against .
Further reading
- Q. Liu, L. Li, Z. Tang & D. Zhou, "Breaking the curse of horizon: Infinite-horizon off-policy estimation," Advances in Neural Information Processing Systems 31 (2018).
- T. Xie, Y. Ma & Y.-X. Wang, "Towards optimal off-policy evaluation for reinforcement learning with marginalized importance sampling," Advances in Neural Information Processing Systems 32 (2019).
- O. Nachum, Y. Chow, B. Dai & L. Li, "DualDICE: Behavior-agnostic estimation of discounted stationary distribution corrections," Advances in Neural Information Processing Systems 32 (2019).
- M. Uehara, J. Huang & N. Jiang, "Minimax weight and Q-function learning for off-policy evaluation," Proceedings of the 37th International Conference on Machine Learning (ICML) (2020).
- M. Yang, O. Nachum, B. Dai, L. Li & D. Schuurmans, "Off-policy evaluation via the regularized Lagrangian," Advances in Neural Information Processing Systems 33 (2020).