Trust Region Policy Optimization: Mathematical Foundations, Monotonic Improvement Guarantees, and Conjugate Gradient Updates
In policy gradient reinforcement learning, optimization dynamics differ fundamentally from standard supervised learning. In supervised regression or classification, the underlying data distribution remains stationary throughout training; a sub-optimal parameter update merely yields high loss on the current batch without corrupting future sample collection. In reinforcement learning, however, the parameter vector of a policy defines both the action distribution and the state visitation distribution . A single excessive gradient step can push the policy into an unrecoverable region of parameter space, degrading performance and generating trajectories from which meaningful reward signals cannot be collected.
To resolve this instability, Schulman et al. (2015) introduced Trust Region Policy Optimization (TRPO). Building upon the theoretical foundations of Conservative Policy Iteration by Kakade and Langford (2002), TRPO proves that enforcing a statistical constraint on policy divergence guarantees monotonic policy improvement. By optimizing a local surrogate objective subject to an average Kullback-Leibler (KL) divergence constraint, and solving the resulting quadratic subproblem via the conjugate gradient method and automatic differentiation vector products, TRPO established the modern paradigm of constrained policy optimization.
The Policy Gradient Step-Size Dilemma
Standard policy gradient methods, derived from the Policy Gradient Theorem (Sutton et al., 1999), optimize the expected cumulative discounted return:
The analytical gradient of with respect to parameter vector is given by:
In empirical implementations, parameters are updated via first-order gradient ascent:
This first-order formulation suffers from three severe mathematical and practical limitations:
- Euclidean Geometry vs. Probability Manifolds: First-order gradient ascent measures step size in parameter space Euclidean distance . However, neural network parameterizations are highly non-linear; an identical Euclidean step can cause a negligible change in policy distributions in flat regions of the parameter landscape, yet cause catastrophic shifts in steep regions.
- State Distribution Shift: Evaluating the gradient under trajectories sampled from assumes that the current state visitation distribution remains valid for the updated policy . If the step size is too large, the state visitation distribution shifts abruptly, invalidating prior value estimates.
- Irreversible Performance Collapse: In supervised learning, bad updates can be corrected by subsequent mini-batches. In reinforcement learning, a policy that degrades produces degenerate trajectories (such as getting stuck in dead-end states), eliminating exploratory actions and preventing the policy from recovering.
Kakade and Langford's Relative Performance Identity
To formalize how an updated policy performs relative to an existing policy , Kakade and Langford (2002) derived the exact relative performance identity:
where is the advantage function under policy , and is the unnormalized discounted state visitation frequency.
This identity reveals that if for all states , then , guaranteeing policy improvement. However, computing the expectation over is intractable in practice because sampling trajectories from the un-evaluated candidate policy prior to optimization is impossible.
The Local Surrogate Objective
To make optimization tractable, Schulman et al. replace the unknown state distribution with the known state distribution , defining the local surrogate objective :
For parameterized policies , matches the true objective to first order at :
Consequently, a sufficiently small step that improves is guaranteed to improve .
The Monotonic Improvement Bound
To establish how large a step can be taken before the approximation error between and overwhelms the improvement, Schulman et al. established the formal bound:
where:
- $D_{\text{KL}}^{\max}(\pi, \tilde{\pi}) = \max_s D_{\text{KL}}(\pi(\cdot|s) \parallel \tilde{\pi}(\cdot|s))$
This inequality serves as a Minorize-Maximization (MM) algorithm: by iteratively maximizing the right-hand side lower bound, the true objective is guaranteed to improve monotonically at every step:
where .
From Theoretical Penalties to Practical Trust Regions
While the theoretical bound guarantees monotonic improvement, the constant is extremely large in practical reinforcement learning tasks (where discount factor , making ). An unconstrained optimization of forces step sizes to be vanishingly small, stalling training progress.
Furthermore, evaluating the maximum KL divergence across the entire state space is computationally impossible in continuous or high-dimensional environments.
TRPO makes two critical transitions to turn this theoretical framework into a practical algorithm:
- Average KL Divergence: Replace the maximum KL divergence with the expected KL divergence under the state visitation distribution :
- Hard Trust Region Constraint: Instead of a penalty formulation with fixed coefficient , cast optimization as a constrained maximization problem with a bounded trust region step size :
Using importance sampling, the surrogate objective is rewritten in sample form:

