Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

Compounding Errors & Interactive Imitation

Why cloning errors can grow quadratically with the horizon, and how DAgger makes them linear.

How can a policy that is right 99.9% of the time on the expert's data still fail, and how much can asking the expert help? This lesson proves behavior cloning's quadratic bound by coupling the learner with the expert and shows that it is tight, defines recoverability through the expert's cost-to-go, analyzes DAgger as a reduction to no-regret online learning (mixing terms included), and ends with the lower bounds that say when no amount of interaction can help.

What you’ll learn

  • Prove J(π)≤J(πE)+T2ϵJ(\pi)\le J(\pi^E) + T^2\epsilon by coupling the learner with the expert, and construct a task that attains it.
  • Define the recoverability constant uu through the expert's cost-to-go, and derive J(π)≤J(πE)+uTϵπJ(\pi)\le J(\pi^E) + uT\epsilon_\pi in terms of the learner's error on its own distribution.
  • Analyze DAgger with expert mixing as a reduction to no-regret online learning, and state the guarantees of forward training and SMILe.
  • Summarize the lower bounds and taxonomies of Rajaraman et al. (2020), Swamy et al. (2021) and Foster, Block & Misra (2024), and what they imply about when interaction helps.

The quadratic bound, by coupling

DerivationProof by coupling
  1. Write the dynamics as St+1=f(St,At,ξt)S_{t+1} = f(S_t, A_t, \xi_t) with independent noise ξt\xi_t (every transition kernel can be written so), and the learner's choice as At=g(St,Ut)A_t = g(S_t, U_t) with independent uniform UtU_t. Run the learner and the expert from the same S1S_1 with the same ξ1,ξ2,…\xi_1,\xi_2,\dots. Let GtG_t be the event that the learner's actions agreed with the expert's at steps 1,…,t1,\dots,t. On Gt−1G_{t-1} both trajectories coincide up to StS_t.

  2. E[C(St,At)]−E[C(StE,AtE)] ≤ Pr⁡(Gtc)\E\big[C(S_t, A_t)\big] - \E\big[C(S^E_t, A^E_t)\big]\ \le\ \Pr\big(G_t^{c}\big)

    On GtG_t the pairs (St,At)(S_t, A_t) coincide, so the two step-tt costs are equal; otherwise they differ by at most 1:

  3. Pr⁡(Gtc)=∑i=1tE[1Gi−1 eπ(SiE)] ≤ ∑i=1tE[eπ(SiE)]=∑i=1tϵi\Pr\big(G_t^{c}\big) = \sum_{i=1}^{t}\E\Big[\mathbf 1_{G_{i-1}}\,e_\pi\big(S^E_i\big)\Big]\ \le\ \sum_{i=1}^{t}\E\Big[e_\pi\big(S^E_i\big)\Big] = \sum_{i=1}^{t}\epsilon_i

    Split GtcG_t^c by the first disagreement. Given the past, the learner disagrees at step ii with probability eπ(Si)e_\pi(S_i), and on Gi−1G_{i-1} its state is the expert's SiES^E_i, whose law is dπEid^i_{\pi^E}:

  4. J(π)−J(πE) ≤ ∑t=1T∑i=1tϵi=∑i=1T(T−i+1) ϵi ≤ T∑i=1Tϵi=T2ϵ■J(\pi) - J(\pi^E)\ \le\ \sum_{t=1}^T\sum_{i=1}^t\epsilon_i = \sum_{i=1}^T(T-i+1)\,\epsilon_i\ \le\ T\sum_{i=1}^T\epsilon_i = T^2\epsilon\qquad\blacksquare

    Sum over tt. Each ϵi\epsilon_i is counted once for every step from ii to TT:

Predict before you look

Spread the error evenly instead: the learner errs with probability ϵ=0.01\epsilon = 0.01 at every step while it still follows the expert, the first error traps it with cost 1 per step (that step included), and the expert's cost is 0. For T=30T = 30, what is the learner's expected extra cost? (The bound gives T2ϵ=9T^2\epsilon = 9.)

