5.2.10 · D5Deep & Advanced RL

Question bank — Trust Region Policy Optimization (TRPO)

2,348 words11 min readBack to topic

Prerequisite ideas being tested: Policy Gradient Methods, Natural Gradient Descent, Fisher Information Matrix, KL Divergence, Importance Sampling, Advantage Estimation (GAE), Conjugate Gradient Method, and the sibling method Proximal Policy Optimization (PPO).


Notation used in this bank

Before the traps, here is every symbol these questions lean on, in plain words. Nothing below uses a letter not defined here.

Recall Why the quadratic KL ball yields a

unique maximizer (proof sketch) Setup. Locally, the objective is linear, , and the constraint region is the ellipsoid . Because is positive-definite, this region is a convex, bounded set (an ellipsoid), and a nonzero linear function attains its maximum on a bounded convex set at exactly one boundary point — the point where the gradient is normal to the ellipsoid surface. The figure below draws this ellipsoid and the resulting step. Derivation. Form the Lagrangian ; the multiplier is the price paid per unit of KL budget. Setting the gradient in to zero: . Substituting into the active constraint solves for and gives the closed form . Since is invertible this point is unique — that is the "WHY" behind the trust-region formulation.

The picture below makes the geometry concrete: the black ellipse is the KL trust region , whose shape is set by the curvature (wide where the policy barely changes, narrow where it changes fast). The black arrow is the ordinary gradient ; the red arrow is the actual TRPO step scaled to the boundary. Notice the red arrow bends away from toward the low-curvature (wide) direction — that bend is exactly what the Fisher matrix buys you, and it is why "limit the parameters" (a circle) would be the wrong constraint.

Figure — Trust Region Policy Optimization (TRPO)
Recall Why

is never formed: the Fisher-vector-product trick is (params × params) — for a deep net that is billions of entries. But Conjugate Gradient Method only ever needs the product for chosen vectors , never itself. The trick: the mean KL (defined above) has gradient (a vector); its directional derivative along is . So = one autodiff of a dot product — a second backward pass. We get every product we need without ever storing the matrix.


True or false — justify

The trust region limits how far the parameters can move.
False. It limits the change in the policy distribution measured by KL; the same parameter step can barely move a flat policy yet drastically move a sharp one.
TRPO directly maximizes the true return .
False. It maximizes the surrogate , which freezes the state-visitation distribution at ; this only approximates near , which is why the KL constraint is needed.
A smaller always gives faster learning.
False. Small makes each step safer but tinier, so learning is slower; larger is faster but risks stepping where the surrogate is no longer trustworthy.
TRPO guarantees the true return can never decrease.
False in practice. The theoretical penalty version guarantees monotonic improvement, but TRPO swaps that penalty for a hard plus a line search — so it guarantees improvement only up to those approximations.
The Fisher Information Matrix is the Hessian of the surrogate objective.
False. is the Hessian of the mean KL divergence (its second-order approximation), not of ; it describes distribution-space curvature, not objective curvature.
The importance ratio can be dropped since we sample from anyway.
False. That ratio is exactly what re-weights old samples so the expectation matches what the new policy would collect; without it we would optimize the old policy against itself.
TRPO requires computing and inverting each update.
False. It only needs Fisher-vector products , and solves (with the surrogate gradient) via Conjugate Gradient Method; is never explicitly formed or inverted.
If the surrogate improves, TRPO always accepts the step.
False. The line search also requires the true KL to stay ; a step passing surrogate improvement but violating true KL is rejected and shrunk.
The natural gradient points in the same direction as the ordinary gradient .
Usually false. They coincide only when is proportional to identity; otherwise rotates and rescales to respect distribution-space geometry.
(mean KL) and give identical constraints.
False. The theory uses the harder max KL; TRPO uses the mean KL because it is estimable from samples, trading a little rigor for practicality.

Spot the error

