Stable Off-Policy Methods with Traces
Off-policy traces get the expected target right, but with they bootstrap, so off-policy plus bootstrapping plus function approximation is the deadly triad and the weights can diverge. This lesson carries the two one-step fixes to traces: GTD(λ) and GQ(λ) add a second weight vector and a gradient correction for true gradient descent on the projected Bellman error, while Emphatic TD(λ) reweights updates through a followon trace and interest to recover the on-policy stability.
╌╌╌╌
This builds on off-policy eligibility traces, which generalized and to functions of state, folded the importance ratio into the trace with a control variate, and built Watkins's Q() and Tree-Backup(). Every one of those methods was a semi-gradient method — correct in expectation, but with no stability guarantee once it bootstraps off-policy under function approximation. This lesson supplies the stable methods, then turns to the practical cost of running traces.
Stable off-policy methods with traces
Everything so far is a semi-gradient method, so with all of it bootstraps, and off-policy plus bootstrapping plus function approximation is the deadly triad: the weights can diverge to infinity, as Baird's counterexample showed. The same two families of one-step fixes from the deadly-triad lesson — Gradient-TD and Emphatic-TD — extend to carry traces.1 All assume linear function approximation, .
GTD() is the trace analogue of TDC, the better of the two Gradient-TD prediction methods. It follows a true stochastic-gradient direction on the projected Bellman error, so it is stable even off-policy. It keeps a second weight vector (initialized to ) and a second step size ,
with , , and defined as above. The extra term in the update — the one with — is the gradient correction that TDC adds to plain TD to make it a true gradient descent; is a slow secondary estimate of the expected TD error.
GQ() is the action-value counterpart, the Gradient-TD control method. It learns , and if is -greedy (or otherwise biased toward greedy in ) it serves as a stable control algorithm. Its update mirrors GTD() but with the average next feature vector under the target policy,
where the expectation-form TD error is and is the action-value off-policy trace. A useful hybrid, HTD(), sits between GTD() and TD(): it is a strict generalization of TD(), reducing to it exactly when the behavior policy happens to equal the target policy (something GTD() does not do), which lets it get by with a single step size whenever both agree.
Emphatic TD() takes the other route to stability — it reweights updates rather than correcting the gradient. It extends the one-step Emphatic-TD algorithm to traces, keeps strong off-policy convergence guarantees, and enables any degree of bootstrapping, at the cost of higher variance and possibly slower convergence. It needs no second weight vector,
but the trace itself is scaled by an emphasis built from a followon trace and the per-state interest ,
The followon trace accumulates how much later states follow on
from states we
care about, and the emphasis it produces steers learning toward the states that
matter under the target policy. The interest lets the user declare which
states the prediction should be accurate at; setting makes every
state equally interesting.
The two strategies differ even on-policy. With every , Emphatic TD() is not identical to conventional TD(), and the difference matters for guarantees: Emphatic TD() is proven to converge for all state-dependent functions, whereas TD() is guaranteed convergent only for constant — Yu's counterexample shows a variable on which TD() fails. So the emphatic weighting is not only an off-policy correction; it also provides convergence across the full variable- family, which the plain method cannot claim.
Implementation issues
A naive reading makes traces look expensive: every state (or state-action pair) seems to need its value and its trace updated on every step, which in the tabular case would be far more work than a one-step method. In practice it is not, because for typical and the traces of almost all states are almost always essentially zero. Only the handful of recently visited states carry a trace significantly above zero, and only those need updating to closely approximate the algorithm.2
Keeping only the significant traces makes the cost of tabular eligibility traces typically a small multiple — a few times — that of a one-step method, the exact factor depending on , , and the cost of the other computations. The tabular case is in a sense the worst case for trace overhead. Once function approximation is used the relative penalty shrinks: with an artificial neural network and backpropagation, adding traces roughly doubles the memory and computation per step, since the trace vector is simply another vector the size of . Truncated -return methods offer another efficient route on conventional computers, though they always demand some extra memory.
There is also the choice of trace vector itself, carried over from the on-policy lesson but now more consequential off-policy. The accumulating trace adds the new gradient on top of the decayed old trace and is the general form derived above. The dutch trace of true online methods folds a step-size term into the increment to achieve exact forward/backward equivalence. The older replacing trace, defined for binary features by overwriting the visited component to rather than incrementing it, guards against the runaway growth accumulating traces can suffer when a feature recurs quickly. Off-policy, the factors amplify traces further, so the choice of trace vector and the variance it induces is not a cosmetic detail.
| Trace | Update (linear, feature ) | Where it comes from |
|---|---|---|
| Accumulating | general TD(); off-policy scales by | |
| Dutch | true online TD(), exact equivalence | |
| Replacing | set trace of active binary feature to | older method, tames accumulation blowups |
Retrace and V-trace in deep RL
The off-policy trace of this lesson scales by the raw ratio , which is the source of its variance problem: a product of ratios can explode when the behavior policy rarely takes actions the target policy favors. Two developments after Sutton and Barto tame that product directly, and both are now standard in large-scale RL.
Retrace() (Munos, Stepleton, Harutyunyan, and Bellemare 2016, NeurIPS,
Safe and Efficient Off-Policy Reinforcement Learning
) replaces in the
trace with the clipped ratio . Clipping at caps the
per-step amplification so the trace can never blow up, no matter how far is from
— the property Retrace calls safe. Yet when the two policies agree the
clipped ratio stays near , so it does not needlessly cut traces short the way
Watkins's Q() does — the property it calls efficient. Retrace sits exactly
between the two crude ancestors this lesson built: it keeps the smooth,
importance-sampling-style correction but bounds it, and Munos et al. proved it
convergent (the same paper that established convergence of the tabular Watkins's
Q() this lesson mentions). Sutton and Barto cite this result
directly.3
V-trace (Espeholt et al. 2018, ICML, IMPALA: Scalable Distributed Deep-RL with Importance Weighted Actor-Learner Architectures
) carries the same clipping
into a distributed setting where many actors generate experience on slightly stale
policies while a central learner updates. V-trace uses two separately clipped
ratios: one, , weights the temporal-difference
error and controls the fixed point the value function converges to; another,
, forms the trace product and controls the speed of
convergence. Splitting the two clips lets IMPALA correct for the lag between actor
and learner policies without the variance of an unclipped product — the same
control-variate-and-clip philosophy as Retrace, engineered for throughput at
scale.4 Both methods are the direct descendants of the off-policy trace
derived here: keep the correction that makes the target right in
expectation, but bound the product that makes its variance dangerous.
What off-policy traces buy, and where the walls are
Traces plus TD errors give a cheap, incremental way to slide along the whole continuum from one-step TD to Monte Carlo, and the two generalizations of this lesson push that machinery to its most general form. Variable and turn the constants into functions, unify episodic and continuing tasks in a single stream, and fold termination into a state-dependent discount. Control variates fold the importance ratio into the trace and dampen the variance it brings, giving efficient off-policy TD() and Expected-Sarsa(). Watkins's Q() cuts the trace on the first non-greedy action; TB() replaces that hard cut with a smooth target-policy weighting and needs no importance sampling at all.
Two limits remain. The first is variance: every off-policy method built on importance sampling inherits its variance, and products can be large. Control variates reduce it; they do not remove it. The second is stability: whenever the algorithms bootstrap, so the deadly triad applies, and the plain semi-gradient forms can diverge under function approximation. That is what GTD(), GQ(), and Emphatic TD() are for — the trace-carrying descendants of the gradient-TD and emphatic fixes, trading a second weight vector or an emphasis reweighting for the convergence guarantee. Off-policy learning splits into two halves: correcting the expected value of the targets, which off-policy traces handle well, and correcting the distribution of updates, which is the hard half these stable methods address.
The policy-gradient lesson takes a different route to control entirely, optimizing a parameterized policy directly instead of deriving one from learned values — sidestepping the deadly triad rather than repairing it.
Footnotes
- Sutton & Barto, §12.11 — Stable Off-policy Methods with Traces: GTD() (analogue of TDC, update 12.30), GQ() (Gradient-TD control with average next feature ), HTD() as a strict TD() generalization, and Emphatic TD() with emphasis , followon trace , and interest ; Emphatic TD() converges for all state-dependent while TD() is guaranteed only for constant (Yu's counterexample). ↩
- Sutton & Barto, §12.12 — Implementation Issues: for typical almost all traces are near zero, so only the few significant ones need updating; the tabular case is the worst case, and function approximation (e.g. an ANN with backpropagation) roughly doubles per-step memory and computation. §12.13 — Conclusions: eligibility traces as the first line of defense for long-delayed rewards and non-Markov tasks. ↩
- Munos, Stepleton, Harutyunyan, and Bellemare (2016),
Safe and Efficient Off-Policy Reinforcement Learning
, Advances in Neural Information Processing Systems (NeurIPS): introduces Retrace(), which replaces the importance ratio in the trace with the clipped factor — bounded (safe) yet not needlessly truncating when policies agree (efficient) — and proves convergence, including for the tabular Watkins's Q(). Cited by Sutton & Barto (§12.10, Bibliographical Remarks). ↩ - Espeholt, Soyer, Munos, et al. (2018),
IMPALA: Scalable Distributed Deep-RL with Importance Weighted Actor-Learner Architectures
, ICML: introduces V-trace, using two separately clipped importance ratios — one weighting the TD error (setting the fixed point) and one forming the trace product (setting convergence speed) — to correct for policy lag between distributed actors and a central learner without unbounded variance. ↩
╌╌ END ╌╌