Distributed Actor–Critic: A3C & IMPALA
Parallel actors, policy lag and V-trace corrections.
IMPALA's learner trains on experience generated by policies several updates out of date, at a reported 250,000 environment frames per second. That works because of a correction, V-trace, whose fixed point is not the value of the current policy but of a policy between it and the one that acted. This lesson follows distributed actor–critic from A3C's lock-free threads to decoupled actors and learners, proves that V-trace contracts and identifies its fixed point, and surveys how such systems scale.
What you’ll learn
- Compare A3C's asynchronous updates, A2C's synchronous ones and IMPALA's decoupled actors and learner, and explain policy lag.
- Write the V-trace target and policy-gradient update, and explain the roles of the truncation levels and .
- Prove that the one-step V-trace operator is a contraction with fixed point , and state the general theorem.
- Describe SEED RL, population-based training and PPO at scale, quoting throughput only as reported.
Asynchronous, synchronous, decoupled
A3C (Mnih et al., 2016) runs many actor-learner threads, each with its own environment and its own copy of the parameters. A thread acts for a few steps, computes an -step advantage gradient on its segment, and applies it to the shared parameters without locks, in the style of Hogwild! (Recht, Ré, Wright & Niu, 2011). Two kinds of staleness follow. A thread's gradient was computed at parameters that other threads have since changed, so it is applied at a different point from the one where it was computed; and its actions came from a slightly older policy than the one being updated. With short segments and a handful of threads on one machine both effects stay small, and asynchrony delivers its real benefit: cheap, decorrelated data.
A2C removes the asynchrony: actors step in lockstep and the learner makes one synchronous update from the batch. OpenAI's 2017 report on its baselines found no evidence that asynchrony's noise improves performance, and the batched update uses accelerators better. But it scales poorly, since every update waits for the slowest actor and the learner idles while actors act.
Decoupling removes the waiting. In IMPALA (Espeholt et al., 2018) actors never compute gradients. Each runs a copy of the policy, sends whole trajectories to a central learner, and fetches fresh parameters from time to time; the learner trains on batches of trajectories from many actors at once. Acting and learning proceed at their own speeds. The price is policy lag: the behavior policy that generated a trajectory can be several updates behind the learner's policy , so the data are off-policy, and an on-policy actor–critic update on them is biased.
| Architecture | Who computes gradients | Data | Main cost |
|---|---|---|---|
| A3C | every actor thread, applied asynchronously | slightly off-policy | stale gradients; limited to one machine's threads |
| A2C | one learner, synchronous batches | on-policy | waits for the slowest actor |
| IMPALA | a central learner; actors only act | off-policy by the policy lag | needs an off-policy correction: V-trace |
IMPALA's actors run copies of the same network as the learner. Why are the learner's data off-policy anyway?
- Because actors explore with ε-greedy actions
- Because actors fetch parameters only from time to time, so a trajectory was generated by a policy that is several learner updates old
- Because rewards arrive with a delay
- Because actors use a different network architecture
Show the answer
B. Because actors fetch parameters only from time to time, so a trajectory was generated by a policy that is several learner updates old
Between an actor's parameter fetch and the moment the learner uses its trajectory, the learner keeps updating. That gap, the policy lag, grows with the number of actors and with network and queueing delays, and the behavior policy differs from the current by that many updates.
V-trace
Importance sampling could correct the lag, but products of ratios over steps have exploding variance (Off-Policy Monte Carlo & Importance Sampling). V-trace truncates them. Espeholt et al. write for the behavior policy and for the reward after action ; here they are , since is our start distribution, and . From the importance ratio define two truncated versions:
Three properties.
- On-policy, it is the -step return. If and , every and equals 1 and telescopes to . One algorithm handles both on- and off-policy data.
- decides what is learned, how fast. The weights on the TD errors determine the fixed point, as the theorem below shows. The traces only control how far corrections propagate back, which affects the contraction speed and the variance but not the fixed point. Truncating them keeps the products of ratios bounded.
- Relation to Retrace. Retrace (Munos, Stepleton, Harutyunyan & Bellemare, 2016) cuts traces at for action values and keeps as its fixed point (Off-Policy Traces: Tree Backup & Retrace). V-trace works with state values and pays for that simplicity with a fixed point that differs from whenever truncates.
Where V-trace converges, and how fast
Treat the expected V-trace update as an operator on value functions. The one-step case already shows both the contraction and the fixed point.
With and , define
For two value functions the rewards cancel. Write , which is at most :
Both coefficients are nonnegative, and they add up to . So if in every state:
The fixed point. exactly when the expected weighted TD error vanishes in every state. Since for , that expectation is times a Bellman residual for a new policy:
So the fixed point satisfies the Bellman equation of : it is , the value of a policy between and .
Two actions, behavior policy , target policy and . What probability does give the first action?
Show the answer
0.83
, which normalizes to : between and . Here , so the one-step contraction modulus is at most , slower than the usual .
What buys. As , : the target is unbiased for , but the weights are raw importance ratios and the variance can explode. As , tends to and the critic learns the behavior policy's value. In IMPALA's analysis experiments the ratios were clipped at , and among the value 1 worked best. With small policy lag, and are close, is close to both, and the bias is small.
Scaling further
Central inference. SEED RL (Espeholt, Marinier, Stanczyk, Wang & Michalski, 2020) moves the policy network off the actors too. Actors only step environments and send observations; a central learner on accelerators runs inference for all of them in large batches and trains on the resulting trajectories, with V-trace for actor–critic learning (and R2D2 for value-based learning). The paper reports training at millions of frames per second, and cost reductions of 40% to 80% for the experiments it considered.
Population-based training (Jaderberg et al., 2017) runs a population of agents in parallel, each with its own hyperparameters. Periodically, weak members copy the weights of stronger ones (exploit) and perturb their hyperparameters (explore). The result is a hyperparameter schedule found within a single training run, at the price of a whole population's compute. The original paper applied it to deep RL agents as well as to supervised learning and GANs.
PPO at scale. OpenAI Five (Berner et al., 2019) trained a PPO agent for Dota 2 continually for about ten months, learning from batches of roughly two million frames about every two seconds, and on April 13, 2019 it beat OG, the reigning world champions. Its architecture has IMPALA's shape: many rollout workers feeding central optimizers on GPUs. Large distributed PPO runs are also the backbone of RLHF pipelines for language models (RL from Human Feedback).
Key takeaways
- A3C applies asynchronous, slightly stale gradients from many threads; A2C synchronizes; IMPALA decouples acting from learning, so its data are off-policy by the policy lag.
- V-trace weights TD errors by truncated ratios and traces by ; on-policy it reduces to the -step return.
- The V-trace operator contracts with modulus at most and converges to with : sets what is learned, how fast.
- Scaling continued with central inference (SEED RL), population-based hyperparameter schedules and very large PPO runs such as OpenAI Five; reported throughput gains trade against policy lag and sample efficiency.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In V-trace, what happens to the fixed point as , and at what cost?
- It becomes the behavior policy's value , and the variance falls
- It becomes the target policy's value , but the unbounded ratios can make the variance explode
- It stays the same for every
- The operator stops being a contraction
Show the answer
B. It becomes the target policy's value , but the unbounded ratios can make the variance explode
tends to as grows, so the target becomes unbiased for . The weights are then plain importance ratios, which can be huge when rarely takes actions that likes. As the fixed point tends to instead.
What does the trace truncation level affect?
- The fixed point of the V-trace operator
- The weight of the entropy bonus
- The speed of contraction and the variance, but not the fixed point, which depends on alone
- Nothing at all
Show the answer
C. The speed of contraction and the variance, but not the fixed point, which depends on alone
The traces multiply TD errors further along the segment, so they decide how far a correction propagates back in one update. The expected TD errors that define the fixed point carry the weights only.
What is stale about an A3C thread's gradient when it is applied to the shared parameters?
- It was computed at parameters that other threads have since changed, from actions of a slightly older policy
- It ignores the critic
- It is computed from replayed experience
- Nothing: lock-free updates make every gradient current
Show the answer
A. It was computed at parameters that other threads have since changed, from actions of a slightly older policy
Without locks, other threads write to the parameters while a thread acts and computes its gradient, so the gradient is applied at a different point from where it was computed, and the segment's actions came from the policy as it was when the thread last copied the parameters. Short segments keep both effects small.
If the data are on-policy () and , what is the V-trace target for a segment of steps?
- Zero
- The one-step TD target
- The Monte Carlo return to the end of the episode
- The -step return
Show the answer
D. The -step return
All ratios equal 1, so every and is 1, and the sum of discounted TD errors telescopes to the -step return. This is why one algorithm can run on fresh and stale data alike.
Further reading
- V. Mnih, A. P. Badia, M. Mirza, A. Graves, T. Lillicrap, T. Harley, D. Silver & K. Kavukcuoglu, "Asynchronous methods for deep reinforcement learning," ICML (2016).
- L. Espeholt, H. Soyer, R. Munos, K. Simonyan, V. Mnih, T. Ward, Y. Doron, V. Firoiu, T. Harley, I. Dunning, S. Legg & K. Kavukcuoglu, "IMPALA: Scalable distributed deep-RL with importance weighted actor-learner architectures," ICML (2018).
- L. Espeholt, R. Marinier, P. Stanczyk, K. Wang & M. Michalski, "SEED RL: Scalable and efficient deep-RL with accelerated central inference," ICLR (2020).
- M. Jaderberg et al., "Population based training of neural networks," arXiv:1711.09846 (2017).
- C. Berner et al. (OpenAI), "Dota 2 with large scale deep reinforcement learning," arXiv:1912.06680 (2019).