Show the answer

4.2

The learner is trapped at step tt with probability 1−0.99t1-0.99^t, so the extra cost is ∑t=130(1−0.99t)=30−99 (1−0.9930)≈30−99×0.2603≈4.23\sum_{t=1}^{30}(1-0.99^t) = 30 - 99\,(1-0.99^{30})\approx 30 - 99\times0.2603\approx 4.23. That is close to ϵT(T+1)/2=4.65\epsilon T(T+1)/2 = 4.65, about half the worst case: uniform errors give the same quadratic order with constant 12\tfrac12, while front-loaded errors attain the bound.

Recoverability: errors on the learner’s own states

The quadratic bound charges every disagreement with the whole rest of the episode. A sharper accounting asks what one wrong action really costs if the expert takes over afterwards. Let QkE(s,a)Q^E_k(s,a) be the expected cost of taking aa in ss and then following πE\pi^E for the remaining k−1k-1 steps, VkE(s)=QkE(s,πE(s))V^E_k(s) = Q^E_k\big(s,\pi^E(s)\big), and QkE(s,π)=Ea∼π(⋅∣s)QkE(s,a)Q^E_k(s,\pi) = \E_{a\sim\pi(\cdot\mid s)}Q^E_k(s,a).

DerivationProof
  1. J(π)−J(πE)=∑t=1T[J(π1:t)−J(π1:t−1)]J(\pi) - J(\pi^E) = \sum_{t=1}^{T}\Big[J(\pi_{1:t}) - J(\pi_{1:t-1})\Big]

    Let π1:t\pi_{1:t} follow π\pi for the first tt steps and πE\pi^E afterwards, so π1:T=π\pi_{1:T} = \pi and π1:0=πE\pi_{1:0} = \pi^E, and telescope:

  2. J(π1:t)−J(π1:t−1)=Es∼dπt[QT−t+1E(s,π)−VT−t+1E(s)]J(\pi_{1:t}) - J(\pi_{1:t-1}) = \E_{s\sim d^t_\pi}\Big[Q^E_{T-t+1}(s,\pi) - V^E_{T-t+1}(s)\Big]

    The two hybrid policies coincide for the first t−1t-1 steps, so St∼dπtS_t\sim d^t_\pi under both; they differ only in the action at step tt, after which the expert has T−t+1T-t+1 steps to go:

  3. J(π)−J(πE) ≤ u∑t=1TEs∼dπt[eπ(s)]=uTϵπ■J(\pi) - J(\pi^E)\ \le\ u\sum_{t=1}^T\E_{s\sim d^t_\pi}\big[e_\pi(s)\big] = uT\epsilon_\pi\qquad\blacksquare

    The bracket vanishes where π\pi picks the expert's action and is at most uu where it does not, so it is at most u eπ(s)u\,e_\pi(s). Summing over tt turns ∑tEdπt[eπ]\sum_t\E_{d^t_\pi}[e_\pi] into TϵπT\epsilon_\pi:

The theorem trades the expert's distribution for the learner's own, which is the distribution that matters, at the price of the constant uu. Three regimes:

  • The cost is the imitation loss, C(s,a)=1{a≠πE(s)}C(s,a) = \mathbf 1\{a\ne\pi^E(s)\}. The expert's cost-to-go is 0 from every state, so u=1u = 1.
  • The expert recovers quickly. If one wrong action raises the expert's cost-to-go by at most kk (a car that swerves is back in its lane within a few steps), then u≤ku\le k and the bound is linear in TT. Ross, Gordon and Bagnell note that if the Markov chain of the expert's behavior mixes at an exponential rate δ\delta, then u=O(1/(1−e−δ))u = \order{1/(1-e^{-\delta})}.
  • One mistake is fatal. If a wrong action leads to a trap, QkE−VkEQ^E_k - V^E_k can be as large as kk, so u=Tu = T and the bound is quadratic again.

