Simple Algorithm
Reinforcement Learning · Bootstrapping · 24 min

Trust Regions: TRPO & PPO

Natural gradients, KL constraints and clipping: taking safe policy steps.

A policy-gradient step that is tiny in parameter space can rewrite an agent's behavior, and an on-policy agent then gathers its next batch with the damaged policy. This lesson builds the tools that keep steps safe: a surrogate objective that scores nearby policies using old data, a KL-divergence trust region whose local solution is the natural gradient (TRPO), and PPO's clipped probability ratio, the workhorse of modern deep RL and of RLHF.

What you’ll learn

  • Explain why the Euclidean length of a parameter step is the wrong measure of a policy update, and measure it with the KL divergence instead.
  • Derive the surrogate objective from the performance difference lemma and show that it matches JJ in value and gradient at the old policy.
  • Derive the trust-region step 2δ/(g⊤F−1g) F−1g\sqrt{2\delta/(\mathbf g^\top F^{-1}\mathbf g)}\,F^{-1}\mathbf g and describe how TRPO computes it with conjugate gradient and a line search.
  • Analyze PPO's clipped objective sample by sample, state its KL-penalty variant, and implement its loss and training loop.
  • Explain, from multi-epoch experiments on one batch, what clipping protects against and what it does not.

Small in parameters, large in behavior

Gradient ascent measures a step by the Euclidean length of Δθ\Delta\boldsymbol\theta. For a policy that is the wrong ruler. How much the behavior changes depends on where you are and on how the policy happens to be parameterized, and an on-policy learner pays twice for a step that is too long: the worse policy collects the next batch, so one bad update also spoils the data that could have corrected it.

A better ruler compares action distributions. The KL divergence DKL(πold(⋅∣s) ∥ π(⋅∣s))\KL\big(\pi_{\text{old}}(\cdot\mid s)\,\|\,\pi(\cdot\mid s)\big) is zero when the two policies act identically in state ss and grows as the new policy makes the old one's actions unlikely. For a one-dimensional Gaussian policy whose mean moves by Δ\Delta while its standard deviation σ\sigma stays fixed, it has a closed form:

DKL(N(m,σ2) ∥ N(m+Δ,σ2))=Δ22σ2\KL\big(\mathcal N(m,\sigma^2)\,\big\|\,\mathcal N(m+\Delta,\sigma^2)\big)=\frac{\Delta^2}{2\sigma^2}
The same mean shift Δ\Delta is a small or a large change of behavior depending on σ\sigma, a quantity that itself changes during training.
Predict before you look

Late in training a Gaussian policy has shrunk its standard deviation to σ=0.05\sigma=0.05. One gradient step moves its mean by Δ=0.1\Delta=0.1, a small change in parameter space. How large is the KL divergence between the old and the new policy, in nats?

Show the answer

2

Δ2/(2σ2)=0.01/0.005=2\Delta^2/(2\sigma^2)=0.01/0.005=2 nats. The new mean sits two old standard deviations away: the new policy puts only about 16% of its actions inside [m−σ,m+σ][m-\sigma,m+\sigma], where the old one put 68%. The same step at σ=1\sigma=1 changes the policy by 0.0050.005 nats, 400 times less. A learning rate that was safe early in training is reckless late in it.

The parameterization is an arbitrary choice that the Euclidean ruler takes seriously. Describe the same Gaussian by σ\sigma or by log⁡σ\log\sigma, or a softmax policy by logits shifted by a constant, and plain gradient ascent takes different steps through the same family of policies. Near a deterministic policy the plain gradient also shrinks toward zero (Global Convergence of Policy Gradients shows how badly), so a fixed step size is too long in some places and too short in others.

The rest of this lesson builds three tools: an objective that predicts how good a nearby policy is from data the old policy collected, a KL budget for each update, and two ways of staying within it, TRPO's constraint and PPO's clipping.

A surrogate objective you can evaluate

To choose a step you must predict the return of a candidate policy π\pi without running it. The performance difference lemma (proved in Advantages & the Performance Difference Lemma) gives the exact answer in terms of the old policy's advantages:

