Preliminary

  1. Long-term discounted reward

    \[J(\pi) = \mathbb{E}_{s_0 \sim \rho,\ a_t \sim \pi(\cdot\vert s_t)}\left[ \sum_{t=0}^{T-1} \gamma^t\, r(s_t, a_t) \right].\]
    • \(s_0 ∼ \rho\): episode start state \(s_0\) starts randomly from the initial state distribution \(\rho\)
    • \(a_t ∼ \pi(\cdot \vert s_t)\): at each time step t, the policy \(\pi\) stochastically samples an action \(a_t\) from the current state \(s_t\)
    • The smaller \(\gamma\) is: the more importance is placed on “immediate reward”
    • The closer \(\gamma\) is to 1: the more importance is placed on “long-term reward including the future”
  2. Policy gradient

    \[\nabla_\theta J(\pi_\theta) = \mathbb{E}_{s \sim \rho^d,\ a \sim \pi(\cdot\vert s)} \left[ \nabla_\theta \log(\pi_\theta(a))\, \hat{A}^{\pi_\theta}(s,a) \right].\]
    • If the advantage function is positive, increase the \(\log \pi_\theta(a \vert s)\) that led to that action; if negative, decrease it
    • Here the policy is a probability distribution \pi_\theta(a | s), and when the goal of wanting to raise the probability of good actions is mathematically differentiated, it organizes more cleanly into the form \(\nabla_\theta \log \pi_\theta(a \vert s)\), the derivative of the log-probability.
    • \(\rho^d\): the state distribution created by the policy, i.e., the states the policy comes to visit
  3. Advantage \(\hat{A}^{\pi_\theta}\)
    • “The degree to which a specific transition contributes to the gradient.”
    • Commonly, letting V be the average expected value at state s, and Q be the value of taking action a at state s, it is expressed as follows:

      \[\hat{A}(s,a) = \hat{Q}(s,a) - \hat{V}(s)\]
    • That is, the difference is a measure of “how much better it was compared to the average”
  4. PPO

    \[L_{\mathrm{on}}(\pi_\theta) = \mathbb{E}_{\pi_{\mathrm{old}}}\left[\min\left(r_t(\pi_\theta),\ \mathrm{clip}(r_t(\pi_\theta), 1-\epsilon, 1+\epsilon)\right) A_t^{\pi_{\mathrm{old}}}\right]\]
    • \(\mathbb{E}_{\pi_{old}} \lbrack \cdot \rbrack\): data comes from the old policy. The expectation is under the old policy. That is, the data \((s_t, a_t)\) was collected with the old policy. In actual training, the flow is: fix the policy for one batch and collect data → update multiple times with that batch → replace the policy → collect again.
    • Importance sampling ratio

      \[r_t(\pi_\theta) = \frac{\pi_\theta(a_t \mid s_t)}{\pi_{\text{old}}(a_t \mid s_t)}\]
      • For the same sample \((s_t, a_t)\), this is the probability that the new policy produces that action divided by the probability that the old policy produces that action.
    • \(\text{clip}(r_t, 1 - \epsilon, 1 + \epsilon)\): to limit the update magnitude, clip the range of r
    • \(\min( \cdot , \cdot )\): if advantage < 0, it tries to lower the probability by making \(r_t\) < 1. Here the min structure selects the safer side so that updates toward large changes that could worsen performance don’t become excessive.

    That is, starting from a simple policy gradient, a surrogate objective is constructed, and instead of directly setting the \(\theta\) update direction, \(\theta\) is updated in the direction that maximizes \(L_{on}\)

    ❓

    The effect of \(\min( \cdot , \cdot )\)

    For example, when \(A_t > 0\), since \(\min(r_t A_t , \text{clip}(...) A_t)\), if \(r_t > 1 + \epsilon\) then \(r_t A_t\) is selected.

    Conversely, when \(A_t \leq 0\), since \(\min(r_t A_t , \text{clip}(...) A_t)\), if \(r_t < 1 - \epsilon\) then \(\text{clip}(...) A_t\) is selected.

    That is, for bad actions, it prevents updates that try to lower the probability too much.

  5. Actor-Critic: “Critic” update

    The Critic learns the value function:

    That is, it predicts the average of the discounted cumulative reward to be received going forward when entering state s. A value update is supervised learning that fits the predicted value \(V_{\psi}(s)\) to the target. The simplest form, the 1-step TD target, is:

    \[y_t = r_t + \gamma V_{\psi_{\mathrm{old}}}(s_{t+1})\]

    It takes this form. Here \(V_{\psi_{old}}\) is the critic just before the update, treated as a constant. The reason the target can be set based on the critic’s own prediction like this is due to the Bellman assumption.

    • Bellman expectation equation

      The true \(V^{\pi}\) satisfies the following:

      \[V^{\pi}(s) = \mathbb{E}_{a\sim\pi,\, s'\sim P}\left[r(s,a) + \gamma V^{\pi}(s')\right]\]

      Value of the current state = one-step reward + value of the next state (expectation)

      ⇒ Self-consistency condition

    Therefore, a sample version that makes the network \(V_{\psi}\) satisfy this relationship takes the same form as the 1-step TD target above.

    And this Value network is updated as follows (MSE):

    \[L_V(\psi) = \mathbb{E}\left[\left(V_\psi(s_t) - y_t\right)^2\right]\]

    And from this critic being trained, the actor uses

    \[\hat{A}_t = \left( y_t - V_\psi(s_t) \right)\]

    as the advantage, instead of the high-variance return \(G_t\).

