Skip to content
AI360Xpert
Beta

Baird's Counterexample

Baird's counterexample demonstrates that when bootstrapping, function approximation, and off-policy learning combine, reinforcement learning value estimates can amplify uncontrollably and explode to infinity.

Baird's 7-state star MDP demonstrates that linear semi-gradient TD methods can diverge exponentially to infinity under off-policy sampling.
Baird's 7-state star MDP demonstrates that linear semi-gradient TD methods can diverge exponentially to infinity under off-policy sampling.

Why Does This Exist?

In the early history of reinforcement learning, researchers believed that linear function approximation was inherently safe. Because the Mean Squared Value Error objective VE‾(w)\overline{\text{VE}}(\mathbf{w}) is a strictly convex quadratic bowl with a unique global optimum, intuition suggested that linear TD methods could never diverge.

In 1995, Leemon Baird shattered this assumption by constructing an ingeniously simple 7-state Markov Decision Process. Baird proved that even with:

  1. A simple linear value function v^(s,w)=w⊤x(s)\hat{v}(s, \mathbf{w}) = \mathbf{w}^\top \mathbf{x}(s),
  2. A deterministic transition model where every single reward is zero (R=0R = 0), and
  3. An infinitesimal step size α>0\alpha > 0,

standard semi-gradient Temporal Difference learning diverges exponentially to infinity (∥wt∥→∞\|\mathbf{w}_t\| \to \infty).

Baird's counterexample is historically famous because it provides the concrete mathematical proof of the Deadly Triad: the dangerous confluence of Function Approximation, Bootstrapping, and Off-Policy Learning. Whenever all three conditions coincide, semi-gradient updates cease to be a contraction mapping, causing value estimates to destabilize and self-amplify without bound.

Think of It Like This

The Acoustic Microphone Feedback Squeal

Imagine an audio technician setting up a microphone on a stage directly facing an amplified loudspeaker:

  1. The Audio Loop: A tiny ambient whisper enters the microphone. The amplifier magnifies the signal by 1.05×1.05\times and broadcasts it out through the speaker.
  2. The Resonant Frequency: Because the speaker is pointed directly at the microphone, that amplified sound immediately re-enters the microphone ten milliseconds later.
  3. The Squeal: The amplifier magnifies it again: 1.05×1.05=1.1025×1.05 \times 1.05 = 1.1025\times. Within two seconds, what started as silence escalates into an ear-piercing, deafening screech that hits the system's maximum acoustic limits.

In Baird's counterexample:

  • The microphone is the bootstrapped next-state estimate v^(St+1,w)\hat{v}(S_{t+1}, \mathbf{w}).
  • The amplifier is the semi-gradient TD update rule that shifts weights upward toward the target.
  • The speaker orientation is the off-policy sampling distribution, which repeatedly feeds target estimates back into earlier states without sufficient on-policy damping.

Even though there is zero external acoustic input (all environmental rewards R=0R = 0), the internal recursion forms an unconstrained positive feedback loop that blows up to infinity.

Where the analogy stops: An audio amplifier eventually saturates due to physical voltage clipping in copper wires. In pure mathematics and floating-point computation, Baird's counterexample has no ceiling—weights compound exponentially until they overflow 64-bit IEEE floating-point numbers into +inf or NaN.

How It Actually Works

The 7-State Star MDP Specification

Baird's counterexample consists of seven states S={s1,s2,s3,s4,s5,s6,s7}\mathcal{S} = \{s_1, s_2, s_3, s_4, s_5, s_6, s_7\} and two actions:

  • Upper states: Six satellite states s1,s2,…,s6s_1, s_2, \dots, s_6.
  • Lower state: One central hub state s7s_7.

The MDP has two actions available in every state:

  1. Solid Action: Deterministically transitions the agent to the lower state s7s_7.
  2. Dashed Action: Transitions the agent uniformly to one of the six upper states {s1,…,s6}\{s_1, \dots, s_6\}, each with probability 16\frac{1}{6}.