J(π)−J(πold)=11−γ ES∼dμπ,  A∼π(⋅∣S)[Aπold(S,A)]J(\pi)-J(\pi_{\text{old}})=\frac{1}{1-\gamma}\,\E_{S\sim d^{\pi}_\mu,\;A\sim\pi(\cdot\mid S)}\big[A^{\pi_{\text{old}}}(S,A)\big]
dμπ(s)=(1−γ)∑tγtPr⁡(St=s)d^\pi_\mu(s)=(1-\gamma)\sum_t\gamma^t\Pr(S_t=s) is the normalized discounted state distribution of the new policy. It is the one ingredient that old data cannot supply.
DerivationFrom the lemma to the surrogate
  1. Lπold(π)=J(πold)+11−γ ES∼dμπold,  A∼π(⋅∣S)[Aπold(S,A)]L_{\pi_{\text{old}}}(\pi)=J(\pi_{\text{old}})+\frac{1}{1-\gamma}\,\E_{S\sim d^{\pi_{\text{old}}}_\mu,\;A\sim\pi(\cdot\mid S)}\big[A^{\pi_{\text{old}}}(S,A)\big]

    Replace the new policy's state distribution by the old one's. This is the only approximation, and it defines the surrogate objective:

  2. Lπold(πθ)=J(πold)+11−γ ES∼dμπold,  A∼πold(⋅∣S)[ρ(θ) Aπold(S,A)]L_{\pi_{\text{old}}}(\pi_{\boldsymbol\theta})=J(\pi_{\text{old}})+\frac{1}{1-\gamma}\,\E_{S\sim d^{\pi_{\text{old}}}_\mu,\;A\sim\pi_{\text{old}}(\cdot\mid S)}\big[\rho(\boldsymbol\theta)\,A^{\pi_{\text{old}}}(S,A)\big]

    The logged actions were drawn by πold\pi_{\text{old}}, so reweight each one by the probability ratio ρ(θ)=πθ(A∣S)/πold(A∣S)\rho(\boldsymbol\theta)=\pi_{\boldsymbol\theta}(A\mid S)/\pi_{\text{old}}(A\mid S), an importance weight on a single action (never on a whole trajectory):

  3. L(θold)=J(θold),∇L(θold)=11−γ E[Aπold(S,A) ∇log⁡πθold(A∣S)]=∇J(θold)L(\boldsymbol\theta_{\text{old}})=J(\boldsymbol\theta_{\text{old}}),\qquad\nabla L(\boldsymbol\theta_{\text{old}})=\frac{1}{1-\gamma}\,\E\big[A^{\pi_{\text{old}}}(S,A)\,\nabla\log\pi_{\boldsymbol\theta_{\text{old}}}(A\mid S)\big]=\nabla J(\boldsymbol\theta_{\text{old}})

    At θ=θold\boldsymbol\theta=\boldsymbol\theta_{\text{old}} every ratio is 1 and advantages average to zero under their own policy, so L=JL=J. Since ∇ρ=ρ ∇log⁡πθ\nabla\rho=\rho\,\nabla\log\pi_{\boldsymbol\theta}, the gradient there is exactly the policy gradient theorem's:

The surrogate is a first-order model of JJ, like a tangent line: exact in value and slope at πold\pi_{\text{old}}, increasingly wrong as π\pi moves away and its state distribution drifts from the data's. In code it is a batch average, L^(θ)=E^t[ρt(θ)A^t]\hat L(\boldsymbol\theta)=\hat\E_t\big[\rho_t(\boldsymbol\theta)\hat A_t\big], with advantage estimates A^t\hat A_t from a critic, usually GAE. The constant J(πold)J(\pi_{\text{old}}) and the factor 11−γ\frac{1}{1-\gamma} are dropped, and so, as in most policy-gradient code, is the weighting of step tt by γt\gamma^t (The Policy Gradient Theorem in Depth explains what that changes).

A KL budget, and the natural direction

The theorem is too cautious to use as stated. Its coefficient grows like (1−γ)−2(1-\gamma)^{-2}, about 4×104 ϵ4\times10^4\,\epsilon at γ=0.99\gamma=0.99, so the certified steps are minute, and a maximum over all states cannot be estimated from a batch. TRPO (trust region policy optimization) keeps the structure and makes two practical substitutions: an average KL over the visited states, which a batch can estimate, and a hard constraint with a fixed radius δ\delta instead of a penalty, because a coefficient that suits early training is wrong later on.

