The KL-constrained problem
Trust Region Policy Optimization (TRPO) makes the trade from Guide 1 explicit. Instead of penalizing the KL divergence with a fragile coefficient, it imposes a hard cap: maximize the surrogate objective subject to the average KL between old and new policy staying below a fixed budget. That budget is the radius of a trust region — the neighborhood in distribution space where the surrogate is trustworthy.
TRPO's core problem: maximize the importance-sampled surrogate advantage subject to a hard KL budget δ.
Choosing a constraint rather than a penalty is what gives TRPO its practical stability. A fixed KL budget keeps every update at the same behavioral size regardless of where you are on the loss surface, which is far easier to tune than a penalty weight that means different things at different points.
Solving it without inverting the Fisher matrix
Linearize the surrogate and quadratically approximate the KL constraint (its matrix is the Fisher information matrix) and the optimal direction is exactly the natural gradient. But forming and inverting the Fisher matrix is infeasible for a deep network. TRPO's trick is that it never needs the matrix itself — only its product with a vector, which can be computed cheaply.
Enter conjugate gradient. It solves the linear system that defines the natural-gradient direction using only Fisher-vector products, converging in a handful of iterations without ever materializing the matrix. Each Fisher-vector product is a single extra backprop, so the whole solve costs a small constant number of gradient passes.
Conjugate gradient solves Fx = g for the natural-gradient direction using only Fisher–vector products, then β scales it to the KL-budget edge δ.
The line-search safety net
The conjugate-gradient direction comes from a quadratic approximation of the real KL constraint, so the full step it suggests might overshoot — the true KL could exceed the budget, or the true surrogate could actually drop. TRPO guards against this with a backtracking line search: it tries the full step, and if the true KL is too large or the surrogate did not improve, it halves the step and checks again, until both conditions hold.
Interactive gradient descent rolling down a loss surface, illustrating the backtracking line search that shrinks the step until it is safe.
TRPO end to end
- Run the current policy to collect a batch of trajectories and estimate advantages (GAE).
- Compute the surrogate gradient with importance sampling against the old policy.
- Use conjugate gradient with Fisher-vector products to get the natural-gradient direction.
- Scale that direction to the largest step inside the KL budget.
- Backtrack with the line search until the KL constraint holds and the surrogate improves; apply it.