Summary \[\begin{aligned} &\text{What we can observe:} \\ &\qquad (s_t, a_t, r_t, s_{t+1}, \mathrm{done}) \\ &\text{What the critic predicts:} \\ &\qquad V(s_t),\ V(s_{t+1}) \\ &\text{Bootstrap target (training label):} \\ &\qquad y_t = r_t + \gamma V_{\text{old}}(s_{t+1}) \\ &\text{TD error (``error relative to expectation''):} \\ &\qquad \delta_t = y_t - V(s_t) \\ &\text{GAE advantage (accumulating several } \delta\text{):} \\ &\qquad \hat{A}_t^{\text{GAE}} = \sum_{l \ge 0} (\gamma\lambda)^l \delta_{t+l} \\[4pt] &\text{The actor is updated with } \hat{A}\text{; the critic is regressed onto } y_t. \end{aligned}\]

Problem Setting

Figure

On-policy algorithms like PPO have the problem that their performance saturates in large-scale parallel environments even when there is still room for improvement. This is because when tens of thousands of parallel environments are run with a GPU simulator, the batch becomes enormous, and when sampling actions from a single Gaussian policy, most actions near the mean are repeated, leading to lots of duplicate data.

❓

Policy gradient methods are sensitive to variance

The policy gradient takes the form of an expectation. However, in actual training, since the expectation cannot be computed directly, Monte Carlo estimation is done with \(N\) samples:

\[\hat{g} = \frac{1}{N} \sum_{i=1}^{N} g(\tau_i)\]

Here the random variable \(\hat{g}\) has variance, and being sensitive to variance means that if \(Var[\hat{g}]\) is large, the update direction fluctuates greatly each time, so that

  • convergence becomes slow, or
  • the learning curve oscillates, or
  • in severe cases, a single large update can drop performance.

Now, the basic form of the policy gradient is \(g_t=∇θ\logπ_θ(a_t∣s_t)\hat{A}(s_t,a_t)\), and here the product structure is the main cause of increased variance. Since return→advantage itself depends on future rewards, if the environment is stochastic or episodes are long, then even for the same \(s_t, a_t\), the return varies greatly depending on what happens afterward, and thus the advantage becomes high-variance. That is, it is noisy.

Furthermore, if \(\nabla \log \pi\) happens to sample an action with very low probability and that action produces a large reward, then

  • the gradient magnitude of \(\log \pi\) becomes large,
  • and if \(\hat A\) is also large,

    a single update “spikes.”

Commonly used solutions

To reduce variance, typically:

  • use a baseline (e.g., value function) to center it as an advantage,
  • adjust the bias–variance trade-off with methods like GAE,
  • limit the update magnitude like PPO/TRPO,
  • increase \(N\) with large batches/parallelization to reduce \(\mathrm{Var}[\hat g]\approx \mathrm{Var}[g]/N\)

    things like these appear.

Method

Figure

Actor Update

The problem with on-policy RL is that data collected with another policy cannot be used. Methods like importance sampling are used to solve this, but in practice they aren’t very practical when computation resources are limited. However, in the large batch setting the story is different, because it becomes useful to roll out multiple policies. Accordingly, an off-policy update is performed as follows:

\[\begin{aligned} L_{\mathrm{off}}(\pi_i; \mathcal{X}) = \frac{1}{\vert \mathcal{X}\vert } \sum_{j \in \mathcal{X}} \mathop{\mathbb{E}}_{(s,a) \sim \pi_j} \big[ \min\big( r_{\pi_i}(s,a), \\ \mathrm{clip}\left( r_{\pi_i}(s,a), \mu(1-\epsilon), \mu(1+\epsilon) \right) \big) A^{\pi_i,\mathrm{old}}(s,a) \big] \end{aligned}\]
  • \(r_{\pi_i}(s, a) = \frac{\pi_i (s,a)}{\pi_j (s, a)}\)
  • \(\mu = \frac{\pi_{i,old} (s,a)}{\pi_j (s, a)}\)