Every transition in the environment yields a reward of zero: Rt+1=0∀s,aR_{t+1} = 0 \quad \forall s, a The discount factor is set near unity: γ=0.99\gamma = 0.99.

Target Policy vs. Behavior Policy (Off-Policy Setting)

  • Target Policy π\pi: Deterministically chooses the solid action (π(solid∣s)=1.0\pi(\text{solid} \mid s) = 1.0). Under π\pi, the agent always transitions to s7s_7.
  • Behavior Policy bb: Chooses the dashed action with probability 56\frac{5}{6} and the solid action with probability 16\frac{1}{6}: b(dashed∣s)=56,b(solid∣s)=16b(\text{dashed} \mid s) = \frac{5}{6}, \quad b(\text{solid} \mid s) = \frac{1}{6}

Because the behavior policy's transitions are independent of the current state, the stationary state distribution under bb is: μ(si)=56×16=536(i=1…6),μ(s7)=16=636\mu(s_i) = \frac{5}{6} \times \frac{1}{6} = \frac{5}{36} \quad (i = 1 \dots 6), \quad \mu(s_7) = \frac{1}{6} = \frac{6}{36}

Linear Feature Parameterization

The value function is represented linearly with seven parameters w=[w1,w2,…,w7]⊤∈R7\mathbf{w} = [w_1, w_2, \dots, w_7]^\top \in \mathbb{R}^7:

  • For upper states s1…s6s_1 \dots s_6: x(si)=2ei+e7  ⟹  v^(si,w)=2wi+w7(i=1…6)\mathbf{x}(s_i) = 2 \mathbf{e}_i + \mathbf{e}_7 \implies \hat{v}(s_i, \mathbf{w}) = 2 w_i + w_7 \quad (i = 1 \dots 6)
  • For the lower state s7s_7: x(s7)=e1+2e7  ⟹  v^(s7,w)=w1+2w7\mathbf{x}(s_7) = \mathbf{e}_1 + 2 \mathbf{e}_7 \implies \hat{v}(s_7, \mathbf{w}) = w_1 + 2 w_7

Notice that the true value of every state under target policy π\pi is exactly zero (vπ(s)=0v_\pi(s) = 0), which is perfectly representable by setting w∗=0\mathbf{w}^* = \mathbf{0}.

The Deadly Triad and Analytical Divergence

When training semi-gradient TD(0) off-policy with importance sampling ratio ρt=π(At∣St)b(At∣St)\rho_t = \frac{\pi(A_t \mid S_t)}{b(A_t \mid S_t)}:

  • When the behavior policy selects the dashed action: ρt=π(dashed)b(dashed)=05/6=0  ⟹  Δw=0\rho_t = \frac{\pi(\text{dashed})}{b(\text{dashed})} = \frac{0}{5/6} = 0 \implies \Delta \mathbf{w} = \mathbf{0}
  • When the behavior policy selects the solid action (probability 16\frac{1}{6}): ρt=π(solid)b(solid)=11/6=6\rho_t = \frac{\pi(\text{solid})}{b(\text{solid})} = \frac{1}{1/6} = 6 The next state is guaranteed to be s7s_7, with reward R=0R = 0. The semi-gradient update for state St=sS_t = s is: Δw=αρt[0+γv^(s7,w)−v^(s,w)]x(s)\Delta \mathbf{w} = \alpha \rho_t \left[ 0 + \gamma \hat{v}(s_7, \mathbf{w}) - \hat{v}(s, \mathbf{w}) \right] \mathbf{x}(s)

Taking the expectation over the behavior distribution μ(s)\mu(s), the factor of 66 in ρt\rho_t exactly cancels the probability 16\frac{1}{6}:

