Asynchronous & Prioritized Dynamic Programming
In-place sweeps, prioritized sweeping and real-time dynamic programming.
A sweep that updates every state equally often is the least intelligent way to spend computation: most values barely change while a few are far from settled. Asynchronous dynamic programming updates states in any order, prioritized sweeping spends each update where the Bellman error is largest, and real-time dynamic programming updates only the states an agent actually visits. On a 400-cell grid, the right order turns 39 sweeps into two.
What you’ll learn
- State the convergence theorem for totally asynchronous dynamic programming, including updates that use stale values, and connect it to the convergence of Q-learning.
- Show on a worked example how the order of updates changes the work by more than an order of magnitude.
- Design prioritized sweeping with Bellman-error priorities, and bound how one backup changes the errors of other states.
- State the convergence theorem of real-time dynamic programming with its conditions, and explain how labeling (LRTDP) and heuristic search (LAO*) let it stop.
Asynchronous updates and their guarantee
In asynchronous dynamic programming there are no sweeps. At each time some state is chosen and its value is replaced by its backup, , with for evaluation or for control; all other values stay put. In-place sweeps, random orders and many processors updating different states at once are all special cases. With several processors, an update may even read values of other states that are out of date.
Bertsekas (1982, 1983) showed that almost nothing about the order matters. The cleanest statement is a general theorem about fixed points.
For a -contraction in the max norm, use balls around the fixed point. A max-norm ball is a product of intervals, one per state, so the box condition holds, and one backup of any vector in lands in :
Suppose that from some time on every value an update reads comes from a vector in . The next update of state then puts into its interval of , and later updates of keep it there. Because the set is a box, each state can move into its new interval on its own schedule: no coordination between states is needed.
Once every state has been updated after that time, the whole vector is in ; once stale reads from before that moment are flushed, all reads come from , and the argument repeats. Fairness and eventual refreshing make this happen for every , so :
The theorem reaches beyond planning. Tabular Q-learning is asynchronous stochastic approximation of the backup on action values: each step updates one pair with a noisy sampled target. Its classical convergence proofs (Tsitsiklis, 1994; Jaakkola, Jordan & Singh, 1994) combine exactly this asynchronous contraction argument with step sizes that average out the noise (Convergence of TD: Stochastic Approximation).
An adversary chooses which state asynchronous value iteration () updates next, and each update may read values up to 1,000 steps out of date. The adversary must update every state infinitely often. Does the algorithm converge to ?
- No: an adversarial order can make the values cycle
- Only if the states are updated in a fixed cyclic order
- Yes: fairness plus bounded staleness is enough for a max-norm contraction
- Only if each update reads fresh values
Show the answer
C. Yes: fairness plus bounded staleness is enough for a max-norm contraction
The boxes shrink by , and with delays bounded by 1,000 steps, old information is eventually discarded. Every fair schedule eventually moves the iterate from one box into the next. The order affects speed, never the limit.
Order matters: a 400-state example
Take an open 20×20 grid with the goal in one corner. Moves are deterministic, bumping into the edge leaves you in place, entering the goal pays and ends the episode, , and . The optimal value of a cell at distance from the goal is , and the farthest cell is 38 steps away. Compare four ways of running value iteration until a pass changes nothing.
Run in-place sweeps row by row, starting from the goal's corner and moving away from it, so that each cell is updated after its neighbors on the goal side. How many sweeps until a sweep changes nothing?
Show the answer
2
When a cell is updated, its goal-side neighbors already hold their final values, so the first sweep computes every value exactly. The second sweep changes nothing and confirms convergence. A synchronous sweep moves information only one step per sweep, so it needs 39.
| Schedule | Sweeps | Backups |
|---|---|---|
| Synchronous (Jacobi) | 39 | 15,561 |
| In place, starting at the far corner and moving toward the goal | 39 | 15,561 |
| In place, starting at the goal's corner and moving away | 2 | 798 |
| Prioritized sweeping (largest Bellman error first) | no sweeps | 399, plus 1,990 Bellman-error checks (399 to fill the queue, 1,591 of predecessors) |
The same two in-place orders differ by a factor of 20, and nothing in the algorithm tells you which one you are using. Good orders follow the flow of value backward from where rewards are. In this deterministic problem, largest-Bellman-error-first processes the cells in order of their distance from the goal, which is Dijkstra's shortest-path algorithm in disguise. It finds that order without being told, at the price of a priority queue and of checking errors, first of every cell to fill the queue and then of each backed-up cell's predecessors (the cell itself included when it borders the edge): about 2,400 backup-sized operations in all, roughly a sixth of synchronous value iteration's 15,561.
Prioritized sweeping
Prioritized sweeping (Moore & Atkeson, 1993; Peng & Williams, 1993, who called it queue-Dyna) keeps a priority queue of states keyed by the size of their pending update. After backing up a state it re-examines only the states whose backups read it: its predecessors. The key fact is local.
PRIORITIZED-SWEEPING(model, V, θ):
for each state s: push s with priority |(T V)(s) − V(s)| if it exceeds θ
while the queue is not empty:
s ← pop the state with the highest priority
V(s) ← (T V)(s) # one backup
for each predecessor p of s: # P(s | p, a) > 0 for some a
e ← |(T V)(p) − V(p)| # its new Bellman error
if e > θ: push p with priority e (or raise its priority to e)
return V # every Bellman error ≤ θThe priority can be the Bellman error itself, as here, or a cheaper upper bound from the theorem, . With a learned model the same loop runs inside Dyna, between real steps (Dyna: Learning, Planning & Acting).
On returning, every Bellman error is at most , so the values are within of the fixed point. Wingate and Seppi (2005) combined prioritization with partitioning the state space and reordering variables, and report speedups of value and policy iteration by several orders of magnitude on many problems while keeping their convergence guarantees. In deep RL, prioritized experience replay (Schaul et al., 2016) applies the same idea to sampled transitions: replay the ones with large TD errors more often (Experience Replay in Depth).
A backup has just changed by . Whose Bellman errors can have changed as a result?
- Only those of 's predecessors, by at most each, plus that of itself
- Only those of the successors of
- Those of every state, by up to
- None: is now consistent, so nothing else is affected
Show the answer
A. Only those of 's predecessors, by at most each, plus that of itself
A backup at reads only if some action of can lead to . Those predecessors' backups shift by at most ; 's own error changes because moved. Everything else is untouched, which is why prioritized sweeping needs the predecessor lists.
Real-time dynamic programming
Real-time dynamic programming (RTDP; Barto, Bradtke & Singh, 1995) chooses which states to update by acting. It runs trials: from a start state, follow the policy that is greedy for the current values, back up each state you visit, and stop at a goal. Korf's (1990) LRTA* is its deterministic special case. RTDP is usually stated for stochastic shortest-path problems, in which an agent pays a cost per step until it reaches a goal, and the values are expected costs to go.
An initial value function is admissible if : it never overestimates the remaining cost. Admissible values are optimistic, and optimism drives the greedy policy toward actions that have not been ruled out yet.
The proof combines the asynchronous convergence argument with optimism. Admissible values stay admissible under backups, so an action that looks cheap is tried until its estimate rises to its true cost; an action that looks expensive has been shown to be so. Irrelevant states are never needed to certify the optimal policy, so RTDP can solve problems whose full state space is far too large to sweep. Two weaknesses remain: RTDP has no stopping rule, and states that are relevant but rarely visited converge slowly.
Labeled RTDP (LRTDP; Bonet & Geffner, 2003) fixes both. A state is labeled solved when every state reachable from it under the greedy policy has a Bellman residual below ; trials stop at solved states, and the algorithm stops when the start state is solved. It terminates after finitely many trials with -consistent values on the greedy policy's reachable states. LAO* (Hansen & Zilberstein, 2001) comes from heuristic search: it grows a partial solution graph from the start state, expanding its unexpanded tips, and runs value or policy iteration only on the states whose values the expansion can change. With an admissible heuristic it returns an optimal policy for the start state, typically after visiting a fraction of the states.
| Method | Which states it updates | When it stops |
|---|---|---|
| Synchronous value iteration | All, every sweep | Largest change below a threshold |
| Prioritized sweeping | Largest Bellman error first; then predecessors | Queue empty: every error below |
| RTDP | States on greedy trials from the start | No built-in rule; converges on relevant states |
| LRTDP | Greedy trials, skipping solved states | The start state is labeled solved |
| LAO* | The expanded part of the best partial solution | The best solution graph has no unexpanded tips and its values have converged |
Key takeaways
- Asynchronous dynamic programming converges under any schedule that updates every state infinitely often, even with stale but eventually refreshed values; the box structure of max-norm balls is the reason, and it also underlies Q-learning's convergence.
- Order changes the work, not the limit: on a 20×20 grid, sweeping in the direction value flows needs 2 sweeps instead of 39, and prioritized sweeping finds such an order by itself.
- Prioritized sweeping backs up the state with the largest Bellman error and re-examines only its predecessors, whose errors change by at most .
- RTDP updates only states visited by greedy trials and, from admissible values, converges on the relevant states; LRTDP adds a solved-labeling stopping rule, and LAO* brings the same idea to heuristic search.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Which condition is enough for asynchronous value iteration with to converge to ?
- Every state is updated infinitely often, and stale values are eventually refreshed
- States are updated in decreasing order of their current values
- All states are updated equally often
- Each update reads only values computed in the current sweep
Show the answer
A. Every state is updated infinitely often, and stale values are eventually refreshed
That is the totally asynchronous condition. The max-norm boxes around make the order irrelevant to the limit, though not to the speed.
On the 20×20 grid, prioritized sweeping backed up each of the 399 cells exactly once, yet did about 2,400 backup-sized operations in total. Where did most of the rest go?
- Into backing up the goal state repeatedly
- Into re-checking the Bellman errors of predecessors after each backup
- Into an initial synchronous sweep that is required for correctness
- Into sorting all states by value before starting
Show the answer
B. Into re-checking the Bellman errors of predecessors after each backup
After each backup the algorithm computes the Bellman error of every predecessor of the updated cell, each check as costly as a backup: 1,591 checks here, on top of the 399 that filled the queue at the start. Prioritization saves backups but adds bookkeeping, and pays off when the right order is not known in advance.
RTDP with admissible values runs on a problem where half the states cannot be reached from the start under any optimal policy. What happens to their values?
- They converge to like all the others
- RTDP diverges unless they are initialized exactly
- They may stay wrong forever, while the greedy policy from the start becomes optimal
- They are set to infinity
Show the answer
C. They may stay wrong forever, while the greedy policy from the start becomes optimal
RTDP updates states only when greedy trials visit them, and once values on the relevant states are accurate, the greedy policy avoids the irrelevant ones. Their values are not needed to act optimally from the start, which is exactly the saving.
When does Labeled RTDP mark a state as solved?
- When it has been visited at least once
- When its own Bellman residual falls below
- When its value equals the heuristic
- When every state reachable from it under the greedy policy has a residual below
Show the answer
D. When every state reachable from it under the greedy policy has a residual below
Its own residual is not enough: its value depends on the states it can reach. Requiring all of them to be -consistent makes the label safe, and once the start state is labeled the algorithm can stop.
Further reading
- D. P. Bertsekas & J. N. Tsitsiklis, Parallel and Distributed Computation: Numerical Methods (Prentice Hall, 1989).
- A. W. Moore & C. G. Atkeson, "Prioritized sweeping: reinforcement learning with less data and less time," Machine Learning 13, 103–130 (1993).
- A. G. Barto, S. J. Bradtke & S. P. Singh, "Learning to act using real-time dynamic programming," Artificial Intelligence 72, 81–138 (1995).
- B. Bonet & H. Geffner, "Labeled RTDP: improving the convergence of real-time dynamic programming," ICAPS (2003).
- E. A. Hansen & S. Zilberstein, "LAO: a heuristic search algorithm that finds solutions with loops," Artificial Intelligence* 129, 35–62 (2001).