Here, if \(i = j\), then j is treated like the version of the current policy i before its parameter update, so \(\pi_j = \pi_{i, old}\).

And this off-policy loss, updated in this way, is combined by weighted sum with the on-policy term to determine the final loss:

\[L(\pi_i) = L_{on}(\pi_i) + \lambda \cdot L_{off}(\pi_i; \mathcal{X})\]

Critic Update

For on-policy and off-policy data respectively, the target is computed as follows:

\[V_{on,\pi_j}^{target}(s_t) = \sum_{k=t}^{t+2} \gamma^{k-t} r_k + \gamma^3 V_{\pi_j,old}(s_{t+3})\] \[V_{off,\pi_j}^{target}(s_t') = r_t + \gamma V_{\pi_j,old}(s_{t+1}')\]

Here, on-policy is computed with a 3-step TD target, and off-policy with a 1-step TD target. Accordingly, the Critic Loss is defined as follows:

\[\begin{aligned} L^{critic}_{on}(\pi_i) &= \mathop{\mathbb{E}}_{(s,a)\sim\pi_i}\left[(V_{\pi_i}(s) - V^{target}_{on,\pi_i}(s))^2\right] \\ L^{critic}_{off}(\pi_i;\mathcal{X}) &= \frac{1}{\vert \mathcal{X}\vert }\sum_{j\in\mathcal{X}}\mathop{\mathbb{E}}_{(s,a)\sim\pi_j}\left[(V_{\pi_i}(s) - V^{target}_{off,\pi_i}(s))^2\right] \\ L^{critic}(\pi_i) &= L^{critic}_{on}(\pi_i) + \lambda \cdot L^{critic}_{off}(\pi_i) \end{aligned}\]

❓

1-step vs n-step

Increasing n-step = including more actual observations when building the value target, and reducing the weight of dependence on predicted values (bootstrap).

The larger n is, from the Critic’s perspective the advantage is reducing the propagation of incorrect bootstrap, and from the actor’s perspective it prevents the critic from becoming inaccurate, so the advantage can fluctuate less.

However, in off-policy an n-step target cannot be used.

This is because off-policy samples are trajectories created not by \(\pi_i\) but by a different policy \(\pi_j\), so

  • the actions taken at t+1, t+2, … are, from the perspective of the policy to be updated (\(\pi_i\)), ‘actions of another policy’

    ⇒ to interpret them as “the n-step result under the policy in question,” in principle this would require importance correction across multiple steps (a product of ratios), which tends to make variance explode.

Leader-follower Aggregation

Figure

As a result of experimenting with two forms (symmetric aggregation and leader-follower aggregation), the authors found that the leader-follower form of asymmetric aggregation was more effective. The reason is that in the symmetric form, all policies end up training on the same data, so the behaviors of the policies converge. ⇒ decreased data diversity

Accordingly, they use the leader-follower aggregation form.

  • Leader Policy: updated by receiving data from all other policies
  • Follower Policy: updated only with its own on-policy data.

⇒ Followers are not pulled toward the same data as each other, so it is easy for each to maintain different exploration/behavior. The leader gathers those experiences and absorbs them into a better policy.

  • Since off-policy data is noisy, subsample the off-policy data so that the number of on-policy and off-policy samples in the leader update minibatch is equal
  • \(\lambda=1\)

Latent Conditioning

Excluding the leader, entropy regularization is applied by giving each follower a different entropy coefficient.

The entropy \(H(\pi(a\mid s))\) of a policy \(\pi(a\mid s)\) represents “how spread out (random) the action distribution is.”

  • High entropy → probability is distributed evenly across many actions (more exploratory)
  • Low entropy → probability concentrates on a few actions (more deterministic/exploitative)

The paper adds an entropy term to the followers’ PPO loss \(L_{\text{on}}\):

\[L(\pi_i) = L_{\mathrm{on}}(\pi_i) + \lambda_{\mathrm{ent}}(i-1)\cdot H(\pi(a\mid s))\]

Followers with a large entropy coefficient do more exploration, while followers with a small entropy coefficient do more exploitation.

⇒ Overall, near-optimal trajectories + exploratory trajectories are mixed, creating broad data coverage.

The Full Algorithm

Figure