Skip to content
mlmentorship

Proximal Policy Optimization (PPO)

Constrain policy updates with a clipped surrogate objective. The default actor-critic algorithm in 2026. For robotics, games, and RLHF.

Published · 6 min read ·Specialist ·Advanced

Visual quick review

Visual first · depth when needed

Given the sign of one sample's advantage, identify which probability-ratio boundary creates PPO's plateau and explain why moving farther in that beneficial direction gives no additional clipped-objective gain.

Preparing the visual…

Summary

PPO (Schulman et al., 2017) is a policy-gradient algorithm that keeps each gradient update close to the previous policy by clipping the ratio of new to old action probabilities. It is the default RL algorithm for continuous control, large-scale games, and RLHF in 2026.

PPO is the most-used deep RL algorithm for several reasons:

  • Stable across domains. Robotics, Atari, locomotion, language model fine-tuning all use it with similar hyperparameters.
  • Simple: no second-order Hessian-vector products (unlike TRPO).
  • Mini-batch friendly: samples can be reused for several epochs per rollout.
  • Backbone of RLHF: ChatGPT, Claude, Llama-Instruct were all trained with PPO on reward signals.

The objective

For a policy and old policy collected during the latest rollout, define the probability ratio:

PPO maximizes the clipped surrogate:

with advantage estimate (typically GAE) and clip parameter .

For one sampled action, the min creates a one-sided plateau. With , increasing the action’s probability stops improving this term once . With , decreasing its probability stops improving the term once .

Clipped surrogate geometry

Where does PPO remove the incentive to move an action probability farther?

PPO clipped objective for positive and negative advantages Two plots show one sample's objective contribution against the new-to-old action probability ratio r, using epsilon 0.2. For positive advantage, the solid clipped objective rises with the dashed unclipped objective until r equals 1.2, then becomes a horizontal plateau; increasing the action probability farther gives no additional objective. For negative advantage, the solid objective is a horizontal plateau below r equals 0.8, then follows the descending dashed line; decreasing the action probability farther gives no additional objective. Both plots mark r equals 1 as the unchanged policy. A > 0 · sampled action was better than expected A < 0 · sampled action was worse than expected 1 + ε = 1.2 1 − ε = 0.8 r = 1: unchanged policy r = 1: unchanged policy ratio r = πnew(a|s) / πold(a|s) ratio r = πnew(a|s) / πold(a|s) no extra gain → ← no extra gain solid: clipped minimum dashed: rA without clipping solid: clipped minimum dashed: rA without clipping sample objective (maximize ↑) sample objective (maximize ↑)
Read it this way: start at the marked old policy, r = 1. For a positive advantage, move right until the solid objective flattens at 1 + ε; for a negative advantage, move left until it flattens at 1 − ε. Past the relevant boundary, PPO supplies no extra reward for pushing that sampled action farther, but clipping does not guarantee that the whole policy stays within that range.

Full PPO objective

In addition to , PPO usually includes:

  • Value function loss: trained jointly.
  • Entropy bonus: . Encourages exploration.

Total:

Standard , .

The training loop

For each iteration:

  1. Rollout: run policy in the environment for steps × parallel actors. Collect .
  2. Compute advantages: via GAE using .
  3. Optimize: SGD on for epochs over the rollout data, in mini-batches.
  4. Update: at the start of next iteration.

Typical: per actor, actors, epochs, mini-batch size 64–256, , , , learning rate .

Why clipping helps

Without clipping, repeated SGD epochs over one rollout can cause runaway policy updates. A large positive advantage gets multiplied by an unbounded ratio. The policy then moves too far from the data distribution, and learning can collapse.

Clipping removes the objective’s incentive to keep changing a sampled action beyond the sign-dependent threshold. It is not a hard constraint on the new policy: shared parameters and other samples can still move it farther, so implementations monitor approximate KL and may stop optimization early.

PPO for RLHF

In RLHF (see RLHF and DPO):

  • State: prompt + partial response.
  • Action: next token.
  • Reward: scalar from the reward model at end of response, plus per-token KL penalty to a frozen reference model.
  • Policy: the LLM being aligned.

The KL penalty is critical. It prevents the policy from drifting into reward-model-exploiting nonsense. Without it, PPO will find adversarial token sequences that maximize the reward model but produce gibberish.

PPO vs. alternatives

AlgorithmWhen to use
PPODefault for on-policy with continuous or discrete actions; RLHF
SACOff-policy continuous control with sample efficiency required
DQNDiscrete actions, off-policy data abundant
DPO (LLM)Direct preference optimization without explicit reward model. Increasingly displacing PPO for LLM alignment
TRPOWhen KL constraint matters more than simplicity

Common pitfalls

  • Wrong advantage normalization. Normalize advantages within each mini-batch (zero mean, unit std); without, learning is unstable.
  • Using too many epochs per rollout. leads to too much off-policy drift; clipping stops bias but variance grows.
  • Forgetting the value function loss coefficient. keeps actor and critic on similar scales.
  • Logging episodic reward only. Watch entropy, KL between consecutive policies, value-function explained variance, clip fraction. Each diagnoses different failure modes.
  • Treating PPO as parameter-free. It has many hyperparameters; defaults work but tuning gives ~2× sample efficiency.