max⁡θ L^(θ)subject toDˉKL(θ)=E^t[DKL(πold(⋅∣St) ∥ πθ(⋅∣St))]≤δ\max_{\boldsymbol\theta}\ \hat L(\boldsymbol\theta)\qquad\text{subject to}\qquad\bar D_{\mathrm{KL}}(\boldsymbol\theta)=\hat\E_t\Big[\KL\big(\pi_{\text{old}}(\cdot\mid S_t)\,\big\|\,\pi_{\boldsymbol\theta}(\cdot\mid S_t)\big)\Big]\le\delta
DerivationSolving the local problem
  1. DˉKL(θold+Δ)=12 Δ⊤F Δ+O(∥Δ∥3),F=E^t EA∼πold(⋅∣St)[ψ ψ⊤]\bar D_{\mathrm{KL}}(\boldsymbol\theta_{\text{old}}+\Delta)=\tfrac12\,\Delta^\top F\,\Delta+O\big(\norm{\Delta}^3\big),\qquad F=\hat\E_t\,\E_{A\sim\pi_{\text{old}}(\cdot\mid S_t)}\big[\boldsymbol\psi\,\boldsymbol\psi^\top\big]

    At θold\boldsymbol\theta_{\text{old}} the KL is zero and so is its gradient (the score has mean zero under the old policy), so it starts quadratically. Its Hessian is the Fisher information matrix FF, the covariance of the score ψ=∇log⁡πθold(A∣S)\boldsymbol\psi=\nabla\log\pi_{\boldsymbol\theta_{\text{old}}}(A\mid S):

  2. g=λ FΔ⟹Δ=1λ F−1g\mathbf g=\lambda\,F\Delta\qquad\Longrightarrow\qquad\Delta=\tfrac1\lambda\,F^{-1}\mathbf g

    Linearize the surrogate, L^≈L^(θold)+g⊤Δ\hat L\approx\hat L(\boldsymbol\theta_{\text{old}})+\mathbf g^\top\Delta with g=∇L^(θold)\mathbf g=\nabla\hat L(\boldsymbol\theta_{\text{old}}), and set the gradient of the Lagrangian g⊤Δ−λ(12Δ⊤FΔ−δ)\mathbf g^\top\Delta-\lambda\big(\tfrac12\Delta^\top F\Delta-\delta\big) to zero:

  3. Δ⋆=2δg⊤F−1g  F−1g,g⊤Δ⋆=2δ  g⊤F−1g\Delta^\star=\sqrt{\frac{2\delta}{\mathbf g^\top F^{-1}\mathbf g}}\;F^{-1}\mathbf g,\qquad\mathbf g^\top\Delta^\star=\sqrt{2\delta\;\mathbf g^\top F^{-1}\mathbf g}

    The constraint is active, 12Δ⊤FΔ=δ\tfrac12\Delta^\top F\Delta=\delta, which fixes λ\lambda and gives the step and the improvement the model predicts:

The direction F−1gF^{-1}\mathbf g is the natural policy gradient (Kakade, 2001): steepest ascent when distance is measured by KL instead of by parameters, and the same policy change whichever parameterization you pick. TRPO (Schulman et al., 2015) computes the step for networks whose Fisher matrix is too large even to store:

  1. Collect a batch with πold\pi_{\text{old}} and estimate the advantages.
  2. Compute g\mathbf g and solve Fx=gF\mathbf x=\mathbf g approximately by conjugate gradient, which touches FF only through products FvF\mathbf v, each about as costly as one more gradient. The paper ran 10 iterations and computed the products on 10% of the batch.
  3. Scale to the radius: Δ=2δ/(x⊤Fx)  x\Delta=\sqrt{2\delta/(\mathbf x^\top F\mathbf x)}\;\mathbf x, with δ=0.01\delta=0.01 in all of the paper's experiments.
  4. Backtrack: shrink Δ\Delta geometrically until the actual surrogate improves and the actual average KL is at most δ\delta.
Check your understanding

