Overview
Actor-Critic methods build off even further from our state-dependent baselines used in REINFORCE with baselines method where our action advantage is \(A^\pi (s_{t}^i, a_{t}^i) = G_{t}^{(i)} - V_{\phi}^\pi(s_{t}^i)\)
But the \(G_{t}^{(i)}\) term can still have high variance: it’s a single rollout Monte-Carlo return based on our \(s_{t}\) and \(a_{t}\) and varies for different trials in our environment; but doesn’t this term sound familiar?
Our returns \(G_{t} = \sum_{k=t}^T R(s_{k}, a_{k})\) are exactly estimated by our Q-functions \(Q^\pi(s,a) = \mathbb{E}[G_{t} \mid s_{t}, a_{t}]\) by definition!
Moreover, since our baseline is our value functions \(V_{\phi}^\pi(s)\), then we should expand our bellman equations to express Q-functions in terms of value functions: \(Q^\pi(s,a) = \mathbb{E}[G_{t} \mid s_{t}, a_{t}] = \mathbb{E}[R_{t} + \gamma G_{t+1} \mid s_{t}, a_{t}] = \mathbb{E}[R_{t}+\gamma V(s_{t+1}) \mid s_{t},a_{t}]\). This way we avoid having to update two critic networks - and only need one critic network that estimates \(V_{\phi}^\pi(s)\)!
Then our action advantages can be simplified through TD-bootstrapping as
This critic “critiques” the actor’s choices by providing an baseline evaluation signal - advantage - that guides how the actor should change.
- Initialize actor policy parameters \(\theta\) and critic parameters \(\phi\)
- Sample trajectories \(\{\tau_{i} = \{s_{t}^i , a_{t}^i\}_{i=0}^T \}\) by deploying our current policy \(\pi_{\theta}(a_{t} \mid s_{t})\)
- Compute returns \(G_t^{(i)} = \sum_{k=t}^{T-1}\gamma^{k-t} r(s_k^{(i)},a_k^{(i)})\) for all \(i,t\)
- Fit critic value functions \(V_{\phi}^\pi(s)\) through MC or TD estimation to update the critic \(\phi\)
- Compute action advantage estimates: \(A^\pi (s_{t}^i, a_{t}^i) = G_{t}^{(i)} - V_{\phi}^\pi(s_{t}^i)\) for all \(i,t\)
- \(\nabla_\theta U(\theta)\approx \frac{1}{N}\sum_{i=1}^N\sum_{t=0}^{T-1}\nabla_\theta \log \pi_\theta(a_t^{(i)}\mid s_t^{(i)})\,\hat A_t^{(i)}\)
- \(\theta \leftarrow \theta + \alpha \nabla_{\theta}U(\theta)\)
In some sense the actor-critic is just “policy iteration” written in gradient form.
- We run the policy and collect a series of \(N\) trajectories.
- Based on the performance, we compute advantages for each time step during each trajectory and take note of high advantage \(A^\pi\) actions - where \(Q_{\pi}(s,a)\) value is higher than the state \(V_{\pi}(s)\) value.
- Then we update our policy parameters \(\pi \rightarrow \pi_{new}\) directly using a policy gradient that is computed through these advantages so that the policy makes those high advantage actions more probable.
A2C - Advantage Actor-Critic (Distributed Synchronous)
The trajectories we collect arrive sequentially, and successive on-policy updates can be highly correlated because they come from a single evolving policy interacting with the environment. We have seen how in off-policy methods like DQN, replay buffers help decorrelate data, so for on-policy actor-critic methods, we instead collect experience in parallel.
In A2C, we parallelize experience collection across multiple workers and aggregate their rollouts into a single batch before computing one single global gradient update, and synchronizing the updated policy globally to all workers. Because each workers interacts with the environment differently, then aggregating their updates removes the problem of correlation, while simultaneously reducing data collection time!
So, each worker runs the current policy to generate trajectories and compute gradient contributions from its own rollouts. We then synchronize: the global update is applied only after all workers finish and their gradients are combined, yielding more diverse experience per update and more stable training!
This distributed synchronous, because all workers collect trajectories only after synchronizing a global policy to use.