E[Δw]=α∑s=17μ(s)[γw⊤x(s7)−w⊤x(s)]x(s)=−αAw\mathbb{E}[\Delta \mathbf{w}] = \alpha \sum_{s=1}^7 \mu(s) \left[ \gamma \mathbf{w}^\top \mathbf{x}(s_7) - \mathbf{w}^\top \mathbf{x}(s) \right] \mathbf{x}(s) = -\alpha \mathbf{A} \mathbf{w}

where the expected key transition matrix A∈R7×7\mathbf{A} \in \mathbb{R}^{7 \times 7} is:

A=∑s=17μ(s)x(s)(x(s)−γx(s7))⊤\mathbf{A} = \sum_{s=1}^7 \mu(s) \mathbf{x}(s) \left( \mathbf{x}(s) - \gamma \mathbf{x}(s_7) \right)^\top

The Eigenvalue Instability of the TD Operator

In stable on-policy linear TD, the matrix A\mathbf{A} is guaranteed to be positive definite (all eigenvalues have positive real parts), meaning −αA-\alpha \mathbf{A} pulls weights inward toward the origin like a damped spring.

In Baird's counterexample, computing the eigenvalues of A\mathbf{A} reveals that two eigenvalues have negative real parts: Re(λ1)≈−0.5227,Re(λ2)≈−0.0040\text{Re}(\lambda_1) \approx -0.5227, \quad \text{Re}(\lambda_2) \approx -0.0040

In the discrete update equation: wk+1=(I−αA)wk\mathbf{w}_{k+1} = (\mathbf{I} - \alpha \mathbf{A}) \mathbf{w}_k any eigenvector associated with a negative eigenvalue of A\mathbf{A} corresponds to an eigenvalue of (I−αA)(\mathbf{I} - \alpha \mathbf{A}) strictly greater than 1: 1−α(−0.5227)=1+0.5227α>11 - \alpha (-0.5227) = 1 + 0.5227 \alpha > 1

At every iteration, the projection along this unstable eigenvector is multiplied by a factor strictly greater than one, generating an exponential explosion: ∥wk∥∝(1+0.5227α)k→k→∞∞\|\mathbf{w}_k\| \propto (1 + 0.5227 \alpha)^k \xrightarrow{k \to \infty} \infty

Worked numerical example

Let initial weights be: w0=[1.0,1.0,1.0,1.0,1.0,1.0,10.0]⊤,α=0.01,γ=0.99\mathbf{w}_0 = \begin{bmatrix} 1.0, & 1.0, & 1.0, & 1.0, & 1.0, & 1.0, & 10.0 \end{bmatrix}^\top, \quad \alpha = 0.01, \quad \gamma = 0.99 Initial weight vector norm: ∥w0∥=6(1.02)+10.02=106≈10.2956\|\mathbf{w}_0\| = \sqrt{6(1.0^2) + 10.0^2} = \sqrt{106} \approx \mathbf{10.2956}

Step 1: First Expected Update

Multiplying by the expected transition matrix A\mathbf{A}: Δw0=−αAw0=[+0.0241,+0.0244,+0.0244,+0.0244,+0.0244,+0.0244,+0.0726]⊤\Delta \mathbf{w}_0 = -\alpha \mathbf{A} \mathbf{w}_0 = \begin{bmatrix} +0.0241, & +0.0244, & +0.0244, & +0.0244, & +0.0244, & +0.0244, & +0.0726 \end{bmatrix}^\top

New weight vector: w1=w0+Δw0=[1.0241,1.0244,1.0244,1.0244,1.0244,1.0244,10.0726]⊤\mathbf{w}_1 = \mathbf{w}_0 + \Delta \mathbf{w}_0 = \begin{bmatrix} 1.0241, & 1.0244, & 1.0244, & 1.0244, & 1.0244, & 1.0244, & 10.0726 \end{bmatrix}^\top ∥w1∥≈10.3804(>10.2956)\|\mathbf{w}_1\| \approx \mathbf{10.3804} \quad (> 10.2956)

Step 2: Second Expected Update

