Convergence of TD: Stochastic Approximation
Robbins–Monro conditions, the ODE method and finite-time bounds.
Each TD(0) step changes a single entry of the table, using one noisy transition and a target made from the table itself. Why should that converge, and how fast? This lesson treats TD as stochastic approximation: an ordinary differential equation whose global stability follows from the contraction of the Bellman operator, step sizes that make or break convergence (with steps, TD can need a number of updates exponential in the effective horizon), and the finite-time bounds of the late 2010s, including what changes when the samples come from one correlated trajectory.
What you’ll learn
- Cast asynchronous TD(0) as stochastic approximation, identify its mean field, and state the Robbins–Monro conditions and the ODE method with its stability hypotheses.
- Prove global exponential stability of the TD(0) ODE with a max-norm Lyapunov function, and derive the weighted-norm inequality that drives finite-time analyses.
- Show that step sizes can make TD exponentially slow in the effective horizon, and compare constant, rescaled-linear and averaged step sizes.
- State finite-time bounds for TD with i.i.d. and Markovian samples, and the minimax and instance-dependent sample complexity of tabular TD, with their conditions.
TD(0) as stochastic approximation
Robbins and Monro (1951) asked how to find a root of a function that can only be measured with noise, and answered with an iteration of the form
where is the mean field and is noise with . TD(0) has exactly this shape. Write for the unit vector of state . The update is , and if the updated state is drawn from a distribution (and the transition from and ), its conditional mean is
The root of is the fixed point of : . The noise is a martingale difference whose conditional second moment grows at most quadratically, , for bounded rewards.
The intuition: on the time scale , the iterates follow the ODE , because the accumulated noise is a martingale with summable variance, which converges. The first Robbins–Monro condition makes the ODE clock run forever; the second silences the noise. For TD(0), is affine and its scaled limit is , so both conditions reduce to the stability of one linear system.
Two details matter for tabular TD. If each state keeps its own step sequence over its visits, the natural conditions are and for every state. For max-norm contractions such as TD's, these per-state conditions suffice (Jaakkola, Jordan & Singh, 1994; Tsitsiklis, 1994), while the ODE version of the argument needs mild extra regularity on how often states are updated. And when the states come from a single trajectory instead of independent draws, the noise is Markovian; extensions of the ODE method cover it, with the chain's stationary distribution (Borkar, 2008).
Why the TD ODE is stable: two Lyapunov functions
Let . Since and is affine, the error obeys a linear ODE:
Let , attained at some coordinate with . Because is a stochastic matrix, , so the largest coordinate shrinks:
The upper derivative of a maximum is at most the largest derivative among the coordinates that attain it, so , and Grönwall's inequality gives the exponential bound.
The proof used no property of beyond positivity. Tabular TD(0) is stable under any state-sampling distribution with full support, on-policy or not, as long as each transition follows . What breaks off-policy TD is function approximation, not the sampling distribution itself.
The second Lyapunov function is the one that generalizes to features. Take and suppose is the stationary distribution of . Then by Jensen's inequality and stationarity, where , and Cauchy–Schwarz in the -inner product gives
The expected TD update always points at least partly toward , by an amount measured in the stationary norm. TD is not the gradient of any objective, but this inequality lets its analysis mirror that of stochastic gradient descent on a strongly convex function. With features it becomes the key lemma of the finite-time analysis below, (Bhandari, Russo & Singal, 2018), and it is also the heart of Tsitsiklis and Van Roy's (1997) convergence proof for linear TD.
Tabular TD(0) evaluates , but the states to update are chosen from an arbitrary fixed distribution with everywhere (each chosen state's transition still follows ). With Robbins–Monro steps, what happens?
- It can diverge, because is not the stationary distribution of : the deadly triad
- It converges to , because the max-norm argument needs only
- It converges, but to the values of the policy that generates
- It converges only if is uniform
Show the answer
B. It converges to , because the max-norm argument needs only
The max-norm Lyapunov proof uses only that every state is sampled with positive probability and that is stochastic. The deadly triad needs function approximation as well; in a table, every state has its own parameter and the off-policy state distribution only changes the speed, through .
Step sizes: why 1/n can be a trap
The Robbins–Monro conditions say whether TD converges, not how fast. The step is the natural choice, since it turns averaging into the exact sample mean, and for Monte Carlo it is optimal. For a bootstrapping method it can be disastrous. The smallest example shows why.
A single state loops to itself with a deterministic reward , so and there is no noise at all. TD(0) with gives an error that obeys
The product telescopes into Gamma functions, and :
The error decays only like . Reaching a fraction of the initial error takes about updates: polynomial in , but with an exponent equal to the effective horizon, so exponential in it for a fixed accuracy. The cause is that each step contracts the error by the factor instead of : bootstrapping passes most of the old error into the new target.
In the one-state loop with and , what fraction of the initial error is still left after one million updates?
Show the answer
0.235
; multiplying out the product exactly gives the same. Getting down to 1% would take about updates. At , about 87% of the error is left after a million updates. A constant would remove 99% of this noiseless error in about 460 updates.
| Step size | Noiseless error after steps | With noise |
|---|---|---|
| : exponentially slow in the horizon | converges, but slowly | |
| constant | : fast | does not converge; hovers with mean squared error of order |
| rescaled linear, | exactly : order | converges at the usual statistical rate |
| polynomial, with | converges; error of order | |
| constant or polynomial steps with iterate averaging | fast, as for the steps used | asymptotically optimal covariance (Polyak & Juditsky, 1992) |
Finite-time bounds and sample complexity
Asymptotic convergence says nothing about a finite budget. The late 2010s produced explicit bounds, stated for linear TD(0), , which includes the tabular case with .
The analysis is the stochastic-gradient template with the inequality of the previous step in the role of strong convexity: the expected update points toward with strength , and the noise adds a term proportional to the step. Srikant and Ying (2019) removed the projection for constant steps with Markovian noise, using a Lyapunov function found by Stein's method: the mean squared error decays geometrically to a steady-state level of order . They also showed that the steady-state error need not have light tails: in their example, moments of high enough order (growing faster than ) are infinite.
How many samples does tabular TD need? With a generative model that samples every state in each round, and accuracy measured in the max norm, synchronous TD needs on the order of samples up to logarithmic factors, which matches the minimax lower bound for policy evaluation; Q-learning, by contrast, needs order , one horizon factor more, and this is tight for it (Li, Cai, Chen, Wei & Chi, 2024). Minimax optimality is a worst-case statement. On a particular problem, Khamaru, Pananjady, Ruan, Wainwright and Jordan (2021) show that TD with Polyak–Ruppert averaging can be strictly worse than the instance-dependent optimum, while a variance-reduced variant attains it up to logarithmic factors.
Key takeaways
- Tabular TD(0) is stochastic approximation with mean field and martingale-difference noise; the ODE method of Borkar and Meyn turns stability of and of its scaled limit into almost-sure convergence.
- The max norm is a Lyapunov function: decays at rate for any sampling distribution with full support; under the stationary distribution, the expected update satisfies .
- With the error of a bootstrapping method can decay like , exponentially slow in the effective horizon; constant, rescaled-linear, polynomial and averaged steps avoid this.
- Finite-time bounds give rates with constants in , a noise ball of order (times the mixing time for Markovian data) for constant steps, and a minimax-optimal sample complexity for synchronous TD.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
States to update are drawn from a distribution and transitions follow . What is the mean field of tabular TD(0)?
- with
Show the answer
B. with
Only the sampled state moves, by , and . Weighting by how often each state is sampled gives , whose root is .
You want tabular TD(0) to converge with probability 1 (both Robbins–Monro conditions) and to escape the slowdown that steps cause at long horizons. Which schedule for the -th update of a state does both?
- , the exact running mean
Show the answer
B.
and , so both conditions hold, and in the noiseless loop the error shrinks like : for a fixed accuracy the number of updates is polynomial, not exponential, in the effective horizon. The rescaled linear step from the lesson's step-size table also does both.
Why can TD(0) with be extremely slow when is close to 1, even without any noise?
- Because violates the Robbins–Monro conditions
- Because each step shrinks the error only by the factor , so it decays like
- Because the TD error is biased, so TD converges to the wrong value
- Because the variance of the updates grows with
Show the answer
B. Because each step shrinks the error only by the factor , so it decays like
Bootstrapping feeds most of the current error back into the target, so the effective contraction per step is instead of . The product decays like : about 77% of the error is gone after a million steps at , but only 13% at .
With a generative model and max-norm accuracy , which statement about sample complexity is correct (up to logarithmic factors)?
- TD and Q-learning both need order samples
- TD needs order , one horizon factor above the lower bound
- No finite-sample bound is known for tabular TD
- Synchronous TD needs order , matching the minimax lower bound, while Q-learning needs order
Show the answer
D. Synchronous TD needs order , matching the minimax lower bound, while Q-learning needs order
Li, Cai, Chen, Wei and Chi (2024) settled both: TD (the one-action case) is minimax optimal, and Q-learning's extra horizon factor is real, a consequence of the overestimation that the max introduces. Variance-reduced and model-based methods attain the rate for control.
Further reading
- V. S. Borkar & S. P. Meyn, "The O.D.E. method for convergence of stochastic approximation and reinforcement learning," SIAM Journal on Control and Optimization 38(2), 447–469 (2000).
- J. N. Tsitsiklis, "Asynchronous stochastic approximation and Q-learning," Machine Learning 16, 185–202 (1994).
- J. Bhandari, D. Russo & R. Singal, "A finite time analysis of temporal difference learning with linear function approximation," Conference on Learning Theory (COLT) (2018); Operations Research 69(3), 950–973 (2021).
- R. Srikant & L. Ying, "Finite-time error bounds for linear stochastic approximation and TD learning," Conference on Learning Theory (COLT) (2019).
- G. Li, C. Cai, Y. Chen, Y. Wei & Y. Chi, "Is Q-learning minimax optimal? A tight sample complexity analysis," Operations Research 72(1), 222–236 (2024).