Asynchronous and Prioritized Dynamic Programming
Keeping the gamma-contraction but varying the schedule: asynchronous and Gauss–Seidel value iteration, prioritized sweeping, and real-time DP. Why the order of backups is free — monotonicity plus a constant-shift identity — and how update order and residual size set the practical convergence rate.
On this page
- Generalized policy iteration: the space between the poles
- Asynchronous value iteration
- Why the order is free: monotonicity and the constant-shift identity
- Gauss–Seidel sweeps and the numerical-analysis analogy
- The Bellman residual and residual scheduling
- Prioritized sweeping
- Real-time dynamic programming
- Counting the work: iterations and samples
- The dynamic-programming bridge
- What’s next
- Exercises
- Companion code
Asynchronous and Prioritized Dynamic Programming
Where we are. Chapter 1 proved that value iteration and policy iteration both reach the optimal value function because the Bellman operators are -contractions. Both methods share one extravagance: every sweep backs up every state, in lockstep, whether or not that state’s value has stopped moving. This chapter keeps the contraction and varies only the schedule — which states we back up, in what order, and using whose values. The load-bearing claim is that the order is nearly free: as long as every state is updated infinitely often, asynchronous dynamic programming converges to the same fixed point , and ordering the updates well — Gauss–Seidel, prioritized sweeping, real-time DP — buys large savings without touching the convergence theory.
Generalized policy iteration: the space between the poles
Chapter 1 closed by naming value iteration and policy iteration the two poles of generalized policy iteration (GPI): VI applies one optimality backup everywhere and reads off a greedy policy at the end; PI evaluates a policy exactly (a linear solve) and then improves it greedily. The methods in between truncate the evaluation. Modified policy iteration Puterman (1994) runs sweeps of the expectation operator in place of the exact solve: recovers value iteration, recovers policy iteration, and intermediate trades evaluation cost against the number of outer improvements. Sutton & Barto Sutton & Barto (2018) frame the entire family as two interacting processes — make the value consistent with the policy, make the policy greedy for the value — that converge to the same fixed point regardless of how finely they are interleaved.
This chapter relaxes a different lockstep: not how much we evaluate between improvements, but which states we touch on each pass and in what order.
Asynchronous value iteration
Synchronous value iteration computes the whole vector from and only then overwrites — every state is backed up from the same old values. Asynchronous value iteration drops that barrier.
Asynchronous value iteration maintains a single value vector and repeats: select a state and overwrite
using the current entries of — including any updated earlier in the pass. States may be visited in any order, subject only to the fairness condition that every state is selected infinitely often. The special case that sweeps the states in a fixed order , each backup seeing the freshly written values of its predecessors, is Gauss–Seidel value iteration.
The synchronous operator of Chapter 1 reuses no in-pass information; Gauss–Seidel reuses all of it; general asynchronous iteration lives anywhere between. The question is whether dropping the barrier costs us the convergence guarantee. It does not, and the reason is two structural facts that cost one line each.
Why the order is free: monotonicity and the constant-shift identity
Let be either Bellman operator ( or ). For all and every constant , writing for the all-ones vector:
- Monotonicity. If componentwise, then .
- Constant-shift. .
Both read off the backup , of which and .
Monotonicity. If then because the transition weights are nonnegative; hence for every , and taking the (or the -average) over preserves the inequality.
Constant-shift. Since , replacing by adds exactly to every ; and (likewise for the average).
These two facts — and not the full contraction algebra — are what make asynchronous order irrelevant.
Run asynchronous value iteration (Def. 2.1) from any , updating every state infinitely often. Then . Moreover, grouping the schedule into rounds — a round ends once every state has been backed up at least once since the round began — the sup-norm error contracts by a factor per round:
Let , so the iterate starts inside the box . Suppose at some moment lies in this box. Back up any state . By monotonicity and then constant-shift (Prop. 2.1), using ,
So the updated entry lands in the smaller box (as ). Two consequences: the iterate never leaves the original -box, and every state, once backed up, sits in the -box. Crucially, later backups in the round still read values inside the original -box, so they too map into the -box. Hence after one full round . Applying the argument round by round gives after rounds; fairness guarantees infinitely many rounds, so .
Synchronous value iteration is the special case in which a round is a single simultaneous sweep, and the bound collapses to Chapter 1’s . The abstract version — monotone contraction operators converge under any fair asynchronous schedule — is the backbone of Bertsekas’s treatment of dynamic programming Bertsekas (2017) .
Gauss–Seidel sweeps and the numerical-analysis analogy
The names are borrowed deliberately. Solving a linear system by splitting and iterating, Jacobi updates every coordinate from the previous iterate (a synchronous sweep), while Gauss–Seidel updates coordinate using the already-updated coordinates — in place, no second buffer. Value iteration is the nonlinear analogue: synchronous VI is Jacobi, Gauss–Seidel VI is Gauss–Seidel. The in-place version typically converges in fewer sweeps because information propagates across the state space within a single pass rather than waiting a full sweep per hop, and it halves the memory (no separate buffer). Theorem 2.1 already covers it: a left-to-right sweep updates every state once, so it is exactly one round.
The order within a sweep is now a design lever. If states are numbered along the direction reward information flows — outward from a goal, say — a single Gauss–Seidel sweep can propagate values across the whole space, whereas the reverse order wastes most of the pass. This is the seed of prioritizing the order rather than fixing it.
The Bellman residual and residual scheduling
How do we know where values are still moving? The same quantity that certifies stopping. Recall from Chapter 1 the local Bellman residual at a state, the amount one more backup would change it,
and that the global residual controls the true error through . A uniform sweep spends equal effort on states with (already converged) and on states with large (still far off). Residual scheduling is the obvious correction: back up states in decreasing order of , and skip states whose residual sits below a tolerance . Asynchronous convergence (Thm. 2.1) licenses any such order as long as no state is starved.
Prioritized sweeping
Prioritized sweeping Moore & Atkeson (1993) makes residual scheduling precise with a priority queue, and adds the key idea that a backup only changes a state’s predecessors, so only their priorities need refreshing.
initialize V ← 0; priority queue PQ keyed by Bellman residual
seed PQ with every state s at priority |(𝒯* V)(s) − V(s)|
repeat:
s ← PQ.pop_max() # largest-residual state
V(s) ← (𝒯* V)(s) # one optimality backup
for each (s̄, a) with p(s | s̄, a) > 0: # predecessors that feed s
e ← |(𝒯* V)(s̄) − V(s̄)| # their refreshed residual
if e > θ: PQ.push(s̄, priority = e)
until PQ empty # every residual below θ
On a sparse-reward problem the queue concentrates work near the frontier where values are actually changing, leaving the converged interior untouched; Moore and Atkeson report order-of-magnitude reductions in backups to reach a target accuracy on large MDPs. The method is exact-model dynamic programming — it needs to form both the backup and the predecessor sets — but it is the direct ancestor of the sampled prioritized-replay schemes that return in Week 6.
Real-time dynamic programming
Prioritized sweeping orders updates by residual; real-time dynamic programming (RTDP) orders them by reachability Barto et al. (1995) . Instead of enumerating states, RTDP backs up only the states it actually visits while acting greedily, interleaving computation with control.
repeat for each trial:
s ← start state
while s is not terminal:
V(s) ← (𝒯* V)(s) # back up the current state
a ← greedy action at s w.r.t. V
s ← sample s' ∼ p(· | s, a) # follow the greedy trajectory
Because backups concentrate on the states reachable under good policies, RTDP can solve problems whose full state space is far too large to sweep, converging on the relevant subset without ever touching the rest. It is also the conceptual hinge to model-free learning: replace the expectation in the backup with the single sampled successor, and the deterministic backup becomes a stochastic one — RTDP’s Monte-Carlo cousin is Q-learning, which Weeks 3–4 build from exactly this move.
Counting the work: iterations and samples
How many backups does the discount cost us? For synchronous value iteration the geometric bound answers it directly.
Starting from , synchronous value iteration reaches after
sweeps, where .
With , Chapter 1’s Corollary 1.1 gives , using the return bound . Requiring the right side and taking logs gives the displayed . The order form uses for , so .
The count is only logarithmic in the accuracy but linear in the effective horizon — push toward and the work grows without bound. Tseng Tseng (1990) made this precise, showing stationary discounted MDPs are solved in time proportional to of the horizon. The same governs the sample cost once the model is unknown: given only a generative model (a sampler for ), estimating an -optimal value needs samples, a bound matched from both sides by Azar et al. Azar et al. (2013) and achieved in near-optimal time by the variance-reduced value iteration of Sidford et al. Sidford et al. (2018) . That cubic blow-up in the horizon is precisely the pressure that drives the curriculum out of the exact-model regime and into sampling (Week 3) and function approximation (Week 5).
The dynamic-programming bridge
Asynchronous DP is where the numerical-analysis reading of value iteration becomes literal. A value function is a point in ; the Bellman operator is a nonlinear map whose fixed point we chase; and the Jacobi / Gauss–Seidel / residual-ordered hierarchy is the same one used to solve large sparse linear systems, transplanted to a contraction that happens to involve a . Two threads carry forward:
- To online control (MPC, Week 15). RTDP’s instinct — compute only over the states you will actually visit, refreshing as you go — is the tabular shadow of model predictive control, which re-solves a short-horizon optimal-control problem from the current state at every step instead of storing everywhere.
- To model-free RL (Weeks 3–6). Replace the model expectation in a backup with a sampled successor and asynchronous DP becomes temporal-difference learning; prioritized sweeping becomes prioritized experience replay. The schedule ideas of this chapter reappear, now applied to which transitions to learn from.
What’s next
- Week 3 removes the known model entirely: values are estimated from sampled returns (Monte Carlo), trading the model expectation for an empirical average and introducing the bias–variance questions that dominate the rest of Part I.
- Week 4 fuses the two views — bootstrapping like DP, sampling like Monte Carlo — into temporal-difference learning, the stochastic-approximation form of the asynchronous backup above.
Exercises
-
(Prove) Show that the Bellman optimality operator satisfies the constant-shift identity for every (Prop. 2.1(2)), and explain where the proof of Theorem 2.1 uses it.
Solution
For each , since the transition row sums to , so every rises by ; the per-state then rises by . Theorem 2.1 uses it to evaluate , which shrinks the bounding box by a factor each round.
-
(Derive) Argue that one full Gauss–Seidel sweep is one “round” in the sense of Theorem 2.1, and conclude that Gauss–Seidel value iteration converges at least as fast (per sweep) as synchronous value iteration.
Solution
A left-to-right sweep updates each state exactly once, so by the end every state has been backed up since the sweep began — a round — and Theorem 2.1 gives . Synchronous VI achieves the same per-sweep factor but reads only stale values; Gauss–Seidel additionally uses freshly updated predecessors within the sweep, so its actual contraction per sweep is no worse and usually strictly better.
-
(Compute) A backup at state changes the residual of which other states? Give the set in terms of , and explain why prioritized sweeping only re-queues those.
Solution
Only the predecessors : a state ‘s backup depends on only if some action from can reach . Every other state’s residual is unchanged by overwriting , so re-evaluating it would be wasted work — hence the predecessor loop in the prioritized-sweeping inner step.
-
(Implement) In the companion, run synchronous VI, Gauss–Seidel VI, and prioritized sweeping on the stochastic gridworld and verify (i) all three reach the policy-iteration value , and (ii) to reach a fixed target accuracy — set the prioritized-sweeping threshold — prioritized sweeping spends fewer state-backups than the synchronous sweep count .
Solution
See
experiments/python/week02/test_async_dp.py: it asserts each method matchesdp.policy_iteration, and that at the prioritized-sweeping backup count is below the synchronous total. The win is in reaching useful accuracy fast — the queue concentrates on high-residual states — and it widens with ; the edge narrows as approaches machine precision, where residuals near the fixed point thrash the queue. -
(Extend) Perturb the gridworld’s transition model (raise the slip probability) and measure how the optimal policy and change. Relate the sensitivity to the factor in Proposition 2.2.
Solution
A model error of size in perturbs the fixed point by (a simulation-lemma bound — a perturbation bound on the DP fixed point): the same effective horizon that sets the iteration count also amplifies model error, which is the quantitative reason model misspecification hurts more as . The companion’s
--slipsweep exhibits the effect.
Companion code
The Week-2 companion lives at experiments/python/week02/ and reuses the Week-1
primitives — it imports dp.py for action_values, bellman_optimality_operator,
value_iteration, and policy_iteration rather than reimplementing them, so the
asynchronous methods are checked against the same reference fixed point.
gridworld.py— builds a parametric stochastic gridworld as a generic(P, R, gamma)MDP in thedp.pyrepresentation: a goal cell, a per-step cost, and a slip probability that randomizes the intended move. Pure NumPy.async_dp.py— Gauss–Seidel (in-place) value iteration and model-based prioritized sweeping with an explicit predecessor index and a backup counter, both built on thedp.pyoperators.test_async_dp.py— mathematical-correctness tests: Gauss–Seidel and prioritized sweeping converge to the same asvalue_iterationandpolicy_iteration(from arbitrary starts); the constant-shift and monotonicity properties of Proposition 2.1 hold numerically; and prioritized sweeping uses fewer backups than a synchronous sweep schedule to reach a target accuracy on a sparse-reward grid.
# core algorithms + correctness tests (pure NumPy, no Gymnasium needed)
PYTHONPATH=. pytest experiments/python/week02/test_async_dp.py -q
# worked comparison + optional value/residual heatmaps (saved locally, not committed)
PYTHONPATH=. python experiments/python/week02/async_dp.py --plot