"Because is a distance, it's symmetric in and ."
Wrong — KL is not symmetric; in general, so it is a divergence, not a metric. (Its second-order approximation via is locally symmetric, which is why the quadratic model works.)
"The surrogate equals everywhere, we just approximate it for speed."
Wrong — matches only to first order at ; it diverges from as moves away because it uses the frozen instead of .
"We use as the actual step-size penalty in TRPO."
Wrong — is the theoretical guaranteed-improvement coefficient (with the max advantage magnitude) and is far too large (steps become minuscule); TRPO replaces the penalty with a tunable hard constraint .
"The advantage is computed under the new policy ."
Wrong — it is the old policy's advantage ; that is what we can estimate from collected data via Advantage Estimation (GAE).
"Setting the Lagrangian derivative to zero gives ."
Wrong sign/scale — with the Lagrange multiplier it gives ; plugging into the KL constraint then fixes the scalar to .
"Because is linear, the objective has no maximum, so the constraint is irrelevant."
Wrong — the linear objective is precisely why the constraint matters: it would run to infinity unbounded, so the quadratic KL ball is what makes the maximizer finite and unique.
"We freeze the state distribution because doesn't exist yet."
Half-wrong — is perfectly well-defined; the real reason is we cannot sample it without already running , so we substitute , valid only when .

Why questions

Why does an importance ratio appear at all in the surrogate?
Because samples came from but we want the expectation under ; Importance Sampling re-weights each old sample by to correct the mismatch.
Why is the KL Hessian (not the identity) the right geometry for the step ?
Because equal parameter moves cause unequal distribution moves; measures how sensitive the policy distribution is to each parameter direction, converting a distribution budget into the correct parameter step.
Why must the constraint be quadratic in KL rather than linear?
Because at the KL and its gradient are both zero (a policy is closest to itself), so the first non-trivial term is the second-order one — the Fisher quadratic form.
Why does TRPO need a backtracking line search on top of the closed-form step?
Because (linear) and (quadratic) are only local approximations; the exact KL and surrogate may violate their models, so the line search shrinks the step until the true constraints hold.
Why is a bad update far more dangerous in RL than in supervised learning?
In supervised learning the dataset is fixed, so a bad step just raises loss next batch; in RL the policy generates its own data, so a bad policy collects bad data, compounding the error and possibly preventing recovery.
Why solve with conjugate gradient instead of a direct method?
Because is (params × params) — enormous for deep nets — but Conjugate Gradient Method needs only cheap Fisher-vector products and converges in far fewer iterations than the dimension.
Why does the natural-gradient direction relate TRPO to Natural Gradient Descent?
Because the trust-region solution is the natural gradient (steepest ascent in KL geometry) merely rescaled to touch the boundary; TRPO is natural gradient with a principled, adaptive step length.
Why prefer PPO's clipped ratio over TRPO's exact constraint in practice?
Proximal Policy Optimization (PPO) approximates the trust region with a simple clipped surrogate, avoiding Fisher-vector products and line search — cheaper and simpler per step, at the cost of TRPO's cleaner theoretical guarantee.

Edge cases

What happens to the step when the surrogate gradient ?
The natural gradient , so : no gradient means no improvement direction, and the scale is a that resolves to a null step — the policy is (locally) stationary.
What happens as the discount ?
Only the immediate reward matters, so the visitation distribution concentrates on the start states and the horizon shrinks; the frozen- approximation becomes nearly exact and the penalty — the surrogate is trustworthy over larger steps.
What happens as the discount ?
The penalty coefficient blows up, forcing arbitrarily tiny theoretical steps; the visitation distribution also has heavier long-horizon weight, making the frozen- approximation harder to trust.
What if assigns near-zero probability where did not?
The importance ratio stays finite, but the KL explodes (division-by-near-zero inside the log), so the trust region immediately rejects such a move — exactly the safety we want.
What if the advantage estimate is uniformly zero for all actions?
The surrogate gradient , so no update is taken; with nothing distinguishing actions there is no direction in which return provably increases.
What happens if you set extremely large (effectively no constraint)?
TRPO degenerates toward an unconstrained natural-gradient step whose length is bounded only by the line search; the surrogate approximation breaks and performance can collapse — the same failure vanilla policy gradient risks.
What if is singular or ill-conditioned?
is undefined or numerically unstable; TRPO adds a small damping term () so conjugate gradient stays well-behaved, trading a bit of geometric accuracy for stability.
Recall One-line summary of the traps

TRPO constrains the distribution (KL), optimizes a surrogate (frozen ), moves along the natural gradient (never inverting ), and verifies with a line search — every misconception comes from forgetting one of these four facts.