DAgger as a reduction to no-regret learning

DAgger turns the chicken-and-egg problem into online learning. Round ii collects data with πi=βiπE+(1−βi)π^i\pi_i = \beta_i\pi^E + (1-\beta_i)\hat\pi_i, which follows the expert with probability βi\beta_i at each step, and charges the online learner the loss ℓi(π)=Es∼dπi[ℓ(s,π)]\ell_i(\pi) = \E_{s\sim d_{\pi_i}}\big[\ell(s,\pi)\big], where ℓ(s,π)∈[0,ℓmax⁡]\ell(s,\pi)\in[0,\ell_{\max}] is a surrogate that upper-bounds the 0–1 error eπ(s)e_\pi(s). A sequence π^1,π^2,…\hat\pi_1,\hat\pi_2,\dots has average regret γN\gamma_N if

1N∑i=1Nℓi(π^i)−min⁡π∈Π1N∑i=1Nℓi(π) ≤ γN.\frac1N\sum_{i=1}^N\ell_i(\hat\pi_i) - \min_{\pi\in\Pi}\frac1N\sum_{i=1}^N\ell_i(\pi)\ \le\ \gamma_N .

Training on the aggregate of all rounds is follow-the-leader, which achieves γN=O~(1/N)\gamma_N = \tilde{\mathcal O}(1/N) for strongly convex losses; any other no-regret algorithm would do. One wrinkle remains: ℓi\ell_i is measured on the states of the mixture πi\pi_i, while the performance-difference bound needs the error of π^i\hat\pi_i on its own states.