Quadratic Approximation and the Natural Policy Gradient
To solve the constrained optimization problem numerically, TRPO applies a second-order Taylor series expansion around :
- Linear approximation of the objective:
where $g = \left. \nabla_\theta L_{\theta_{\text{old}}}(\theta) \right|_{\theta = \theta_{\text{old}}} = \mathbb{E} \left[ \nabla_\theta \log \pi_\theta(a|s) A(s, a) \right]$.
- Quadratic approximation of the KL divergence constraint:
where is the Fisher Information Matrix (FIM), defined as the Hessian of the average KL divergence evaluated at :
Setting , the optimization problem reduces to:
Analytical Solution via Lagrange Multipliers
Forming the Lagrangian:
Taking the gradient with respect to and setting it to zero:
Substituting into the boundary constraint :
This yields the closed-form TRPO search direction:
The term is the Natural Policy Gradient (Amari, 1998; Kakade, 2001). TRPO automatically scales the natural gradient vector by so that the resulting step precisely exhausts the trust region budget .
Large-Scale Computation: Pearlmutter Vector Products and Conjugate Gradients
For modern deep neural networks containing millions of parameters (), forming the full Fisher Information Matrix would require terabytes of memory, and inverting it ( operations) is computationally prohibitive.
TRPO solves for without ever materializing , utilizing two mathematical techniques:
1. The Pearlmutter Fisher-Vector Product (FVP)
Using the technique formalized by Pearlmutter (1994), the matrix-vector product for an arbitrary vector can be computed using two backward automatic differentiation passes:
In PyTorch notation, this is implemented cleanly:
import torch
def compute_fisher_vector_product(kl_div, policy_params, v, damping=1e-2):
# First backward pass: compute gradient of KL divergence
kl_grad = torch.autograd.grad(kl_div, policy_params, create_graph=True)
kl_grad_flat = torch.cat([g.contiguous().view(-1) for g in kl_grad])
# Inner product with arbitrary vector v
grad_v_prod = torch.sum(kl_grad_flat * v)
# Second backward pass: compute Hessian-vector product
hvp = torch.autograd.grad(grad_v_prod, policy_params, retain_graph=True)
hvp_flat = torch.cat([g.contiguous().view(-1) for g in hvp])
# Add numerical damping for positive-definiteness: (H + damping * I) v
return hvp_flat + damping * v2. The Conjugate Gradient Algorithm
Because is symmetric and positive semi-definite, the linear system can be solved iteratively using the Conjugate Gradient (CG) algorithm. CG finds the exact solution on a Krylov subspace in at most steps, but in practice, to iterations yield an accurate approximation:
def conjugate_gradient(fvp_fn, b, n_steps=10, residual_tol=1e-10):
x = torch.zeros_like(b)
r = b.clone()
p = b.clone()
rdotr = torch.dot(r, r)
for _ in range(n_steps):
Ap = fvp_fn(p)
alpha = rdotr / (torch.dot(p, Ap) + 1e-8)
x += alpha * p
r -= alpha * Ap
new_rdotr = torch.dot(r, r)
if new_rdotr < residual_tol:
break
beta = new_rdotr / rdotr
p = r + beta * p
rdotr = new_rdotr
return xBacktracking Line Search
Because the analytical update relies on linear and quadratic Taylor approximations, higher-order terms can cause the update to violate the non-linear trust region constraint or fail to improve the surrogate objective .
To ensure monotonic improvement and strict constraint satisfaction, TRPO performs a backtracking line search along the direction :
for , with decay factor (typically ). The algorithm accepts the first that satisfies both criteria:
- Surrogate Improvement:
- Trust Region Compliance:
If no step in the search satisfies both conditions after iterations (typically ), the update is rejected, and the parameters remain , guaranteeing that catastrophic updates are never committed.
TRPO vs. PPO: Algorithmic Comparison
In 2017, Schulman et al. (2017) published Proximal Policy Optimization (PPO), introducing a first-order clipped surrogate objective that bypassed conjugate gradient computation:
| Feature | TRPO (Trust Region Policy Optimization) | PPO (Proximal Policy Optimization) | | :--- | :--- | :--- | | Optimization Order | Second-order (Natural Policy Gradient via CG) | First-order (SGD / Adam) | | Constraint Mechanism | Hard statistical constraint: | Clipped probability ratio: | | Computation per Step | High (10 to 15 Fisher-vector passes + Line Search) | Low (Standard backpropagation) | | Network Architecture Flexibility | Restricted (sharing weights between Actor and Critic is difficult) | High (Supports shared actor-critic trunk and RNNs) | | Implementation Complexity | High (Custom autograd graphs and CG solver) | Low (Few lines of loss code in standard frameworks) | | Sample Efficiency | Higher on dense continuous control benchmarks | Slightly lower per batch, but faster wall-clock throughput | | Role in LLM Post-Training | Rarely used due to distributed multi-GPU CG overhead | Industry standard for RLHF and reasoning alignment |
Architectural Impact on Modern AI
While PPO became the standard algorithm for large-scale post-training and Reinforcement Learning from Human Feedback (RLHF) due to its compatibility with distributed Adam optimizers and tensor parallelism, TRPO established the foundational theoretical architecture for modern policy optimization:
- Information Geometry as First Principle: TRPO proved that measuring distance between policies via probability distributions (KL divergence) rather than parameter vectors (Euclidean distance) is essential for stable learning.
- Surrogate Importance Objectives: The probability ratio combined with advantage estimates forms the backbone of all modern alignment frameworks, including PPO, GRPO, and DPO.
- Monotonic Lower Bounds: The Minorize-Maximization perspective demonstrated that optimizing guaranteed lower bounds prevents policy collapse in complex multi-step reasoning and control environments.
Sources
- Schulman, J., Levine, S., Abbeel, P., Jordan, M., & Moritz, P. (2015). Trust Region Policy Optimization. ICML 2015. arXiv:1502.05477
- Kakade, S. M., & Langford, J. (2002). Approximately Optimal Approximate Reinforcement Learning. ICML 2002. arXiv:cs/0205018
- Kakade, S. M. (2001). A Natural Policy Gradient. NeurIPS 2001.
- Amari, S. I. (1998). Natural Gradient Works Efficiently in Learning. Neural Computation, 10(2), 251-276.
- Pearlmutter, B. A. (1994). Fast Exact Multiplication by the Hessian. Neural Computation, 6(1), 147-160.
- Schulman, J., Wolski, F., Dhariwal, P., Radford, A., & Klimov, O. (2017). Proximal Policy Optimization Algorithms. arXiv:1707.06347



