Divergence: Baird’s Counterexample
Seven states, eight weights, and values that run off to infinity.
Baird's counterexample is the standard proof that off-policy semi-gradient TD can fail, and it is small enough to analyze completely. This lesson computes its expected-update matrix exactly, finds the direction in which the weights escape and the precise discount, , above which they must escape, shows why positive definiteness is the wrong test (it already fails at , long before anything diverges), proves why the on-policy distribution is always safe for linear TD, and maps the other classic counterexamples, including on-policy divergence with a nonlinear approximator.
What you’ll learn
- Write off-policy semi-gradient TD and semi-gradient DP on Baird's counterexample as the mean iteration , and compute .
- Reduce by symmetry, derive that it has eigenvalues with negative real part exactly when , and identify the escaping direction.
- Prove the column-sum criterion for positive definiteness of the on-policy key matrix, and explain why it is sufficient but not necessary for stability.
- Describe the counterexamples of Tsitsiklis and Van Roy (fitted value iteration, off-trajectory updates, a nonlinear spiral) and why Gordon's averagers are safe.
The construction, exactly
Sutton and Barto's version of Baird's (1995) example has states and weights . The feature matrix, with states as rows, is
From any state, dashed moves to one of uniformly and solid moves to . The behavior policy takes dashed with probability , so its next state is uniform on all seven states and its stationary distribution is . The target policy always takes solid, so : every row sends all its probability to . All rewards are 0 and .
The true value function is 0, and it is representable in many ways: exactly for with , since and . Off-policy semi-gradient TD(0) with importance ratio (7 for solid, 0 for dashed) has expected update, given , . Averaging over ,
The spectrum, and the critical discount
commutes with permutations of the six upper states, so it splits into two invariant pieces. On the 5-dimensional subspace where and , it acts as : harmless. Everything interesting happens on the symmetric subspace , , .
On the symmetric subspace the estimates are (upper states) and (). The vector has entries on the upper states and on . Applying (component : ; component 7: ; component 8: ) gives restricted to :
: the null direction again. Let be the other two eigenvalues. Their sum is the trace, and their product is the sum of the principal minors (the coefficient of in the characteristic polynomial, since the third eigenvalue is 0):
The product is positive for . If are real they share a sign, the sign of their sum; if complex, their common real part is half the sum. Either way both real parts are negative exactly when the sum is:
At and , the dominant eigenvalue of is . By roughly what factor does the escaping component of the weights grow every 1,000 sweeps of semi-gradient DP?
Show the answer
11
Each sweep multiplies that component by , and . Iterating from , is about 335 after 1,000 sweeps and 4,050 after 2,000, while lock onto about , the shape of the unstable eigenvector . Halving halves the exponent; it never stops the growth.
The escaping direction has an intuition. Raise the shared weight alone: every upper state's estimate rises by 1, but its target rises by , so each upper state's TD error grows by , and the six of them, sampled six times as often as , push up further. Only 's own update pulls back, with weight and a tiny net error . Formally the diagonal entry is , negative for , and the escaping eigenvector is dominated by with the upper weights following at a third of its size.
Why on-policy updates are always stable
, so it suffices that the symmetric is positive definite. Because off-diagonal entries are nonpositive, row of has diagonal surplus equal to row sum plus column sum of :
A symmetric matrix with positive diagonal that is strictly diagonally dominant has only positive eigenvalues (Gershgorin's theorem). Now check the conditions on-policy. Diagonal , off-diagonal , row sums , and column sums by stationarity:
In Baird's problem with the behavior's and the target's , the sign pattern and the row sums are fine, but the target policy routes everyone's flow into :
The criterion is sufficient, not necessary. Baird's has more columns than rows, so always has the zero eigenvalue along ; the meaningful test is whether is positive whenever , that is, whether the symmetric part of is positive definite. Its smallest eigenvalue is , negative once . The column sum at is negative from , and even the diagonal entry from ; yet the mean dynamics stay stable until . At , for instance, the critical eigenvalues are , with positive real part. Stability is a statement about eigenvalues, positive definiteness about the symmetric part, and the gap between them is real.
Restricting updates to the target policy's own distribution is safe for a simple reason here: it puts all weight on , so , positive semidefinite. Every update moves the weights along only, multiplying by , so the weights converge to . Because the upper states share , their estimates end at : on-policy updates drive the error to 0 where the target policy goes, the only place the on-policy objective measures it, not everywhere.
Other counterexamples, and approximators that are safe
Fitted value iteration (Tsitsiklis & Van Roy, 1996; Sutton & Barto, Example 11.1). Even replacing each semi-gradient step by the exact least-squares fit of the backed-up values does not help. With features , a transition from the first state to the second, and the second state staying put with probability and terminating otherwise (all rewards 0), the uniformly weighted least-squares iteration is , divergent for : a projection that is non-expansive in a weighted norm composed with a backup that contracts in the max norm need contract in neither.
Off-trajectory updates (Tsitsiklis & Van Roy, 1997). Their analysis of linear TD identifies the condition that matters: updates must follow trajectories of the Markov chain being evaluated. They prove convergence under that condition and show divergence is possible when it is violated, which reconciles the earlier positive and negative results.
Nonlinear approximation, on-policy (Tsitsiklis & Van Roy, 1997). A three-state Markov chain with all costs zero, a single scalar parameter, and a nonlinear parameterization whose representable value functions trace a spiral in a plane: each backup rotates and scales the current estimate, the nearest point on the spiral lies further out, and TD(0) diverges although it samples on-policy. The positive-definiteness argument is a property of linear parameterizations; with nonlinear ones, on-policy sampling is no longer enough.
For control the picture is worse still. Q-learning with linear features can diverge in Baird-style examples, while for an -greedy behavior close to the greedy target policy Sutton and Barto (2018) note that no divergence had been found but no proof existed either. On-policy linear SARSA is bounded but may chatter (Gordon, 2001). Deep Q-learning, with nonlinear features and replay, sits inside every one of these warnings, which is why its stabilizers, and their limits, are studied empirically (The Deadly Triad).
Key takeaways
- On Baird's counterexample, off-policy semi-gradient TD and semi-gradient DP share the mean dynamics with .
- By symmetry the critical eigenvalues satisfy and , so the dynamics diverge for every step size exactly when ; at the weights grow about elevenfold per 1,000 sweeps at .
- On-policy, the key matrix has positive row and column sums and is positive definite; in Baird's problem the column of sums to . Positive definiteness is sufficient, not necessary, for stability.
- Fitted value iteration with least squares can diverge, nonlinear TD can diverge even on-policy, and averagers, being max-norm non-expansions, are safe.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Which weight vector makes every estimate in Baird's counterexample exactly 0?
- , or any multiple of it
- Only
Show the answer
B. , or any multiple of it
Upper states: ; : . Eight weights and seven independent feature vectors leave a one-dimensional null space, so exact solutions form a line. Divergence happens although the target is not just representable but representable in infinitely many ways.
At , Baird's key matrix has , so it is not positive definite. What happens to the mean iteration for small ?
- It converges, because every nonzero eigenvalue of has positive real part when
- It diverges, because is not positive definite
- It diverges only for large step sizes
- It neither converges nor diverges
Show the answer
A. It converges, because every nonzero eigenvalue of has positive real part when
Stability of a linear iteration depends on the eigenvalues, not on the symmetric part. At the critical pair is , with positive real part, so small steps converge (with oscillation). Positive definiteness is a convenient sufficient condition, which Baird's key matrix fails from on (its diagonal entry is negative from 0.625), well before the instability at .
What does Tsitsiklis and Van Roy's spiral example show?
- That linear TD can diverge on-policy
- That fitted value iteration diverges with averagers
- That importance sampling causes divergence
- That TD(0) can diverge on-policy when the value function is a nonlinear function of the parameters
Show the answer
D. That TD(0) can diverge on-policy when the value function is a nonlinear function of the parameters
Linear on-policy TD converges (positive definite key matrix). With a nonlinear parameterization whose representable functions form a spiral, each backup rotates the estimate and the closest representable point moves outward, so TD(0) diverges even with on-policy sampling and zero rewards.
Further reading
- L. Baird, "Residual algorithms: Reinforcement learning with function approximation", ICML (1995).
- R. S. Sutton & A. G. Barto, Reinforcement Learning: An Introduction, §9.4 and §11.2 (MIT Press, 2nd ed., 2018).
- J. N. Tsitsiklis & B. Van Roy, "Feature-based methods for large scale dynamic programming", Machine Learning 22 (1996).
- J. N. Tsitsiklis & B. Van Roy, "An analysis of temporal-difference learning with function approximation", IEEE Transactions on Automatic Control 42(5) (1997).
- G. J. Gordon, "Stable function approximation in dynamic programming", ICML (1995).