A3C - Asynchronous Advantage Actor-Critic (Distributed Asynchronous)
The natural performance optimization to make is what if we didn’t require the workers to wait for others to finish rollouts, allowing the workers to update our global policy asynchronously and providing gradient updates without waiting for all workers each iteration.
Summarized in algorithmic form, where
- \(\theta\) is the global actor parameters and \(\theta_{v}\) is the global critic parameters
- \(\theta', \theta'_{v}\) are the thread (worker) specific parameters that may not be in sync with other threads to asynchronous updates

Entropy Regularization
In the A3C paper, entropy regularization is an extra term added to the actor’s objective that rewards stochasticity in the policy. In actor–critic it’s used to prevent the actor from collapsing too early to a near-deterministic (often suboptimal) policy and to improve exploration.
For a discrete action policy \(\pi_{\theta}(\cdot \mid s)\) we have by definition of entropy that
Recall that higher entropy results in more spread-out action probabilities so we want to force a higher entropy term to update our policy objective by adding a regularized entropy term!
For our gradient updates then:
And substituting we get!
PPO - Proximal Policy Optimization
PPO is derived from policy improvement logic and more so a approximate policy iteration method than a policy gradient method.
High UTD
let us define the frequency of gradient updates we used in Actor-Critic
Obviously it seems to us that a high UTD is efficient with collected data - and a bottleneck in RL for complex environments is exactly data collection - so we want to come up with methods that work well with high UTD. So let’s modify actor-critic to have \(UTD > 1\). But…
Here’s the issue:
if we apply one gradient update step, then we land on a new policy \(\pi'\) parameterized by \(\theta'\). We cannot compute the same policy gradient estimate for \(\nabla_{\theta}U(\theta)\) by reusing the past rollouts (when computing the advantages).
This means that if we forcefully use a high UTD, then we have a noisy estimate based on limited experience and can result in policy drifts. This is a motivator for PPO and TRPO methods as we discuss: What if we constrained our update steps so that the new policy \(\pi'\) is close enough to \(\pi\) and we can reuse the same gradient updates for old set of advantages collected!
Policy Improvement
Performance of Policy
If we quantify the performance of a policy as expected return over all trajectories
and define a discounted state visitation distribution that as the weighted time spent in a specific state \(s\) over all trajectories given a policy \(\pi\)
where
- \(\Pr_{\pi}\) specifically refers to probability over policy (all policy-induced randomness)
- the sum of all pmfs for \(d^\pi(s)\) over all states is \(\sum_{s} d^\pi(s) = \frac{1}{1-\gamma}\), because summing over \(s\) sums the inner probability to \(1\) for each time step
The state visitation distribution is important because we can rewrite a discounted sum over time of some some state-dependent function \(f(s)\) as an expectation over the states from the state visitation distribution.
This is a nice identity we can use to reparameterize the trajectory distribution for our performance difference lemma.
Performance Difference Lemma
Then we can show that the policy improvement from \(\pi \rightarrow \pi'\) can be written as expected advantage over state visitation distribution and action sampling from our policy.
Intuitively this is true because the advantage \(A^\pi(s,a) = Q^\pi(s,a) - V^\pi(s)\) is a single-step improvement signal:
It measures the difference
- take \(a\) - sampled from \(\pi'\) - at \(s\) then follow \(\pi\)
- follow \(\pi\) immediately from \(s\) And we are averaging this over the entire joint \((s,a)\) distribution of our new policy \(\pi'\)
Proof
Let’s start from the definition of advantage expanded using Bellman
If we compute expectation of advantage over all trajectories, we need to expand the expression and reproduce an expression for the global policy difference we are seeking.
To start, for a fixed state \(s\), our advantage expectation over our action distribution from \(\pi'\) is
If we consider this same advantage expectation over \((s_{t}, a_{t})\) generated by \(\pi'\) from \(s_{0} \sim \rho\), then summing this over entire trajectory, we eventually can isolate the performance of both \(\pi\) and \(\pi'\) as performance difference as wanted!
Policy Improvement Formulation
We aim to find a new policy \(\pi'\) maximizing our policy improvement:
The whole motivation behind PPO is about making safe, stable policy updates while aiming using data collected from our older policy \(\pi\). But the issue is our performance difference directly samples directly from \(\pi'\). Can we avoid this?
Importance Sampling
If we can’t sample from \(\pi'\) of a distribution \(p(z)\), but want to compute an expectation of a function \(f(z)\) under that distribution, then a technique called importance sampling allows us to sample from a different easier proposal/behavior distribution \(q(z)\) then scale using a term called important weight on our function values! :
which works as long as the denominator \(q(z) > 0\) whenever \(p(z) > 0\)

And as always we can compute an unbiased estimator for the expectation using Monte Carlo Estimation
Policy Improvement Reformulation
Then to apply this trick to our formulation, we aim to express our expectation entirely in terms of \(\pi\), our first attempt in re-expressing our state visitation distribution in terms of \(\pi\) would be
but calculating state-visitation ratio \(\frac{d^{\pi'}(s)}{d^\pi(s)}\) is hard in itself - because the discounted visitation distribution for \(\pi'\) is unknown - and if we try to estimate this ratio we need a large amount of sampling, and because this is a high variance term that could explode in certain states, this would lead to instability in the computation.
PPO fixes this by simply keeping \(\pi\) close to \(\pi'\) so that the state-visitation distribution naturally induces an approximate equality of \(d^{\pi'}\approx d^\pi\). And we still apply the importance sampling trick for \(\pi'(\cdot\mid s_{t})\) which note the ratio \(\frac{\pi'(\cdot\mid s_{t})}{\pi(\cdot\mid s_{t})}\) is easy to deal with - this is just directly from our policy network!
Constrained Maximization Updates
We need to take gradient ascent steps to find the best \(\pi'\), but wait…
We want to reuse the same policy \(\pi\) advantages for multiple policy gradient updates to our parameters \(\theta'\), not just one. But if we blindly follow this gradient, what if we make too big of policy updates to \(\pi'\)? Then actions that were likely under \(\pi\) may not be likely anymore and
- the advantages we computed are stale for later updates and
- our assumption \(d^{\pi'} \not \approx d^\pi\) may not hold.
PPO aims to enforce some closeness penalty constraints on how far the new policy \(\pi'\) can drift from \(\pi\) on each gradient update! This way we can have high UTD. This can done through adding a regularization term to our objective.
Clipped Ratio Objectives for Constrained Step Size
But what PPO actually does is use a soft approximation by utilizing ratio clipping keeping \(\frac{\pi'(a\mid s)}{\pi(a \mid s)}\) close to 1 instead of using an explicit distance metric (KL Divergence) as in TRPO. Remember the whole purpose is to make sure the old batch of trajectories representative of the new policy so we can get high UTD.
This clipped objective can be summarized as
A lot is going on here. The intuition is to clip the importance weight \(\frac{\pi'(a\mid s)}{\pi(a \mid s)} \in [1-\epsilon, 1+ \epsilon]\)
Clip directly prevents any gradient updates from occurring outside the intended range \([a,b]\).
But just including a naive clip objectives clips our has the issue of clipping too much, even in useful situations
- if our advantage \(A(s_{t},a_{t}) > 0\), even if our ratio \(r < 1 - \epsilon\), \(a_{t}\) is still better than our current baseline in \(\pi\) and the right update is increase its probability but because the clipped ratio becomes level when \(<1-\epsilon\) , then the gradient zeros out, and we don’t get to use this \((s,a)\) experience for gradient update even though a positive advantage is clearly beneficial for forcing \(\pi'(a \mid s)\) to be higher probability.
- If our advantage \(A(s_{t},a_{t}) < 0\), even if our ratio \(r > 1 + \epsilon\) , \(a_{t}\) is still worse than our current baseline and the right update is to decrease its probability but the naive clipped objective zeros out the gradient once again, and we miss utilizing this \((s,a)\) experience for gradient update, even though a negative advantage is clearly necessary to force \(\pi'(a\mid s)\) smaller.
So our entire clipped objective adds an additional \(\min\) term so that we only clip the ratio only in situations we actually have the issue of over-improving our policy! Now positive advantages with ratio \(r < 1 -\epsilon\) can still be made more probable and negative advantages with ratio \(r > 1+\epsilon\) can still be made less probable.
In summary, this full clipped objective visualized:

- If our advantage is positive, then we keep gradient updates up to \(1+\epsilon\)
- If our advantage is negative, then we keep gradient updates after \(1- \epsilon\)
Asymmetric clipping
In reality we need to emphasize good actions when exploring for language models, meaning our clip term should be something like
This means that we want to make \(\epsilon_{+} < \epsilon_{-}\) so that we don’t clip for higher positive advantages that we would clip if we kept \(\epsilon_{-}\) fixed and had \(\epsilon_{+} = \epsilon_{-}\)!
GAE - Generalized Advantage Estimation
While we have seen \(n\)-step bootstrapping for computing advantage estimates \(A_{t}^n = r_{t} + \gamma r_{t+1} + \gamma^2r_{t+2} + \dots + \gamma^n V(s_{t+n}) - V(s_{t})\), the tradeoff is while this estimator is less biased, it is higher variance than our high bias, low variance simple TD-estimate \(A_{t}^1 = r_{t} + \gamma V(s_{t+1} )-V(s)\).
Instead of trying to determine the best \(n\)-step TD target to use, GAE computes exponentially weighted sum of all such \(n\)-step targets, but this can also be simplified to a form - weighted sum of 1-step future TD errors starting at \(t\) - that is easier to compute
The parameter \(\lambda \in [0,1]\) allows us to balance bias-variance in our advantage estimates, with a smaller \(\lambda\) having higher bias and lower variance, but a larger \(\lambda\) having lower bias and higher variance.
- \(\lambda = 0\), then only the \(l=0\) term is kept in the summation leaving us with 1-step TD of \(\hat{A}_{t} = \delta_{t}\)
- \(\lambda \rightarrow 1\), then we care about future TD errors fully reaching something similar to Monte-Carlo
By easier to compute we mean this has a way to conveniently recursively compute each timestep
Then we can compute any \(\hat{A}_{t}\) by iteratively computing backwards from \(t=T-1\) to \(t=0\).
Performance

TRPO - Trust-Region Policy Optimization
If we were to keep the KL-constraint in our objective instead of a soft ratio-clipping objective with PPO, then the formulation is different. This is called TRPO.
Our surrogate objective is now
In optimization problems in general, a trust region is a rule for making small optimization steps to update parameters within a neighborhood where our local approximation is “trusted” to predict improvement.
With KL we have defined our neighborhood in terms of policy space measured through KL divergence.
Natural Policy Gradient
We can convert this constrain into a penalty, just adding the KL term, so we can just perform unconstrained approximation. We can then approximate this objective by
- estimating the policy objective with a first order Taylor expansion and
- estimating the KL term with a second order Taylor expansion
Let’s derive the Taylor approximation for the KL term:
For the first order KL term:
For the second order KL Term, we solve in which the inner term is called the fisher information matrix: the Hessian of the KL divergence at the point where the two distributions match.
We essentially want to find the optimal \(\mathbf{d}\) for our objective which can be done through finding local minimnum
How shall we choose the step size along the natural gradient direction? From the 2nd order Taylor expansion of the KL term, given that we require our KL between new and old policies to be at most \(\epsilon\), then we can directly solve for \(\alpha\)

Line Search For TRPO
Because the quadratic KL approximation is in the end just an approximation that is done with neural nets, the actual KL may not actually be \(\leq \epsilon\) like we want it. Instead we try something that just tests different step sizes \(\alpha^{j+1} = c\,\alpha^j\) with a shrink factor \(c \in (0,1)\) to gauge a KL constraint that works and a positive surrogate improvement.
