"The critic does not tell the actor what to do. It tells the actor whether what it did was better or worse than it deserved to expect, and that is enough."
A Careful Control Loop
This section builds directly on section 15.2, which derives the policy gradient theorem and the REINFORCE baseline; familiarity with the log-probability update and the role of a baseline is assumed here. The actor-critic framing introduced in this section is extended in section 15.4, where the clipped surrogate objective of PPO controls how far the actor update can move from the rollout policy. The privileged-critic pattern discussed in the research frontier callout below reappears in section 20.3, where critics trained on full simulator state are used alongside domain randomization and adaptation modules for sim-to-real transfer.
A legged robot sticks a recovery step after an unexpected surface tilt. The reward arrives ten frames later, blurred across a dozen joint commands. Which action deserves the credit? REINFORCE spreads it evenly and learns slowly; a well-calibrated critic knows instantly whether that recovery step beat what the state already promised. That gap between "what happened" and "what was expected" is the advantage, and Generalized Advantage Estimation (GAE) is the principled recipe for computing it under noisy, contact-rich dynamics. The sections that follow develop GAE, tune the bias-variance dial controlled by \(\lambda\), and explain why every production PPO system for embodied agents relies on it.
Picture a walking robot that takes 200 actions, falls once near the end, and earns a single episode return: REINFORCE blames all 200 actions equally, including the good ones taken before the misstep. That coarse, all-or-nothing credit is exactly what makes plain policy gradients so noisy for embodied agents, where a late slip, contact bounce, or tracking error can dominate the whole episode return. Actor-critic methods sharpen the blame by learning \(V_\phi(s)\), a value function that estimates how much return is expected from a state before the next action is chosen. Figure 15.3A captures the division of labor: the actor decides what to do next, while the critic judges whether the last action beat the state's expectations.
Figure 15.3B traces the full loop: the actor acts, the environment responds, the critic scores the surprise as a TD residual, and GAE chains those residuals into the advantage that drives the next actor update. The actor update uses an advantage estimate:
$$A_t = Q(s_t,a_t)-V(s_t).$$
From advantage to TD residual
In practice, Proximal Policy Optimization (PPO) often starts from the temporal-difference residual:
$$\delta_t=r_t+\gamma V(s_{t+1})-V(s_t),$$
The TD residual matters for physical robots because a robot cannot wait until the episode ends before updating. Real hardware wears, batteries drain, and safety envelopes must hold mid-episode. The residual compares the immediate reward plus the discounted next-state value against the current-state prediction. This comparison measures local surprise: how much better or worse the next moment was than the critic expected. A positive residual means the transition was unexpectedly good; a negative residual flags an outcome worse than predicted. That per-step signal lets the critic update continuously from partial trajectories rather than only from complete episodes.
The TD residual \(\delta_t\) subtracts the critic's prediction \(V(s_t)\) from the one-step evidence \(r_t + \gamma V(s_{t+1})\). The bootstrap term \(\gamma V(s_{t+1})\) replaces real future returns with the critic's estimate, which keeps variance low. When the critic is accurate, \(\delta_t\) averages near zero, so the actor receives only genuine new information. GAE chains these residuals backward: a surprise at step \(t+k\) reaches earlier steps with weight \((\gamma\lambda)^k\).
Having defined \(\delta_t\), GAE combines a whole rollout of these residuals into a single advantage estimate by summing them with exponentially decaying weights:
$$\hat A_t^{\mathrm{GAE}(\gamma,\lambda)}=\sum_{l=0}^{\infty}(\gamma\lambda)^l\delta_{t+l}.$$
This sum is the section's core deliverable: it is how GAE actually turns per-step TD residuals into the advantage estimate that the actor uses, and the algorithm box, worked example, and lambda-sweep lab that follow all show this formula in use.
Algorithm: Generalized Advantage Estimation (GAE)
Input: Rollout of \(T\) steps: rewards \(\{r_t\}\), value estimates \(\{V_\phi(s_t)\}\), termination flags \(\{\text{done}_t\}\); discount \(\gamma\); trace parameter \(\lambda\); critic parameters \(\phi\)
Output: Advantage estimates \(\{\hat{A}_t\}\) and return targets \(\{G_t\}\) for actor and critic updates
- Collect rollout: run policy \(\pi_\theta\) for \(T\) steps, recording \((s_t, a_t, r_t, s_{t+1}, \text{done}_t)\) at each step.
- Evaluate critic: compute \(V_\phi(s_t)\) for all \(t \in \{0, \ldots, T\}\); set \(V_\phi(s_{T+1}) = 0\) if the episode truly terminated, otherwise bootstrap with \(V_\phi(s_{T+1})\).
- Compute TD residuals: for each \(t\), set \(\delta_t = r_t + \gamma \, V_\phi(s_{t+1}) \cdot (1 - \text{done}_t) - V_\phi(s_t)\).
- Initialize accumulator: set \(\hat{A}_{T} = 0\).
- Backward pass: for \(t = T-1\) down to \(0\), compute \(\hat{A}_t = \delta_t + (\gamma \lambda)(1 - \text{done}_t)\,\hat{A}_{t+1}\).
- Compute return targets: set \(G_t = \hat{A}_t + V_\phi(s_t)\) for critic supervision.
Checkpoint
So far: the residuals \(\delta_t\) measure local surprise, the backward pass chains them into advantage estimates \(\hat{A}_t\), and adding back \(V_\phi(s_t)\) turns those advantages into return targets \(G_t\) for the critic; the remaining steps just use these three quantities to update the actor and critic.
- Normalize advantages: compute batch mean \(\mu_A\) and standard deviation \(\sigma_A\); replace \(\hat{A}_t \leftarrow (\hat{A}_t - \mu_A) / (\sigma_A + \varepsilon)\).
- Actor update: maximize \(\mathbb{E}_t\bigl[\nabla_\theta \log \pi_\theta(a_t \mid s_t)\,\hat{A}_t\bigr]\) (or use the PPO clipped surrogate from section 15.4).
- Critic update: minimize \(\mathbb{E}_t\bigl[(V_\phi(s_t) - G_t)^2\bigr]\) using gradient descent on \(\phi\).
- Log raw advantages, value predictions, \(G_t\), and \(\delta_t\) per episode so critic failure does not silently corrupt the actor signal.
Step-Through: GAE backward recursion
Trace GAE over a 3-step rollout with \(\gamma = 0.9\), \(\lambda = 0.5\), no early termination. Rewards \(r = [0,\ 0,\ 1]\); critic values \(V = [0.5,\ 0.4,\ 0.3,\ 0.0]\) (the last is the post-terminal bootstrap, 0). First compute the TD residuals \(\delta_t = r_t + \gamma V_{t+1} - V_t\): \(\delta_0 = 0 + 0.9(0.4) - 0.5 = -0.14\); \(\delta_1 = 0 + 0.9(0.3) - 0.4 = -0.13\); \(\delta_2 = 1 + 0.9(0.0) - 0.3 = 0.70\). Now run the backward pass with factor \(\gamma\lambda = 0.45\). Start at the end: \(\hat A_2 = \delta_2 = 0.70\). Step back: \(\hat A_1 = \delta_1 + 0.45\,\hat A_2 = -0.13 + 0.45(0.70) = 0.185\). Step back again: \(\hat A_0 = \delta_0 + 0.45\,\hat A_1 = -0.14 + 0.45(0.185) = -0.057\). So \(\hat A = [-0.057,\ 0.185,\ 0.70]\). Notice how the reward at step 2 leaks backward: it gives step 1 a positive advantage even though its local residual was negative, while step 0 stays slightly negative because the decayed credit (\(0.45^2 = 0.2025\) weight) cannot overcome its own negative residual.
The critic does not tell the actor whether the state is good in absolute terms. It tells the actor whether the sampled action led to a result above or below what the state already promised.
A critic that merely predicts reward is a scoreboard; a critic that predicts expected return from each state is a conscience, because it lets the actor know not just what happened but whether it deserved to happen.
Think of GAE like tasting a dish after each ingredient is added. When you take a bite and discover it is too salty, you do not only blame the last pinch of salt: you mentally trace back through each earlier addition, blaming the step two pinches ago more than the step ten pinches ago because it is closer to the problem. The exponential weight \((\gamma\lambda)^l\) is exactly that fading blame: a surprise at step \(t+l\) reaches earlier step \(t\) with strength \((\gamma\lambda)^l\), strong for nearby steps and nearly gone for distant ones, so the most recent causes bear the most responsibility.
Theory
The parameter \(\lambda\) controls a bias-variance tradeoff. When \(\lambda=0\), the advantage uses one-step TD evidence, which is low variance but depends heavily on critic accuracy. When \(\lambda\) is near 1, the estimate resembles Monte Carlo return, the sum of actual rewards observed for the rest of the episode with no bootstrapping from the critic, which uses longer evidence but becomes noisier. PPO commonly uses values near 0.95 because that often balances delayed reward evidence with manageable variance. The practical difference is large. In a standard MuJoCo hopper benchmark, REINFORCE typically needs roughly 50,000 episodes to reach a stable gait. Actor-critic GAE (\(\lambda=0.95\)) reaches the same policy quality in around 300 episodes, because the critic absorbs most of the episode-level noise before it reaches the gradient. Exact figures vary by environment and reward shaping, but the two-orders-of-magnitude gap is representative.
For embodied control, this tradeoff plays out in time. A one-step residual misses the stumble a foot placement caused three frames later; a long-horizon return blames that same placement for an unrelated collision after a perception glitch. GAE hands the builder one knob: how far credit travels backward through the rollout.
The critic supplies a baseline, the TD residual measures local surprise, and GAE smooths those surprises backward through time. The actor then uses the resulting advantage to weight the same log-probability update introduced in REINFORCE.
Worked Example
Before reading the code below, guess: in a four-step rollout where step 2 yields a reward of 1.0 and every other step yields zero, which earlier steps receive a positive advantage, and by roughly how much does the credit decay with each step backward?
Code Fragment 1 computes GAE for a short rollout. Notice that the advantages are computed backward because later residuals influence earlier credit.
# Compute Generalized Advantage Estimation from rewards and value predictions.
# The backward recursion sends delayed evidence to earlier sampled actions.
rewards = [0.0, 0.2, 1.0, -0.1]
values = [0.3, 0.4, 0.6, 0.2, 0.0]
gamma = 0.99
lam = 0.95
advantages = []
gae = 0.0
for t in reversed(range(len(rewards))):
delta = rewards[t] + gamma * values[t + 1] - values[t]
gae = delta + gamma * lam * gae
advantages.insert(0, round(gae, 3))
print("advantages:", advantages)
rewards = [0.0, 0.2, 1.0, -0.1], showing the step-2 reward of 1.0 propagate positive credit into steps 0 and 1 while step 3's negative residual stays isolated.This trace gives the mental model. Step 3 has a negative advantage because the outcome was worse than the critic expected. Earlier steps remain positive because the later reward still supplies evidence that those actions helped set up a useful state.
Stable-Baselines3, CleanRL, RSL-RL, and rl_games all implement actor-critic PPO with GAE. The implementation details to inspect are gamma, gae_lambda, value loss scaling, advantage normalization, and whether time-limit truncations are bootstrapped correctly.
Practical Recipe
- Train the actor and critic on the same rollout batch so advantages match the behavior policy.
- Bootstrap from \(V(s_{t+1})\) when a rollout segment ends by truncation, but not when the episode truly terminates (see the Common Failure Mode callout below for why conflating the two is the most common GAE bug in practice).
- Normalize advantages per batch to prevent reward-scale changes from dominating the policy loss.
- Track explained variance, the fraction of the variance in the return targets \(G_t\) that the critic's predictions \(V_\phi(s_t)\) account for, where a value near 1 means the critic tracks returns well and a value near 0 means it predicts no better than the batch mean, or value error so a broken critic does not silently corrupt the actor update.
- Audit GAE under perturbations, because delayed physical failures change how far credit should travel backward.
Time-limit truncation is often mistaken for termination. If a robot episode ends because the rollout buffer filled, the critic should usually bootstrap from the next value; if it ended because the robot fell, it should not.
A common assumption is that a high critic value \(V(s_t)\) means the actor should reinforce whatever action it took in that state, and that a low value means those actions should be suppressed. This is wrong: the advantage, not the value, drives the actor update. A high-value state in embodied control, such as a robot already near the goal, may yield a negative advantage if the action taken was clumsy and lost ground relative to what that state promised. Reinforcing actions in high-value states regardless of advantage would corrupt credit assignment and cause the policy to repeat suboptimal moves wherever the critic is optimistic. The correct mental model is that the actor asks only whether the sampled action outperformed the critic's expectation for that specific state, which is precisely what \(A_t = Q(s_t, a_t) - V(s_t)\) captures.
In CleanRL and RSL-RL, the dones flag conflates true termination with time-limit truncation, so GAE silently stops bootstrapping at every timeout boundary. Pass a separate truncated mask (set to 1 only when the episode ended by time limit, not by failure) and multiply the bootstrap term by (1 - terminated) * (1 - truncated) + truncated. Without this fix, long-horizon locomotion tasks consistently underestimate the value of states near the rollout boundary, biasing advantages negative and suppressing exploration in the second half of every episode.
On a Franka Panda running at 1 kHz with fingertip force-torque sensors sampled at 500 Hz, a grasp re-centering command at step \(t\) causes object slip to stabilize roughly 15-20 control steps later (30-40 ms), only detectable via a tactile signal that crosses a 0.3 N threshold. With \(\lambda = 0.95\) and \(\gamma = 0.99\), that 20-step credit travels back with weight \((\gamma\lambda)^{20} \approx 0.36\), enough for the actor to strengthen the re-centering command. With one-step TD (\(\lambda = 0\)), the weight is zero and the actor receives no signal from the stabilization event. Setting \(\lambda\) too high (near 1.0) lets a later wrist collision at step \(t+80\) (due to a perception error, not the grasp) bleed back and incorrectly penalize the original re-centering action.
The critic is the agent's skeptical lab partner. It does not celebrate reward by itself; it asks whether the reward was better than the state already predicted.
Real-World Application: quadruped locomotion (ANYmal / Isaac Gym)
ETH Zurich and NVIDIA's "Learning to walk in minutes" pipeline trains the ANYmal quadruped entirely in Isaac Gym using PPO with GAE at \(\lambda = 0.95\) and \(\gamma = 0.99\), where thousands of parallel robots generate rollouts and a critic absorbs the per-step contact noise so the advantage signal stays clean. Correct truncation handling at the fixed rollout-horizon boundary is what lets the critic bootstrap instead of treating every timeout as a fall, and this convention is typically among the contributing factors when the policy reaches a stable trot within minutes of wall-clock training. The resulting policies transfer to the physical ANYmal with domain randomization.
Transformer critics and long-context advantage estimation (2024-2025). Advantage estimation with a fixed GAE window struggles when reward signals span hundreds of steps, as in whole-body manipulation or multi-stage assembly. The CMU Robotics Institute and ETH Zurich's Robotic Systems Lab have moved away from multilayer perceptron (MLP) critics toward Transformer-based value networks that attend over the entire rollout history. Shi et al. (2024) "Yell At Your Robot" (RSS 2024, CMU) show that a history-conditioned critic stabilizes policy learning for contact-rich bimanual tasks where a single misstep 60 steps earlier cascades into task failure, a regime where standard GAE with lambda=0.95 fails to trace credit accurately.
Hybrid on-policy/off-policy advantage correction (2024-2025). Classic GAE is tied to on-policy rollouts, which wastes expensive real-robot or high-fidelity simulator data. A 2024 research direction, active at Berkeley and DeepMind, mixes a small buffer of high-quality off-policy demonstrations with fresh rollouts, then applies importance-weighted GAE (each residual is rescaled by the probability ratio between the policy that generated it and the current policy, correcting for the mismatch) so the advantage targets remain unbiased even when behavior and target policies differ. Hansen et al. (2024) "TDMPC2" (ICLR 2024) and follow-on work from the same group demonstrate that a single critic trained on mixed data substantially reduces the wall-clock hours needed to reach locomotion benchmarks in IsaacGym.
Learned advantage normalizers for multi-reward embodied tasks (2025-2026). Robots trained with composite rewards (tracking, energy, safety, contact quality) experience advantage distributions with very different scales across reward terms. Naive global normalization erases that structure. Groups at Stanford and ETH are learning per-reward advantage scaling heads jointly with the critic, a method sometimes called "advantage whitening per objective." Lee et al. (2025) "Cascade" (CoRL 2025) report that per-objective normalization reduces policy collapse on whole-body loco-manipulation tasks compared to a single shared normalizer.
Open problem. All three directions above rely on a critic that generalizes across robot morphologies. A PhD-tractable question: can a single Transformer critic trained jointly on quadruped, humanoid, and arm-manipulation rollouts learn a universal advantage estimator that bootstraps effectively on a new morphology with fewer than 1,000 environment steps? This requires understanding what geometric or kinematic inductive bias, if any, should be built into the critic architecture versus learned from multi-task data.
Can you identify which terms in a rollout affect the actor loss, which affect the critic loss, and which termination flags decide whether GAE should bootstrap?
Answering that self-check correctly depends on keeping two bookkeeping streams apart, because the actor and critic draw on the same rollout yet pull in different directions. The actor and critic optimize different targets from the same experience, a principle called separate losses from shared rollouts. The actor asks which sampled actions should become more likely. The critic asks which states predict future return. If these targets are mixed casually, a bug in value learning can masquerade as a policy improvement.
Embodied systems add one more complication: the critic often sees partial observations, not the full physical state. If the value function cannot infer hidden contact state, object slip, battery sag, or actuator temperature, its baseline will be noisy. That does not make actor-critic invalid, but it does mean the value diagnostics must be read alongside physical failure labels.
| Estimator | Strength | Embodied Risk |
|---|---|---|
| Monte Carlo return | Uses complete future reward evidence. | High variance when late physical events dominate the episode. |
| One-step TD | Low variance and fast feedback. | Biased when the critic misses delayed contact consequences. |
| GAE with \(\lambda\) near 0.95 | Balances delayed credit and variance. | Sensitive to truncation handling and value-function quality. |
| Normalized advantages | Stabilizes batch scale for PPO. | Can hide reward-scale bugs if raw advantages are never inspected. |
Whichever estimator from the table above you settle on, its raw output still has to be rescaled before PPO can use it safely, which is where the next step comes in.
Code Fragment 2 shows the second piece most PPO implementations apply after GAE: advantage normalization. This is not part of the theorem; it is a practical stabilizer that keeps the policy loss scale consistent across batches.
- Compute advantages before shuffling minibatches, using the rollout time order.
- Normalize advantages after GAE, using the full batch mean and standard deviation.
- Keep raw advantages in logs so reward-scale and critic failures remain visible.
- Train the value function on returns compatible with the same bootstrap convention.
- Plot value prediction, return target, and failure labels for several complete episodes.
# Normalize advantages after GAE so PPO sees a stable loss scale.
# Keep raw values for diagnostics because normalization can hide reward bugs.
advantages = [0.746, 0.691, 0.316, -0.300]
mean_advantage = sum(advantages) / len(advantages)
variance = sum((x - mean_advantage) ** 2 for x in advantages) / len(advantages)
std_advantage = variance ** 0.5
normalized = [(x - mean_advantage) / (std_advantage + 1e-8) for x in advantages]
print([round(x, 3) for x in normalized])
mean_advantage and std_advantage, so PPO sees a stable loss scale across batches.Normalization keeps the loss scale stable when everything works, but it also hides trouble when the critic underneath is sick, so debugging starts one level down. When actor-critic training fails, check critic health first. A value loss that falls while episode behavior worsens can mean the critic learned the wrong shortcut, such as predicting timeout length rather than task progress. A value loss that never falls can turn every advantage estimate into high-variance noise.
For actor-critic and GAE, compare only construct-matched metrics co-computed in one pass on one configuration: same rollout horizon, same bootstrap convention, same \(\gamma\), same \(\lambda\), same value target, and same perturbation suite. Save raw advantages, normalized advantages, value predictions, returns, truncation flags, and failure labels in one artifact.
Actor-critic methods make policy gradients usable by asking a sharper question: was this action better than expected from this state? GAE controls how much delayed embodied evidence flows backward into that answer.
Given a five-step rollout with rewards, values, and termination flags, compute TD residuals, GAE advantages, normalized advantages, and value targets. Mark which steps should bootstrap if the rollout ended by timeout instead of task failure.
Lab: Sweeping the GAE lambda dial
Goal: Build direct intuition for the bias-variance tradeoff that \(\lambda\) controls by measuring how it changes advantage variance and learning speed on a real control task.
Tools needed: Python with Gymnasium (CartPole-v1), Stable-Baselines3 (or CleanRL's single-file ppo.py), and Matplotlib. About 15-30 minutes including training runs.
What to vary: Run PPO with gae_lambda set to 0.0, 0.5, 0.9, 0.95, and 1.0, holding \(\gamma = 0.99\), the seed, and all other hyperparameters fixed. For each run, also log the raw (pre-normalization) advantage tensor from one rollout batch.
What to observe: Plot episode return versus environment steps for each \(\lambda\), and separately plot the standard deviation of the raw advantages per batch. You should see variance rise monotonically as \(\lambda \to 1\) (Monte Carlo regime), while \(\lambda = 0\) learns slowly or unstably because it leans entirely on an untrained critic. The middle values (0.9 to 0.95) typically reach a solved policy fastest. As a stretch, add a fixed time limit shorter than the natural episode and confirm that mishandling the truncation flag (treating timeout as termination) visibly degrades the higher-\(\lambda\) runs.
Project Ideas
Beginner (weekend): Implement GAE from scratch on the CartPole-v1 environment in Gymnasium, then sweep lambda from 0 to 1 and plot how advantage variance and training speed change. The key challenge is correctly handling the truncation flag so the backward recursion stops bootstrapping only on true termination, not on rollout buffer boundaries.
Intermediate (1-2 weeks): Train a hopper or ant locomotion policy in MuJoCo using CleanRL's PPO implementation, then replace the on-policy critic with a privileged critic that receives hidden simulator state (contact forces, joint velocities not passed to the actor). The key challenge is verifying that removing the privileged critic at deployment time does not collapse the policy, which requires logging explained variance separately for privileged and deployable observations throughout training.
Intermediate (1-2 weeks): Use Isaac Lab to train a quadruped stand-up recovery task with GAE, then transfer the policy to PyBullet to test sim-to-real gap sensitivity. The key challenge is auditing which value-function shortcuts (ground-truth body orientation, contact state) break when the simulator changes, and patching the truncation convention so rollout boundaries in the faster Isaac Lab simulator do not silently suppress credit for late recovery rewards.
What's Next?
This section showed how actor-critic methods and GAE reduce policy-gradient variance while preserving delayed reward evidence. Next, Section 15.4 adds trust-region control so those actor updates do not move too far from the rollout policy.
Schulman, J. et al. (2017). Proximal Policy Optimization Algorithms. arXiv.
Introduces the clipped surrogate objective that prevents large policy updates without the second-order KL constraint of TRPO. Read Section 3 for the clipping mechanism and Section 5 for the implementation details including value-function loss coefficient and entropy bonus that appear in nearly every modern PPO codebase.
Derives the generalized advantage estimator (GAE) as an exponentially weighted average of n-step returns, controlled by the lambda parameter. Read Section 3 for the bias-variance trade-off analysis; in practice lambda around 0.95 is the default in most PPO implementations and understanding why requires this paper.
Schulman, J. et al. (2015). Trust Region Policy Optimization. ICML.
Introduces the trust-region constraint that bounds policy update size using KL divergence, providing a monotonic improvement guarantee. Read Section 3 for the surrogate objective and Theorem 1 for the lower bound; PPO simplifies this into a clipped ratio that achieves similar stability with far less implementation complexity.
Formalizes the policy gradient theorem showing that the gradient of expected return can be expressed as an expectation over state-action pairs. Read to understand why on-policy sampling is sufficient for an unbiased gradient estimate and how the baseline reduces variance without introducing bias.
The original REINFORCE paper deriving the likelihood-ratio policy gradient. Read Section 2 for the REINFORCE update rule and Section 5 for baseline subtraction. This is the direct predecessor to actor-critic and PPO; understanding it makes the clipped surrogate objective in Schulman et al. 2017 concrete.
CleanRL documentation and source code.
Provides single-file, dependency-minimal RL implementations that make every algorithmic choice visible on one screen. Read the PPO and SAC files side by side with the corresponding papers; CleanRL is the fastest way to verify that you understand which implementation details matter versus which are optional.