DerivationProof
  1. dπi=(1−βi)T dπ^i+(1−(1−βi)T) d′d_{\pi_i} = (1-\beta_i)^T\,d_{\hat\pi_i} + \big(1-(1-\beta_i)^T\big)\,d'

    With probability (1−βi)T(1-\beta_i)^T the mixture uses π^i\hat\pi_i at all TT steps, and given that event its trajectories are distributed exactly as those of π^i\hat\pi_i, because the coin flips are independent of everything else. So for some distribution d′d',

  2. ∥dπi−dπ^i∥1=(1−(1−βi)T)∥d′−dπ^i∥1 ≤ 2(1−(1−βi)T) ≤ 2Tβi■\norm{d_{\pi_i} - d_{\hat\pi_i}}_1 = \big(1-(1-\beta_i)^T\big)\norm{d' - d_{\hat\pi_i}}_1\ \le\ 2\big(1-(1-\beta_i)^T\big)\ \le\ 2T\beta_i\qquad\blacksquare

    Subtract dπ^id_{\hat\pi_i}, use ∥d′−dπ^i∥1≤2\norm{d'-d_{\hat\pi_i}}_1\le2, and Bernoulli's inequality (1−β)T≥1−Tβ(1-\beta)^T\ge1-T\beta:

DerivationProof sketch
  1. Es∼dπ^i[ℓ(s,π^i)] ≤ ℓi(π^i)+2ℓmax⁡min⁡(1,Tβi)\E_{s\sim d_{\hat\pi_i}}\big[\ell(s,\hat\pi_i)\big]\ \le\ \ell_i(\hat\pi_i) + 2\ell_{\max}\min(1, T\beta_i)

    The lemma moves each round's loss from the mixture's states to the learner's own, at a cost of at most 2ℓmax⁡min⁡(1,Tβi)2\ell_{\max}\min(1,T\beta_i):

  2. min⁡iEs∼dπ^i[ℓ(s,π^i)] ≤ ϵN+γN+2ℓmax⁡N∑i=1Nmin⁡(1,Tβi)\min_{i}\E_{s\sim d_{\hat\pi_i}}\big[\ell(s,\hat\pi_i)\big]\ \le\ \epsilon_N + \gamma_N + \frac{2\ell_{\max}}{N}\sum_{i=1}^N\min(1,T\beta_i)

    The best iterate is no worse than the average, and the average of ℓi(π^i)\ell_i(\hat\pi_i) is within γN\gamma_N of the best fixed policy in hindsight:

  3. Finally, the first nβn_\beta terms of the last sum are at most 1 each, and the rest are TβiT\beta_i. Feeding the result into J(π^)≤J(πE)+uT Edπ^[eπ^]≤J(πE)+uT Edπ^[ℓ]J(\hat\pi)\le J(\pi^E) + uT\,\E_{d_{\hat\pi}}[e_{\hat\pi}]\le J(\pi^E) + uT\,\E_{d_{\hat\pi}}[\ell] gives the bound on JJ.

Two assumptions hide in this result. First, ϵN\epsilon_N is a best-in-class error on distributions the learner itself generates. If no policy in Π\Pi imitates the expert well on those states, for example because the learner's observations miss something the expert sees, DAgger converges to a poor policy and the bound is honest about it. Second, the reduction needs no regret against the sequence of losses. Follow-the-leader on a strongly convex loss provides it; a learner that refits only to the newest round does not.

Check your understanding

What does DAgger's analysis require of the supervised learner that behavior cloning's analysis does not?

  1. That the expert's policy belongs to the policy class
  2. A no-regret guarantee against the sequence of per-round losses, such as follow-the-leader on a strongly convex loss
  3. Access to the task's cost function
  4. A model of the environment's dynamics
Show the answer

B. A no-regret guarantee against the sequence of per-round losses, such as follow-the-leader on a strongly convex loss

The whole argument passes through the regret bound: the iterates' average loss on their own data is within γN\gamma_N of the best fixed policy on all rounds. Cloning's analysis needs only a small error on one fixed distribution.

Lower bounds and a taxonomy

Rajaraman, Yang, Jiao and Ramchandran (2020) asked for minimax rates in tabular episodic MDPs with NN expert trajectories and per-step rewards in [0,1][0,1]. The policy that mimics the expert wherever the expert was observed is suboptimal by ≲∣S∣H2log⁡N/N\lesssim\abs{\mathcal S}H^2\log N/N in expectation, even for a stochastic expert. Conversely, every algorithm is ≳∣S∣H2/N\gtrsim\abs{\mathcal S}H^2/N suboptimal on some instance, even with a deterministic expert and even if it may query the expert at the states it visits. With the transition model known and a deterministic expert, a different algorithm reaches ≲∣S∣H3/2/N\lesssim\abs{\mathcal S}H^{3/2}/N, below the H2H^2 barrier. So in the worst case over tabular MDPs interaction cannot improve the horizon dependence, and the guarantees of DAgger-style methods must come from assumptions such as recoverability.

What is matchedData neededExamplesUpper boundLower bound
Reward moments, on-policyEnvironment interactionGAIL, SQILO(ϵT)\order{\epsilon T}Ω(ϵT)\Omega(\epsilon T)
Q-value moments, off-policyDemonstrations onlyBehavior cloning, ValueDICEO(ϵT2)\order{\epsilon T^2}Ω(ϵT2)\Omega(\epsilon T^2)
Q-value moments, on-policyInteraction and a queryable expertDAgger, AggreVaTeO(ϵHT)\order{\epsilon HT}Ω(ϵT)\Omega(\epsilon T)
Bounds on the imitation gap for any algorithm that returns an ϵ\epsilon-approximate equilibrium of the corresponding moment-matching game (Swamy, Choudhury, Bagnell & Wu, 2021). Here ϵ\epsilon measures how far the returned policy is from an equilibrium of the moment-matching game, not a 0–1 error, and HH is their recoverability constant, which plays the role of uu.

Swamy et al. also show (their Lemma 7) that in a problem whose recoverability constant is of order TT, a classification error κ\kappa in a single state can cost Ω(κT2)\Omega(\kappa T^2) even with an interactive expert (for κ≲1/T\kappa\lesssim1/T, since no loss can exceed TT): neither family escapes compounding there.

Foster, Block and Misra (2024) revisit cloning itself. With the logarithmic loss and a policy class of controlled complexity that contains the expert's policy, the horizon dependence can be far milder than the classical analysis suggests: horizon-independent when the range of the total return is controlled, and linear in the horizon for deterministic stationary policies under dense per-step rewards. They also show that, without further assumptions on the policy class, online interaction cannot improve on offline log-loss cloning in the worst case. Part of the classical T2T^2 thus reflects how the learner's error is measured (a 0–1 error per state, rather than the log loss of whole trajectories), while the lower bounds above say what no method can avoid.

Key takeaways

  • Coupling the learner with the expert proves J(π)≤J(πE)+∑t(T−t+1)ϵt≤J(πE)+T2ϵJ(\pi)\le J(\pi^E) + \sum_t(T-t+1)\epsilon_t\le J(\pi^E) + T^2\epsilon; an error concentrated at the first step, followed by a trap, attains it exactly when the expert's own cost is 0.
  • Telescoping hybrid policies gives J(π)−J(πE)=∑tEdπt[QT−t+1E(s,π)−VT−t+1E(s)]≤uTϵπJ(\pi) - J(\pi^E) = \sum_t\E_{d^t_\pi}\big[Q^E_{T-t+1}(s,\pi) - V^E_{T-t+1}(s)\big]\le uT\epsilon_\pi: the learner's error on its own distribution, weighted by the recoverability constant uu.
  • Forward training, SMILe and DAgger all train on the states the current policy reaches. DAgger does it as no-regret online learning, with mixing handled by ∥dπi−dπ^i∥1≤2Tβi\norm{d_{\pi_i} - d_{\hat\pi_i}}_1\le2T\beta_i, and achieves J(πE)+uTϵN+O(1)J(\pi^E) + uT\epsilon_N + \order{1} after O~(uT)\tilde{\mathcal O}(uT) rounds.
  • Without structure, interaction cannot beat order ∣S∣H2/N\abs{\mathcal S}H^2/N (Rajaraman et al., 2020). Swamy et al. (2021) separate reward matching (ϵT\epsilon T), off-policy Q-matching (ϵT2\epsilon T^2) and on-policy Q-matching (ϵHT\epsilon HT), and log-loss cloning can be much less horizon-sensitive than the 0–1 analysis suggests (Foster, Block & Misra, 2024).

Check yourself

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

Question 1

The coupling proof gives J(π)−J(πE)≤∑t(T−t+1) ϵtJ(\pi) - J(\pi^E)\le\sum_t(T-t+1)\,\epsilon_t. With the average ϵ\epsilon held fixed, which error profile can make the extra cost as large as T2ϵT^2\epsilon?

  1. The same error ϵ\epsilon at every step
  2. All of the error at the last step, ϵT=Tϵ\epsilon_T = T\epsilon
  3. All of the error at the first step, ϵ1=Tϵ\epsilon_1 = T\epsilon, with a first mistake that leads to a trap
  4. Errors at random steps, independent of the state
Show the answer

C. All of the error at the first step, ϵ1=Tϵ\epsilon_1 = T\epsilon, with a first mistake that leads to a trap

The weight T−t+1T-t+1 is largest at t=1t = 1, so front-loaded errors maximize the sum, and a trap after the first mistake gives J(π)=(1−Tϵ)J(πE)+T2ϵJ(\pi) = (1-T\epsilon)J(\pi^E) + T^2\epsilon: exactly T2ϵT^2\epsilon more than the expert when the expert's own cost is 0.

Question 2

Suppose the task's cost is the imitation loss itself, C(s,a)=1{a≠πE(s)}C(s,a) = \mathbf 1\{a\ne\pi^E(s)\}. What is the recoverability constant uu, and what does the performance-difference bound give?

  1. u=Tu = T, so J(π)≤T2ϵπJ(\pi)\le T^2\epsilon_\pi
  2. u=1u = 1, so J(π)≤TϵπJ(\pi)\le T\epsilon_\pi
  3. u=0u = 0, so every policy is as good as the expert
  4. uu is undefined, because the expert's cost-to-go depends on the learner
Show the answer

B. u=1u = 1, so J(π)≤TϵπJ(\pi)\le T\epsilon_\pi

Under the imitation loss the expert's cost-to-go is 0 from every state, so a wrong action costs exactly 1 and the expert pays nothing afterwards: QkE(s,a)−VkE(s)=1{a≠πE(s)}≤1Q^E_k(s,a) - V^E_k(s) = \mathbf 1\{a\ne\pi^E(s)\}\le1. The bound becomes J(π)≤TϵπJ(\pi)\le T\epsilon_\pi, the number of mistakes the learner makes on its own trajectories.

Question 3

Why does the term 2ℓmax⁡min⁡(1,Tβi)2\ell_{\max}\min(1, T\beta_i) appear in DAgger's guarantee?

  1. It is the regret of follow-the-leader in round ii
  2. It accounts for estimating the loss from finitely many trajectories
  3. It is the recoverability constant of the expert
  4. Round ii's data come from the mixture πi\pi_i, whose state distribution differs from that of π^i\hat\pi_i by at most 2Tβi2T\beta_i in L1L_1, since the mixture follows π^i\hat\pi_i at all TT steps with probability (1−βi)T≥1−Tβi(1-\beta_i)^T\ge1-T\beta_i
Show the answer

D. Round ii's data come from the mixture πi\pi_i, whose state distribution differs from that of π^i\hat\pi_i by at most 2Tβi2T\beta_i in L1L_1, since the mixture follows π^i\hat\pi_i at all TT steps with probability (1−βi)T≥1−Tβi(1-\beta_i)^T\ge1-T\beta_i

The online learner is charged on the mixture's states, but the performance bound needs the learner's error on its own states. The lemma ∥dπi−dπ^i∥1≤2min⁡(1,Tβi)\norm{d_{\pi_i} - d_{\hat\pi_i}}_1\le2\min(1,T\beta_i) converts one into the other, which is why the expert's share must decay: βi≤1/T\beta_i\le1/T eventually, or a geometric schedule.

Question 4

Rajaraman et al. (2020) prove an Ω(∣S∣H2/N)\Omega(\abs{\mathcal S}H^2/N) lower bound that holds even for learners who can query the expert at the states they visit. What does it imply?

  1. DAgger's theorem must be wrong
  2. Behavior cloning is always the best method in practice
  3. Over all tabular MDPs, interaction cannot improve the worst-case horizon dependence; DAgger's linear bound relies on extra structure such as recoverability
  4. Knowing the transition model cannot help either
Show the answer

C. Over all tabular MDPs, interaction cannot improve the worst-case horizon dependence; DAgger's linear bound relies on extra structure such as recoverability

DAgger's guarantee uTϵNuT\epsilon_N is linear only when uu is small, and the hard instances behind the lower bound are not of that kind. The two results are consistent: one is a worst case over all MDPs, the other a guarantee under an assumption.

Further reading

  • S. Ross & J. A. Bagnell, "Efficient reductions for imitation learning," AISTATS (2010).
  • S. Ross, G. J. Gordon & J. A. Bagnell, "A reduction of imitation learning and structured prediction to no-regret online learning," AISTATS (2011).
  • N. Rajaraman, L. F. Yang, J. Jiao & K. Ramchandran, "Toward the fundamental limits of imitation learning," NeurIPS (2020).
  • G. Swamy, S. Choudhury, J. A. Bagnell & Z. S. Wu, "Of moments and matching: A game-theoretic framework for closing the imitation gap," ICML (2021).
  • D. J. Foster, A. Block & D. Misra, "Is behavior cloning all you need? Understanding horizon in imitation learning," NeurIPS (2024).