TRPO solves for its step in closed form, yet it still ends every update with a backtracking line search. Why?

  1. The closed-form step solves a model (a linear surrogate and a quadratic KL), so the true surrogate may fall or the true KL may exceed δ\delta; the line search shrinks the step until both checks pass
  2. To find the largest step size for which the true return JJ improves, measured with fresh rollouts
  3. Because conjugate gradient returns only the direction of F−1gF^{-1}\mathbf g, never its length
  4. To keep every probability ratio inside [1−ϵ,1+ϵ][1-\epsilon,1+\epsilon]
Show the answer

A. The closed-form step solves a model (a linear surrogate and a quadratic KL), so the true surrogate may fall or the true KL may exceed δ\delta; the line search shrinks the step until both checks pass

The step is optimal for the local model, which is accurate only for small steps. The line search evaluates the real surrogate and the real average KL on the batch and halves the step (or shrinks it by another factor) until the surrogate has improved and the constraint holds. No new rollouts are needed.

PPO: clip the incentive, keep the penalty

TRPO is complicated to implement, and its second-order step does not fit architectures with noise, such as dropout, or with parameters shared between the policy and the value function. PPO, proximal policy optimization (Schulman, Wolski, Dhariwal, Radford & Klimov, 2017), runs ordinary first-order optimizers for several epochs of minibatches on each batch and builds the caution into the objective instead:

