Chapter 204
📝Draft

Proximal Policy Optimization

The most popular deep RL algorithm in practice

Prerequisites:

What You'll Learn

  • Explain why large policy updates are dangerous
  • Understand the trust region concept and its importance
  • Implement PPO with the clipped surrogate objective
  • Tune PPO hyperparameters effectively
  • Train agents using PPO on standard benchmarks

Policy gradient methods are powerful, but fragile. One bad update can destroy a good policy. TRPO solved this elegantly but with complex math. Then in 2017, OpenAI introduced PPO - a simpler heuristic that performs comparably in practice. Today, PPO is one of the most widely used deep RL algorithms, especially in on-policy settings.

Why PPO?

The core insight is simple: discourage the new policy from moving too far from the old one.

  • TRPO enforces this with a KL divergence constraint solved via second-order optimization
  • PPO instead uses a clipped objective that removes the incentive for large per-sample updates and can be optimized with standard gradient descent (it discourages, but does not bound, policy change — practitioners monitor KL as the safeguard)

The result: simpler code, similar performance, and remarkable robustness.

Chapter Overview

This chapter explains PPO, the workhorse algorithm behind modern RL applications from game-playing agents to RLHF for language models.

The Big Picture

📖Proximal Policy Optimization

A policy gradient algorithm that discourages large policy updates by clipping the surrogate objective when the probability ratio between new and old policies leaves a small interval. Samples pushed outside the interval stop contributing gradient, removing the incentive for destructively large updates while maintaining simplicity.

Mathematical Details

The PPO clipped objective:

LCLIP(θ)=Et[min(rt(θ)A^t,clip(rt(θ),1ϵ,1+ϵ)A^t)]L^{\text{CLIP}}(\theta) = \mathbb{E}_t \left[ \min\left( r_t(\theta) \hat{A}_t, \text{clip}(r_t(\theta), 1-\epsilon, 1+\epsilon) \hat{A}_t \right) \right]

where rt(θ)=πθ(atst)πθold(atst)r_t(\theta) = \frac{\pi_\theta(a_t|s_t)}{\pi_{\theta_{\text{old}}}(a_t|s_t)} is the probability ratio.

Think of PPO as a “cautious optimizer”:

  • If an action looks good (positive advantage), increase its probability - but stop rewarding increases beyond the clip range
  • If an action looks bad (negative advantage), decrease its probability - but stop rewarding decreases beyond the clip range
  • The clip removes the incentive to overreact to any single batch of experience

Prerequisites

This chapter assumes familiarity with:

  • The advantage function from Actor-Critic Methods
  • GAE for advantage estimation
  • Basic policy gradient concepts

Key Takeaways

  1. Large policy updates can be catastrophic
    One bad update can destroy a good policy. TRPO constrains updates with a trust region; PPO discourages them with clipping.
  2. PPO replaces second-order optimization with clipping
    TRPO needs conjugate gradients and line search; PPO runs on plain gradient descent.
  3. Clipping removes incentive; it does not bound change
    A clipped sample stops contributing gradient, but other samples still move the shared parameters—ratios and KL can exceed the clip range. Monitor KL in practice.
  4. PPO is robust across domains
    Forgiving hyperparameters and stable training made it the default for games, robotics, and more.
  5. PPO powers RLHF for language models
    The InstructGPT pipeline—precursor to ChatGPT—used PPO as its RL algorithm.

Check Your Understanding

Check your understanding
1. What does PPO’s clipping actually bound?
2. Why do practical PPO implementations monitor the empirical KL divergence and stop update epochs early?
3. A sample has negative advantage (A < 0), and its ratio has been pushed above 1+ε by updates on other samples. What does the clipped objective do?
4. Why can PPO reuse the same batch of experience for multiple optimization epochs when REINFORCE cannot?
5. How does PPO’s relationship to policy-change control differ from TRPO’s?
Next ChapterModel-Based RL