Search as Policy Improvement: AlphaZero
Policy and value networks trained by search, and search improved by networks.
AlphaZero is policy iteration in disguise: a search improves on the network's policy, the network learns to imitate the search, and the better network makes the next search stronger. This lesson removes the disguise. It proves why lookahead improves any policy, shows how AlphaGo became AlphaZero by closing the loop, states what approximate-policy-iteration theory guarantees for such loops and what it cannot, and weighs what superhuman self-play strength does not establish.
What you’ll learn
- Prove that acting greedily on estimated action values of a policy improves it up to , and relate this to rollout algorithms and deeper lookahead.
- Map AlphaGo, AlphaGo Zero and AlphaZero onto policy evaluation and policy improvement, and write the self-play loop and its loss as expert iteration.
- State the approximate-policy-iteration bound with evaluation and improvement errors, and interpret both errors for search-and-distill training.
- Assess the evidence: compute, open reimplementations, adversarial policies against superhuman Go programs, and the gap between the theory's assumptions and self-play.
Lookahead improves a policy
The policy improvement theorem says that acting greedily with respect to a policy's own action values never makes it worse. Tesauro and Galperin (1996) used this online in backgammon: at each position, estimate every move's value by Monte Carlo rollouts of a base player, then play the best. The resulting player made far fewer errors than the base player it simulated. Bertsekas, Tsitsiklis and Wu (1997) studied such rollout algorithms for combinatorial optimization and showed when they are guaranteed to improve on their base heuristic. In practice the values are estimates, so the useful statement includes their error.
Greediness on and the error bound give, for every , . Averaging over bounds the advantage of the new action:
The performance-difference lemma (Advantages & the Performance Difference Lemma), started from state , writes the change in value as the old advantages averaged over the new policy's occupancy measure, which sums to 1.
Deeper lookahead shrinks the damage of value errors. If leaf values are within of and the model is exact, acting greedily on an -step lookahead is acting greedily on applied to the leaf values, which are within of ; the greedy-policy loss bound then gives
From AlphaGo to AlphaZero: closing the loop
AlphaGo (Silver et al., 2016) reads as roughly one and a half passes of policy iteration. A policy network imitated expert moves; policy gradient self-play improved it; a value network evaluated the improved policy by regression on its self-play outcomes; and MCTS, guided by both networks, added one more improvement step at play time. The search's improvement was never fed back into training.
AlphaGo Zero (Silver et al., 2017) closed the loop. One network guides MCTS in self-play; the search returns visit-count probabilities , a better policy than ; the network is trained to imitate and to predict the game outcome reached by playing it. AlphaZero (Silver et al., 2018) applied the same loop to chess, shogi and Go.
| Policy-iteration role | AlphaGo (2016) | AlphaGo Zero and AlphaZero |
|---|---|---|
| Policy to improve | Networks trained on expert games, then by policy gradient | The current network's |
| Improvement operator | Policy gradient in training; MCTS only at play time | MCTS with PUCT in every self-play move |
| Keeping the improvement | Not done: search results are not trained on | Cross-entropy from to |
| Evaluation | Value network fitted to outcomes of the policy-gradient player | Value head fitted to outcomes of the search player |
| Data | Human games plus self-play | Self-play only |
EXPERT-ITERATION(network f_θ = (p_θ, v_θ)): # AlphaZero is one instance
repeat:
# improvement: the expert is a search guided by the apprentice
for each self-play game, at each state s:
π_s ← SEARCH(s, prior p_θ, leaf values v_θ) # e.g. MCTS visit counts
play a ~ π_s (sampled early in the game, near-greedy later)
z ← the final outcome, credited to each stored state from its player's view
# distillation and evaluation: the apprentice imitates the expert
update θ on recent (s, π_s, z) to reduce (z − v_θ(s))² − π_sᵀ log p_θ(s) + c‖θ‖²Expert iteration (ExIt; Anthony, Tian & Barber, 2017) proposed this decomposition independently: tree search plans new policies and a deep network generalizes those plans, which in turn strengthens the search. Their Hex player, trained from scratch, beat MoHex 1.0, the most recent Olympiad-champion Hex program to have been publicly released.
The apprentice is trained on states reached by its own (search-augmented) play, labeled by the expert's choices there. That is the structure of interactive imitation learning such as DAgger (Compounding Errors & Interactive Imitation), which is why imitating the search does not suffer the compounding errors of cloning a fixed dataset: the training distribution follows the learner.
Approximate policy iteration: what the theory says
Read it for AlphaZero. is the value head's error, and measures how far the network's next policy falls short of greedy improvement: the search is only approximately greedy, and the network imitates it only approximately, so both search error and distillation error land in . One factor accumulates errors across iterations, the other converts a one-step shortfall into lost value. The result is a : approximate policy iteration need not converge, and it can oscillate among policies whose values stay within the bound.
With , evaluation error and improvement error , what does the bound give for the eventual suboptimality ?
Show the answer
2.8
. With rewards in values range over , so 1% errors at every state already permit losing more than a quarter of the range; at the same errors give 298 against a range of 100. Board games use on episodes of bounded length, so the discounted bound is a guide to the structure, not a guarantee for AlphaZero.
The deeper gap is the norm. Both errors are suprema over all states. Self-play trains and checks the networks only on the states its own games reach; errors elsewhere are unconstrained, and nothing in the loop looks for them. Two refinements narrow the gap between theory and practice. Conservative improvement steps, such as the KL-regularized improvement that AlphaZero's visit counts implement (MCTS in Depth: UCT, PUCT & What Search Optimizes), keep consecutive policies close, in the spirit of conservative policy iteration. And Dual Policy Iteration (Sun, Gordon, Boots & Bagnell, 2018) formalizes the pairing of a fast reactive policy with a slow non-reactive one, such as a search, and extends approximate-policy-iteration analysis to it.
Evidence: strength, cost and blind spots
The strength is not in doubt. AlphaGo Zero, after three days of self-play, beat the version of AlphaGo that had defeated Lee Sedol by 100 games to 0, and AlphaZero defeated the world-champion programs Stockfish in chess and Elmo in shogi, and a three-day AlphaGo Zero in Go. The cost was large: in the words of the KataGo paper (Wu, 2019), AlphaZero used "thousands of TPUs over several days" and the open reimplementation ELF OpenGo (Tian et al., 2019) "thousands of GPUs over two weeks". KataGo surpassed ELF's final model after 19 days on fewer than 30 GPUs, reporting a 50× reduction in computation over comparable methods, through changes to the search, additional training targets and Go-specific input features.
Think first If approximate policy iteration converges at all, it converges to good play in every state the errors are small in. Why did adversarial training not simply remove the cyclic-group weakness?
Adversarial training adds the adversary's positions to the training distribution, shrinking errors there, but the guarantee needs small errors everywhere, and a new adversary can search for the next region where the network is wrong. Each round patches the states that were found, not the generalization flaw that produced them. Whether a learned evaluation can be made robust over all positions a determined opponent can reach, rather than over the positions typical games reach, is the open question.
Key takeaways
- Greedy action on estimates within of loses at most against (performance-difference lemma); -step lookahead with leaf values within of loses at most .
- AlphaGo was a partial pass of policy iteration; AlphaGo Zero and AlphaZero close the loop: search improves, the policy head distills the improvement, the value head evaluates the search player. Expert iteration is the same pattern.
- Approximate policy iteration guarantees with sup-norm errors; self-play controls errors only where it plays.
- The strength is real but costly (KataGo reports a 50× compute reduction over comparable methods), and adversarial policies that beat KataGo show that superhuman typical play is not worst-case robustness.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In the policy-iteration reading of AlphaGo Zero, which component performs policy evaluation?
- The MCTS visit counts
- The cross-entropy term toward the search probabilities
- The Dirichlet noise at the root
- The value head, regressed onto the outcomes of games played by the search-guided policy
Show the answer
D. The value head, regressed onto the outcomes of games played by the search-guided policy
The squared-error term fits to Monte Carlo returns of the improved, search-based player: evaluation. The visit counts and the cross-entropy term are the improvement and its distillation.
In the approximate-policy-iteration bound applied to AlphaZero, where does a poor imitation of the search by the policy head show up?
- Only in the evaluation error
- In the improvement error : the next policy falls short of the greedy improvement the search computed
- Nowhere: the bound assumes perfect distillation
- In the discount factor
Show the answer
B. In the improvement error : the next policy falls short of the greedy improvement the search computed
measures how far the policy that is actually deployed next is from greedy with respect to the current value estimate. Imperfect search and imperfect distillation both enlarge it. is the value head's error.
A policy is greedy with respect to estimates within of everywhere. What can be guaranteed?
- exactly
- in every state
- Nothing, unless
Show the answer
C. in every state
The greedy action's advantage under is at least , and the performance-difference lemma sums at most worth of such shortfalls. With it is the policy improvement theorem.
What does the success of adversarial policies against superhuman Go programs show?
- That superhuman average strength can coexist with systematic errors in positions self-play rarely reaches
- That the programs were never superhuman
- That MCTS is inconsistent
- That adversarial training removes such weaknesses for good
Show the answer
A. That superhuman average strength can coexist with systematic errors in positions self-play rarely reaches
The victims still beat strong humans in ordinary games. The adversaries lead them into positions where their evaluations are wrong, and the weakness persisted through adversarial training. Approximate-policy-iteration guarantees need small errors in all states; self-play controls them only where it plays.
Further reading
- D. Silver et al., "Mastering the game of Go without human knowledge," Nature 550, 354–359 (2017).
- D. Silver et al., "A general reinforcement learning algorithm that masters chess, shogi, and Go through self-play," Science 362, 1140–1144 (2018).
- T. Anthony, Z. Tian & D. Barber, "Thinking fast and slow with deep learning and tree search," NeurIPS (2017).
- D. P. Bertsekas & J. N. Tsitsiklis, Neuro-Dynamic Programming (Athena Scientific, 1996).
- T. T. Wang, A. Gleave, T. Tseng, K. Pelrine, N. Belrose, J. Miller, M. D. Dennis, Y. Duan, V. Pogrebniak, S. Levine & S. Russell, "Adversarial policies beat superhuman Go AIs," ICML (2023).