PPO Algorithm › Trust Region Methods
Language AI HandbookAll chapters PPO Algorithm › Trust Region MethodsOne section · Sections in this chapter3 / 14 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The insight behind trust region methods is to constrain how much the policy can change in each update. Rather than blindly following the gradient wherever it leads, we optimize the policy subject to a constraint that keeps the new policy "close" to the old one. This approach recognizes a basic tension in optimization: we want to improve the policy as quickly as possible. However, our confidence in the improvement direction decreases the further we move from where we collected our data. Gradients computed from sampled trajectories accurately describe performance improvement near the current policy, but extrapolating far from observed data becomes unreliable.
Think of a trust region as the area on a topographic map that your GPS unit has surveyed at high resolution. Within that region, the contour lines are accurate and you can safely navigate. Outside that region, the map was generated from coarser satellite data and might have cliffs, valleys, or impassable terrain that looks navigable on the map. You would not plan a route that takes you far outside your high-resolution zone. Similarly, the policy gradient is an accurate local guide only within the neighborhood of states and actions you have recently observed. Venturing far outside that neighborhood means relying on gradient extrapolations that may be wildly wrong.
A trust region is a neighborhood around the current parameters within which a local approximation of the objective function is trusted to be accurate. Optimization proceeds by maximizing this approximation within the trust region, then updating the region based on how well the approximation matched reality. If the approximation was good, the trust region expands. If it was poor, the region shrinks. This adaptive mechanism maintains alignment between the model and reality throughout training.
The key insight behind all trust region methods is that gradient estimates are only reliable near the data they were computed from. Moving the policy far from the current policy means the state-action distribution shifts, and the advantages computed from old data no longer accurately reflect the new policy's performance. The trust region constraint formalizes the boundary beyond which you should not venture without collecting new data. Enforcing this boundary ensures that the objective function improvement you see during optimization corresponds to actual performance improvement in the environment.

Trust Region Policy Optimization (TRPO), PPO's predecessor, formalizes this using KL divergence as a constraint. The KL divergence measures how different two probability distributions are, which makes it a natural choice for measuring policy similarity. Policies that assign similar probabilities to actions have low KL divergence, while policies that behave very differently have high KL divergence. This makes KL divergence a precise, mathematically grounded way to define "how much the policy has changed."
The TRPO objective addresses the policy update problem by maximizing expected advantage while explicitly constraining how much the policy can change. It maximizes the expected advantage weighted by the importance sampling ratio, which allows us to use data from the old policy to evaluate the new policy, while constraining the KL divergence between old and new policies:
To understand how this constrained optimization problem balances improvement against stability, examine each component:
- : parameters of the new policy being optimized
- : parameters of the old policy from which data was collected
- : expectation over states and actions sampled from trajectories collected using the old policy
- : a state sampled from the state distribution under the old policy
- : an action sampled from the old policy in state
- : probability of action in state under the new policy
- : probability of action in state under the old policy
- : the importance sampling ratio, which reweights data from the old policy to evaluate the new policy
- : advantage function computed under the old policy, measuring how much better action is than average in state
- : expectation over states from the state distribution under the old policy
- : Kullback-Leibler divergence measuring how much the new policy distribution differs from the old policy distribution
- : maximum allowed KL divergence, the trust region radius
This constraint ensures the new policy does not diverge too far from the old policy in terms of the probability distributions over actions. The ratio is called the importance sampling ratio and allows us to evaluate the new policy using data collected from the old policy. This ratio acts as a correction factor: if the new policy is twice as likely to take an action as the old policy, we weight that action's contribution twice as heavily to account for the fact that it would occur more frequently under the new policy.
Why TRPO Works But Is Complex
TRPO guarantees monotonic improvement under certain conditions, meaning the policy never gets worse than the previous version. This guarantee provides the stability that vanilla policy gradients lack. However, the mathematical machinery required to enforce this guarantee comes with significant computational costs: computing Fisher information matrices and solving linear systems.
Solving the constrained optimization problem requires computing second-order derivatives, specifically the Fisher information matrix, and performing conjugate gradient optimization to solve a system of linear equations. This makes TRPO computationally expensive and difficult to implement correctly. The Fisher information matrix has size where is the number of policy parameters, so even storing it is impractical for large neural networks. Computing the matrix-vector product required by conjugate gradient solvers requires special tricks involving second-order automatic differentiation. Computing the Fisher information matrix across multiple workers in distributed settings adds significant overhead.
PPO achieves similar stability guarantees with a first-order method by replacing the hard constraint with a penalty built directly into the objective function. Instead of solving a constrained optimization problem, PPO modifies the objective itself to discourage excessive policy changes. This transformation from constraint to penalty makes PPO dramatically simpler to implement while preserving the needed benefits of trust region methods. The resulting algorithm fits cleanly into any standard deep learning training loop, with no exotic optimization machinery required.