LCLIP(θ)=E^t[min⁡(ρt(θ) A^t, clip⁡(ρt(θ),1−ϵ,1+ϵ) A^t)]L^{\text{CLIP}}(\boldsymbol\theta)=\hat\E_t\Big[\min\Big(\rho_t(\boldsymbol\theta)\,\hat A_t,\ \operatorname{clip}\big(\rho_t(\boldsymbol\theta),1-\epsilon,1+\epsilon\big)\,\hat A_t\Big)\Big]
The clipped surrogate objective, with ϵ=0.2\epsilon=0.2 in the paper's continuous-control experiments. At θold\boldsymbol\theta_{\text{old}} every ratio is 1, so it agrees with the surrogate L^\hat L in value and gradient there.
DerivationWhat one sample contributes
  1. ∇θmin⁡(ρtA^t, clip⁡(ρt,1−ϵ,1+ϵ) A^t)={0,A^t>0 and ρt>1+ϵ,0,A^t<0 and ρt<1−ϵ,A^t ∇ρt,otherwise.\nabla_{\boldsymbol\theta}\min\Big(\rho_t\hat A_t,\ \operatorname{clip}(\rho_t,1-\epsilon,1+\epsilon)\,\hat A_t\Big)=\begin{cases}\mathbf 0, & \hat A_t>0\ \text{and}\ \rho_t>1+\epsilon,\\ \mathbf 0, & \hat A_t<0\ \text{and}\ \rho_t<1-\epsilon,\\ \hat A_t\,\nabla\rho_t, & \text{otherwise.}\end{cases}

    Inside the band [1−ϵ,1+ϵ][1-\epsilon,1+\epsilon] the two arguments of the min coincide. Outside it, the min keeps the smaller one, and the clipped argument does not depend on θ\boldsymbol\theta. Case by case (wherever the gradient exists):

  2. A sample stops pulling only after its probability has already moved by more than a factor 1±ϵ1\pm\epsilon in the direction its advantage asks for. A move in the wrong direction is never clipped: a good action whose ratio fell below 1−ϵ1-\epsilon keeps its full gradient back up.

  3. LCLIP(θ) ≤ L^(θ)=E^t[ρt(θ) A^t]  for all θ,with equality at θoldL^{\text{CLIP}}(\boldsymbol\theta)\ \le\ \hat L(\boldsymbol\theta)=\hat\E_t\big[\rho_t(\boldsymbol\theta)\,\hat A_t\big]\ \text{ for all }\boldsymbol\theta,\qquad\text{with equality at }\boldsymbol\theta_{\text{old}}

    Since min⁡(x,y)≤x\min(x,y)\le x, the clipped objective lies below the surrogate everywhere: a pessimistic version that ignores gains beyond the band and keeps every loss.

Check your understanding

With ϵ=0.2\epsilon=0.2, four samples sit at these points during an update: (a) A^=+1\hat A=+1, ρ=1.3\rho=1.3; (b) A^=+1\hat A=+1, ρ=0.7\rho=0.7; (c) A^=−1\hat A=-1, ρ=0.7\rho=0.7; (d) A^=−1\hat A=-1, ρ=1.3\rho=1.3. Which of them contribute zero gradient to LCLIPL^{\text{CLIP}}?

  1. (a) and (d)
  2. (b) and (c)
  3. All four, since every ratio is outside [0.8,1.2][0.8,1.2]
  4. (a) and (c)
Show the answer

D. (a) and (c)

(a) is a good action already raised past 1+ϵ1+\epsilon and (c) a bad action already lowered past 1−ϵ1-\epsilon: both have moved far enough the way their advantages ask, so their terms are flat. (b) is a good action whose probability fell and (d) a bad action whose probability rose; the min keeps their unclipped terms, which pull them back. Being outside the band is not enough; the direction matters.

The paper's second variant, PPO-penalty, keeps the unclipped surrogate and subtracts β E^t[DKL(πold(⋅∣St) ∥ πθ(⋅∣St))]\beta\,\hat\E_t\big[\KL\big(\pi_{\text{old}}(\cdot\mid S_t)\,\|\,\pi_{\boldsymbol\theta}(\cdot\mid S_t)\big)\big], the penalty form that TRPO's theory suggests, with an adaptive coefficient: after each update measure the mean KL dd; if d<dtarg/1.5d<d_{\text{targ}}/1.5 halve β\beta, and if d>1.5 dtargd>1.5\,d_{\text{targ}} double it. The constants are heuristic, and the paper reports that the algorithm is not very sensitive to them.

Objective (PPO paper, Table 1)Average normalized score
No clipping or penalty−0.39
Clipping, ϵ=0.1\epsilon=0.1 / 0.20.2 / 0.30.30.76 / 0.82 / 0.70
Adaptive KL, dtarg=0.003d_{\text{targ}}=0.003 / 0.010.01 / 0.030.030.68 / 0.74 / 0.71
Fixed KL, β=0.3\beta=0.3 / 11 / 33 / 10100.62 / 0.71 / 0.72 / 0.69
Seven MuJoCo tasks, one million steps, three seeds each; scores rescaled so that a random policy gets 0 and the best result 1. Optimizing the plain surrogate for several epochs did worse than the random policy on HalfCheetah. With three seeds per task, read the ranking of the stabilized variants as suggestive rather than decisive.

Several epochs on one batch

PPO alternates collection and optimization. With NN parallel environments it collects TT steps from each with πold\pi_{\text{old}}, computes advantages A^t\hat A_t by GAE and value targets G^t=A^t+Vold(St)\hat G_t=\hat A_t+V_{\text{old}}(S_t), and then runs KK epochs of minibatch stochastic gradient steps on one combined loss:

L(θ)=−LCLIP(θ)+c1 E^t[(Vθ(St)−G^t)2]−c2 E^t[H(πθ(⋅∣St))]\loss(\boldsymbol\theta)=-L^{\text{CLIP}}(\boldsymbol\theta)+c_1\,\hat\E_t\Big[\big(V_{\boldsymbol\theta}(S_t)-\hat G_t\big)^2\Big]-c_2\,\hat\E_t\Big[\mathcal H\big(\pi_{\boldsymbol\theta}(\cdot\mid S_t)\big)\Big]
c1c_1 matters only when the policy and the value function share parameters; c2c_2 weights an entropy bonus that slows the collapse to a deterministic policy. The paper's MuJoCo runs used separate networks and no entropy bonus.
python
import torch

def ppo_loss(dist, actions, logp_old, adv, values, targets, eps=0.2, c1=0.5, c2=0.0):
    """dist: the current policy's distribution on a minibatch of states, e.g. a
    torch.distributions.Categorical; logp_old, adv, targets were stored at collection."""
    logp = dist.log_prob(actions)
    ratio = torch.exp(logp - logp_old)               # rho_t(theta), via logs for stability
    clipped = torch.clamp(ratio, 1 - eps, 1 + eps)
    policy_loss = -torch.min(ratio * adv, clipped * adv).mean()
    value_loss = (values - targets).pow(2).mean()
    return policy_loss + c1 * value_loss - c2 * dist.entropy().mean()

# One iteration: roll out N envs for T steps with pi_old, storing logp_old;
# adv = GAE(gamma=0.99, lam=0.95); targets = adv + V_old(s).
# Then for K epochs: shuffle the N*T samples into minibatches and take
# one optimizer step on ppo_loss per minibatch.

Only dist and values depend on the current parameters; everything stored at collection time is a constant. For a Gaussian policy over several action dimensions, sum the per-dimension log-probabilities (or wrap the distribution in torch.distributions.Independent).

PPO in practice, and the deeper lessons

The paper's settings became common defaults. For MuJoCo: 2,048 steps per iteration, 10 epochs, minibatches of 64, Adam with step size 3×10−43\times10^{-4}, γ=0.99\gamma=0.99 and GAE's λ=0.95\lambda=0.95. For Atari: 8 actors with 128 steps each, 3 epochs, minibatches of 256, ϵ=0.1\epsilon=0.1 and the Adam step size both annealed linearly to zero, a value-loss coefficient of 1 and an entropy coefficient of 0.01. OpenAI Five's Dota 2 agent was trained with PPO at a far larger scale.

In RLHF the policy is a language model, an action is a token, and a learned reward model scores the finished response. InstructGPT (Ouyang et al., 2022) fine-tuned GPT-3 models with PPO on that reward minus a per-token KL penalty toward the supervised fine-tuned model, a second leash on top of clipping that keeps the policy where the reward model can be trusted; its PPO-ptx variant also mixed gradients of the pretraining objective into the update. Critic-free relatives such as GRPO keep PPO's clipped ratio but replace the learned value function by the average reward of several responses to the same prompt (GRPO & Critic-Free Policy Optimization).

Key takeaways

  • Policy steps should be measured by how much behavior changes, for example by the KL divergence between old and new action distributions, not by the Euclidean length of the parameter change.
  • The surrogate Lπold(π)L_{\pi_{\text{old}}}(\pi) replaces the new policy's state distribution by the old one's; with probability ratios it is computable from old data and matches JJ in value and gradient at πold\pi_{\text{old}}.
  • A linearized surrogate under a quadratic KL budget gives the natural-gradient step 2δ/(g⊤F−1g) F−1g\sqrt{2\delta/(\mathbf g^\top F^{-1}\mathbf g)}\,F^{-1}\mathbf g; TRPO computes it with conjugate gradient on Fisher–vector products and checks it with a line search.
  • PPO's clipped objective zeroes a sample's gradient only once its ratio has left [1−ϵ,1+ϵ][1-\epsilon,1+\epsilon] in the direction its advantage favors; it lies below the surrogate and suits several epochs of minibatch SGD per batch.
  • Clipping limits the damage a noisy batch can do; it does not strictly bound the ratios or the KL, and it does not raise the average gain. PPO with a KL penalty toward a reference model is the classic optimizer of RLHF.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

The surrogate Lπold(π)L_{\pi_{\text{old}}}(\pi) and the exact J(π)J(\pi) from the performance difference lemma differ in one ingredient. Which?

  1. The surrogate uses the new policy's advantages AπA^\pi
  2. The surrogate ignores the discount factor
  3. The surrogate weights states by the old policy's distribution dμπoldd^{\pi_{\text{old}}}_\mu instead of the new policy's dμπd^{\pi}_\mu
  4. The surrogate samples actions from the new policy instead of the old one
Show the answer

C. The surrogate weights states by the old policy's distribution dμπoldd^{\pi_{\text{old}}}_\mu instead of the new policy's dμπd^{\pi}_\mu

Everything else is exact: both use the old policy's advantages, and the probability ratio reweights old actions without bias. Using the old state distribution is what makes the surrogate computable from old data, and also why it is trustworthy only near πold\pi_{\text{old}}: the bound on the gap grows with the KL divergence between the policies.

Question 2

In a TRPO update, conjugate gradient returns x≈F−1g\mathbf x\approx F^{-1}\mathbf g with g⊤F−1g=2\mathbf g^\top F^{-1}\mathbf g=2, and the radius is δ=0.01\delta=0.01. Before any backtracking, the step is c xc\,\mathbf x for which cc?

  1. c=0.1c=0.1
  2. c=0.01c=0.01
  3. c=0.02c=0.02
  4. c=0.2c=0.2
Show the answer

A. c=0.1c=0.1

c=2δ/(g⊤F−1g)=0.02/2=0.1c=\sqrt{2\delta/(\mathbf g^\top F^{-1}\mathbf g)}=\sqrt{0.02/2}=0.1. Check: the quadratic model of the KL is 12c2 x⊤Fx=12(0.01)(2)=0.01=δ\tfrac12c^2\,\mathbf x^\top F\mathbf x=\tfrac12(0.01)(2)=0.01=\delta, and the model predicts a surrogate gain of 2δ⋅2=0.2\sqrt{2\delta\cdot2}=0.2.

Question 3

PPO-penalty runs with target dtarg=0.01d_{\text{targ}}=0.01. After an update, the measured mean KL divergence is d=0.03d=0.03. What happens to the penalty coefficient β\beta?

  1. It is halved, so the next update can move further
  2. It stays the same, since dd is within a factor 3 of the target
  3. It is multiplied by d/dtarg=3d/d_{\text{targ}}=3
  4. It is doubled, because dd exceeds 1.5 dtarg=0.0151.5\,d_{\text{targ}}=0.015
Show the answer

D. It is doubled, because dd exceeds 1.5 dtarg=0.0151.5\,d_{\text{targ}}=0.015

The rule doubles β\beta when d>1.5 dtargd>1.5\,d_{\text{targ}} and halves it when d<dtarg/1.5d<d_{\text{targ}}/1.5, leaving it alone in between. A larger β\beta makes the next update more conservative, pulling the measured KL back toward the target.

Question 4

Which statement about PPO's clipped objective is correct?

  1. It keeps every probability ratio inside [1−ϵ,1+ϵ][1-\epsilon,1+\epsilon] throughout the update
  2. It removes each sample's incentive to move its ratio beyond the band in the direction its advantage favors, but other samples and shared parameters can still push the ratio further, so neither the ratios nor the KL divergence are strictly bounded
  3. It guarantees that the true return does not decrease
  4. It raises the average improvement per batch compared with optimizing the unclipped surrogate for the same number of epochs
Show the answer

B. It removes each sample's incentive to move its ratio beyond the band in the direction its advantage favors, but other samples and shared parameters can still push the ratio further, so neither the ratios nor the KL divergence are strictly bounded

A clipped sample contributes zero gradient, nothing more. Its ratio can still drift, through the gradients of other samples that share parameters with it, and there is no restoring force. What clipping reliably does is limit how far one noisy batch can drag the policy, which bounds the damage rather than raising the average gain.

Question 5

Two engineers train the same family of Gaussian policies, one parameterizing the spread by σ\sigma, the other by log⁡σ\log\sigma. In the limit of small steps, which update moves both through the same sequence of action distributions?

  1. Plain gradient ascent with equal learning rates
  2. Neither: the two parameterizations describe different policies
  3. The natural gradient F−1∇JF^{-1}\nabla J
  4. Both, as long as the learning rates are equal
Show the answer

C. The natural gradient F−1∇JF^{-1}\nabla J

The natural gradient is steepest ascent with respect to the KL divergence, which depends only on the distributions, not on their coordinates; for small steps it traces the same path of policies in any smooth, invertible reparameterization. The plain gradient's direction changes with the coordinates (by the Jacobian of the change of variables).

Go deeper

Further reading

  • J. Schulman, S. Levine, P. Abbeel, M. I. Jordan & P. Moritz, "Trust region policy optimization," ICML (2015).
  • J. Schulman, F. Wolski, P. Dhariwal, A. Radford & O. Klimov, "Proximal policy optimization algorithms," arXiv:1707.06347 (2017).
  • S. Kakade & J. Langford, "Approximately optimal approximate reinforcement learning," ICML (2002).
  • L. Ouyang, J. Wu, X. Jiang et al., "Training language models to follow instructions with human feedback," NeurIPS (2022).