w2=[1.0483,1.0490,1.0490,1.0490,1.0490,1.0490,10.1455]⊤\mathbf{w}_2 = \begin{bmatrix} 1.0483, & 1.0490, & 1.0490, & 1.0490, & 1.0490, & 1.0490, & 10.1455 \end{bmatrix}^\top ∥w2∥≈10.4657(>10.3804)\|\mathbf{w}_2\| \approx \mathbf{10.4657} \quad (> 10.3804)

Step 3: Third Expected Update

w3=[1.0726,1.0736,1.0736,1.0736,1.0736,1.0736,10.2188]⊤\mathbf{w}_3 = \begin{bmatrix} 1.0726, & 1.0736, & 1.0736, & 1.0736, & 1.0736, & 1.0736, & 10.2188 \end{bmatrix}^\top ∥w3∥≈10.5517(>10.4657)\|\mathbf{w}_3\| \approx \mathbf{10.5517} \quad (> 10.4657)

Long-Term Trajectory

By step 1,000, the weight norm reaches ∥w1000∥≈3,302.63\|\mathbf{w}_{1000}\| \approx \mathbf{3,302.63}. By step 2,000, it surpasses 1.2×1061.2 \times 10^6. The weights diverge exponentially toward infinity without ever stabilizing.

Code

from typing import List, Tupleimport numpy as np

def build_bairds_counterexample() -> (    Tuple[np.ndarray, np.ndarray, np.ndarray]):    """Construct the feature matrix X, stationary distribution mu, and matrix A for Baird's 7-state MDP."""    # 7 states x 7 features    num_states = 7    num_features = 7    gamma = 0.99
    X = np.zeros((num_states, num_features))    # Upper states s_1 .. s_6: 2 * e_i + e_7    for i in range(6):        X[i, i] = 2.0        X[i, 6] = 1.0    # Lower state s_7: e_1 + 2 * e_7    X[6, 0] = 1.0    X[6, 6] = 2.0
    # Stationary distribution under behavior policy b:    # 5/6 chance of dashed action (uniformly transitions to s_1..s_6 with 1/6 each)    # 1/6 chance of solid action (transitions to s_7)    mu = np.array([5.0 / 36.0] * 6 + [6.0 / 36.0])
    # Transition matrix A: E_b [ rho_t * x_t * (x_t - gamma * x_{t+1})^T ]    # Solid action is taken under b with prob 1/6, with importance ratio rho = 6.    # Solid action always leads to s_7.    x_7 = X[6]    A = np.zeros((num_features, num_features))    for s in range(num_states):        A += mu[s] * np.outer(X[s], X[s] - gamma * x_7)
    return X, mu, A

def simulate_bairds_divergence(    alpha: float = 0.01, num_steps: int = 1000) -> Tuple[List[float], np.ndarray]:    """Run expected semi-gradient TD updates on Baird's counterexample."""    _, _, A = build_bairds_counterexample()
    # Initial weights: w_0 = [1, 1, 1, 1, 1, 1, 10]^T    w = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0])    norms: List[float] = [float(np.linalg.norm(w))]
    for _ in range(num_steps):        # Semi-gradient expected update: w_{k+1} = w_k - alpha * A @ w_k        w = w - alpha * (A @ w)        norms.append(float(np.linalg.norm(w)))
    return norms, w

if __name__ == "__main__":    X, mu, A = build_bairds_counterexample()    eigenvalues = np.linalg.eigvals(A)
    print("=== Baird's Counterexample Matrix Analysis ===")    print("Real parts of eigenvalues of transition matrix A:")    for ev in np.real(eigenvalues):        print(f"  lambda_Re = {ev:+.6f}")
    # Check for negative eigenvalues (proof of instability)    has_negative_ev = any(np.real(ev) < -1e-4 for ev in eigenvalues)    assert (        has_negative_ev    ), "Matrix A must possess negative eigenvalues for divergence!"    print(        f"\nInstability verified: Matrix A has negative eigenvalues (e.g. {min(np.real(eigenvalues)):.4f})."    )
    # Simulate 1000 steps of expected semi-gradient updates    norms, final_w = simulate_bairds_divergence(alpha=0.01, num_steps=1000)
    print("\n=== Exponential Weight Divergence ===")    print(f"Initial Weight Norm ||w_0||:     {norms[0]:.4f}")    print(f"Norm after 100 steps ||w_100||:   {norms[100]:.4f}")    print(f"Norm after 500 steps ||w_500||:   {norms[500]:.4f}")    print(f"Norm after 1000 steps ||w_1000||: {norms[1000]:.4f}")
    # Assert that weights diverge by orders of magnitude    assert (        norms[1000] > norms[0] * 100.0    ), "Weights must explode by over 100x!"    print(        f"\nVerification passed: Weight norm grew by {norms[1000] / norms[0]:.1f}x across 1,000 steps."    )
# Expected Output:# === Baird's Counterexample Matrix Analysis ===# Real parts of eigenvalues of transition matrix A:#   lambda_Re = +0.554490#   lambda_Re = -0.003993#   lambda_Re = -0.522719#   lambda_Re = +0.555556#   lambda_Re = +0.555556#   lambda_Re = +0.555556#   lambda_Re = +0.555556## Instability verified: Matrix A has negative eigenvalues (e.g. -0.5227).## === Exponential Weight Divergence ===# Initial Weight Norm ||w_0||:     10.2956# Norm after 100 steps ||w_100||:   22.0383# Norm after 500 steps ||w_500||:   269.4678# Norm after 1000 steps ||w_1000||: 3302.6332## Verification passed: Weight norm grew by 320.8x across 1,000 steps.

Watch Out For

Assuming Linear Models and Zero Rewards Guarantee Convergence

Many practitioners mistakenly assume that divergence in deep reinforcement learning is caused exclusively by non-linear neural network activations (ReLUs, Sigmoids), exploding gradient clipping failures, or massive reward scales.

Baird's counterexample definitively disproves this belief:

  • The function approximator is strictly linear (w⊤x(s)\mathbf{w}^\top \mathbf{x}(s)).
  • The transition dynamics are completely stationary.
  • Every single reward is zero (R=0R = 0), meaning there is no reward magnitude to explode.
  • The step size α=0.01\alpha = 0.01 is small and conservative.

Divergence occurs purely because the Deadly Triad is present: off-policy sampling breaks the contraction property of the Bellman operator under the linear projection norm, turning semi-gradient updating into an explosive linear dynamical system.

The Fix:

  1. Break the Triad by Learning On-Policy: If you train SARSA or on-policy TD on Baird's counterexample, weights converge stably to the global optimum w∗=0\mathbf{w}^* = \mathbf{0}.
  2. True Gradient Off-Policy Algorithms (Gradient TD): Use GTD2 or TDC (Sutton et al., 2009), which minimize the Mean Squared Projected Bellman Error (MSPBE) via true gradient descent, mathematically guaranteeing convergence on Baird's counterexample.
  3. Emphatic TD (ETD): Use Emphatic TD (Sutton, Mahmood, White, 2016), which reweights updates by an emphasis scalar MtM_t to restore positive definiteness to the system matrix A\mathbf{A}.

The Quick Version

  • The classic proof of divergence: Leemon Baird's 1995 7-state star MDP proves that linear semi-gradient TD can diverge to infinity when updating off-policy.
  • Zero rewards cannot save you: Even when every reward is 00 and the true value of every state is 00, weights explode exponentially (∥w∥→∞\|\mathbf{w}\| \to \infty) due to unstable operator eigenvalues.
  • The Deadly Triad: Instability arises whenever Function Approximation, Bootstrapping, and Off-Policy Training intersect simultaneously.
  • The algorithmic remedies: Stability is restored by either eliminating off-policy training, applying true-gradient methods (GTD2/TDC), or reweighting transitions via Emphatic TD.