{'fraction_non_alphanumeric': 0.029540244799100383, 'fraction_numerical': 0.009558410103369231, 'mean_word_length': 4.636640663091175, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Generalized Proximal Policy Optimization with Sample Reuse

In real-world decision making tasks, it is critical for data-driven reinforcement learning methods to be both stable and sample efficient. On-policy methods typically generate reliable policy improvement throughout training, while off-policy methods make more efficient use of data through sample reuse. In this work, we combine the theoretically supported stability benefits of on-policy algorithms with the sample efficiency of off-policy algorithms. We develop policy improvement guarantees that are suitable for the off-policy setting, and connect these bounds to the clipping mechanism used in Proximal Policy Optimization. This motivates an off-policy version of the popular algorithm that we call Generalized Proximal Policy Optimization with Sample Reuse. We demonstrate both theoretically and empirically that our algorithm delivers improved performance by effectively balancing the competing goals of stability and sample efficiency.


Introduction
In recent years, model-free deep reinforcement learning has been used to successfully solve complex simulated control tasks [4]. Unfortunately, real-world adoption of these techniques remains limited. High-stakes real-world decision making settings demand methods that deliver stable, reliable performance throughout training. In addition, real-world data collection can be difficult and expensive, so learning must make efficient use of limited data. The combination of these requirements is not an easy task, as stability and sample efficiency often represent competing interests. Existing model-free deep reinforcement learning algorithms often focus on one of these goals, and as a result sacrifice performance with respect to the other.
On-policy reinforcement learning methods such as Proximal Policy Optimization (PPO) [19] deliver stable performance throughout training due to their connection to theoretical policy improvement guarantees. These methods are motivated by a lower bound on the expected performance loss at every update, which can be approximated using samples generated by the current policy. The theoretically supported stability of these methods is very attractive, but the need for on-policy data and the highvariance nature of reinforcement learning often requires significant data to be collected between every update, resulting in high sample complexity and slow learning.

arXiv:2111.00072v1 [cs.LG] 29 Oct 2021
Off-policy algorithms address the issue of high sample complexity by storing samples in a replay buffer, which allows data to be reused to calculate multiple policy updates. The ability to reuse samples improves learning speed, but also causes the distribution of data to shift away from the distribution generated by the current policy. This distribution shift invalidates the standard performance guarantees used in on-policy methods, and can lead to instability in the training process. Popular off-policy algorithms often require various implementation tricks and extensive hyperparameter tuning to control the instability caused by off-policy data.
By combining the attractive features of on-policy and off-policy methods in a principled way, we can balance the competing goals of stability and sample efficiency required in real-world decision making. We consider the popular on-policy algorithm PPO as our starting point due to its theoretically supported stable performance, and develop an off-policy variant with principled sample reuse that we call Generalized Proximal Policy Optimization with Sample Reuse (GePPO). Our algorithm is based on the following main contributions: 1. We extend existing policy improvement guarantees to the off-policy setting, resulting in a lower bound that can be approximated using data from all recent policies. 2. We develop connections between the clipping mechanism used in PPO and the penalty term in our policy improvement lower bound, which motivates a generalized clipping mechanism for off-policy data. 3. We propose an adaptive learning rate method based on the same penalty term that more closely connects theory and practice.
We provide theoretical evidence that our algorithm effectively balances the goals of stability and sample efficiency, and we demonstrate the strong performance of our approach through experiments on high-dimensional continuous control tasks in OpenAI Gym's MuJoCo environments [3,21].

Related work
On-policy policy improvement methods The goal of monotonic policy improvement was first introduced by Kakade and Langford [14] in Conservative Policy Iteration, which maximizes a lower bound on policy improvement that can be constructed using samples from the current policy. This theory of policy improvement has served as a fundamental building block in the design of on-policy deep reinforcement learning methods, including the popular algorithms Trust Region Policy Optimization (TRPO) [17] and Proximal Policy Optimization (PPO) [19]. TRPO achieves approximate policy improvement by enforcing a Kullback-Leibler (KL) divergence trust region, while PPO does so by clipping the probability ratio between current and future policies.
Due to the strong performance of TRPO and PPO, there has been substantial interest in better understanding these methods. Engstrom et al. [5] and Andrychowicz et al. [2] both performed extensive empirical analysis on the various implementation choices in these algorithms, while other research has focused on the clipping mechanism used in PPO. Wang et al. [22] and Wang et al. [23] both proposed modifications to the clipping mechanism based on a KL divergence trust region. To the best of our knowledge, we are the first to directly relate the clipping mechanism in PPO to the total variation distance between policies. Wang et al. [23] also proposed a rollback operation to keep probability ratios close to the clipping range. We accomplish a similar goal by considering an adaptive learning rate.
Sample efficiency with off-policy data A common approach to improving the sample efficiency of model-free reinforcement learning is to reuse samples collected under prior policies. Popular off-policy policy gradient approaches such as Deep Deterministic Policy Gradient (DDPG) [15], Twin Delayed DDPG (TD3) [8], and Soft Actor-Critic (SAC) [11] accomplish this by storing data in a replay buffer and sampling from this buffer to calculate policy updates. Note that these methods are not motivated by policy improvement guarantees, and do not directly control the bias introduced by off-policy data.
Other approaches have combined on-policy and off-policy policy gradients, with the goal of balancing the variance of on-policy methods and the bias of off-policy methods [7,9,10,16,24]. Gu et al. [10] demonstrated that the bias introduced by off-policy data is related to the KL divergence between the current policy and the behavior policy used to generate the data. Fakoor et al. [7] considered a related KL divergence as a penalty term in their objective, while Wang et al. [24] approximately controlled this KL divergence by applying a trust region around a target policy. These methods are related to the penalty term that appears in our generalized policy improvement lower bound, which can be bounded by a penalty that depends on KL divergence.
Finally, there have been heuristic attempts to incorporate off-policy data into PPO [13,20]. However, unlike our approach, these methods do not account for the distribution shift caused by off-policy data that invalidates the theoretical support for PPO.

Preliminaries
Reinforcement learning framework We consider an infinite-horizon, discounted Markov Decision Process (MDP) defined by the tuple (S, A, p, r, ρ 0 , γ), where S is the set of states, A is the set of actions, p : S × A → ∆ S is the transition probability function, r : S × A → R is the reward function, ρ 0 is the initial state distribution, and γ is the discount rate.
We model the agent's decisions as a stationary policy π : S → ∆ A . Our goal is to choose a policy that maximizes the expected total discounted rewards J(π) = Eτ∼π [ ∞ t=0 γ t r(s t , a t )], where τ ∼ π represents a trajectory sampled according to s 0 ∼ ρ 0 , a t ∼ π( · | s t ), and s t+1 ∼ p( · | s t , a t ). A policy π also induces a normalized discounted state visitation distribution d π , where d π (s) = (1 − γ) ∞ t=0 γ t P(s t = s | ρ 0 , π, p). We write the corresponding normalized discounted state-action visitation distribution as d π (s, a) = d π (s)π(a | s), where we make it clear from the context whether d π refers to a distribution over states or state-action pairs.
Policy improvement lower bound The starting point in the design of many popular on-policy algorithms is the following policy improvement lower bound, which was first developed by Kakade and Langford [14] and later refined by Schulman et al. [17] and Achiam et al. [1]: Lemma 1 (Achiam et al. [1]). Consider a current policy π k . For any future policy π, we have where C π,π k = max s∈S Ea∼π(·|s) [A π k (s, a)] and TV(π, π k )(s) represents the total variation distance between the distributions π( · | s) and π k ( · | s).
We refer to the first term of the lower bound in Lemma 1 as the surrogate objective, and the second term as the penalty term. Note that we can guarantee policy improvement at every step of the learning process by choosing the next policy π k+1 to maximize this lower bound. Because the expectations in Lemma 1 depend on the current policy π k , we can approximate this lower bound using samples generated by the current policy.
Proximal Policy Optimization PPO, which has become the default on-policy policy optimization algorithm due to its strong performance and simple implementation, is theoretically motivated by the policy improvement lower bound in Lemma 1. Rather than directly maximizing this lower bound, PPO considers the goal of maximizing the surrogate objective while constraining the next policy to be close to the current policy. In particular, PPO heuristically accomplishes this by considering the following objective at every policy update: where clip(x, l, u) = min(max(x, l), u). As seen in the second term of this objective, PPO constrains the difference between consecutive policies by removing the incentive for the probability ratio π(a|s) /π k (a|s) to leave the clipping range [1 − , 1 + ]. Finally, the outer minimization guarantees that (2) is a lower bound to the surrogate objective in Lemma 1. In practice, (2) is approximated using samples generated by the current policy π k , and the resulting empirical objective is approximately optimized at every policy update using minibatch stochastic gradient ascent.
For a sufficiently small learning rate and sufficiently large number of samples, PPO results in stable policy improvement throughout the learning process. However, it is well-known that high variance is a major issue in reinforcement learning, so often the number of samples must be large in order for the empirical objective to be an accurate estimator of the true objective (2). Because these samples must be collected under the current policy between every policy update, PPO can be very sample intensive.

Generalized policy improvement lower bound
A logical approach to improve the sample efficiency of PPO is to reuse samples from prior policies, as done in off-policy algorithms. Unfortunately, the distribution shift between policies invalidates the policy improvement lower bound in Lemma 1, which provides the theoretical support for PPO's reliable performance. In order to retain the stability benefits of PPO while reusing samples from prior policies, we must incorporate these off-policy samples in a principled way. We accomplish this by developing a generalized policy improvement lower bound that can be approximated using samples from the last M policies, rather than requiring samples be generated only from the current policy π k : Theorem 1 (Generalized Policy Improvement Lower Bound). Consider prior policies π k−i , i = 0, . . . , M −1, where π k represents the current policy. For any choice of distribution ν = [ν 0 · · · ν M −1 ] over the prior M policies and any future policy π, we have where C π,π k and TV(π, π k−i )(s) are defined as in Lemma 1.
Proof. We generalize Lemma 1 to depend on expectations with respect to any reference policy, and we apply this result M times where the reference policy is each of π k−i , i = 0, . . . , M − 1, respectively. Then, the convex combination determined by ν of the resulting M policy improvement lower bounds is also a lower bound. See the Appendix for a full proof.
Because the expectations in Theorem 1 depend on distributions related to the last M policies, this lower bound provides theoretical support for extending PPO to include off-policy samples. Note that Theorem 1 is still a lower bound on the policy improvement between the current policy π k and a future policy π. This is true because the advantage function in the surrogate objective and the constant in the penalty term still depend on the current policy π k . However, the visitation distribution, probability ratio in the surrogate objective, and total variation distance in the penalty term now depend on prior policies. Finally, the standard policy improvement lower bound in Lemma 1 can be recovered from Theorem 1 by setting M = 1.
The penalty term in Theorem 1 suggests that we should control the expected total variation distances between the future policy π and the last M policies. By applying the triangle inequality for total variation distance to each component of the penalty term, we see that The first term on the right-hand side of (4) represents an expected total variation distance between the current policy π k and the future policy π, while each component of the second term represents an expected total variation distance between consecutive prior policies. This demonstrates that we can effectively control the expected performance loss at every policy update by controlling the expected total variation distance between consecutive policies. We see next that the clipping mechanism in PPO approximately accomplishes this task.

Clipping mechanism
Connection to penalty term As discussed previously, the clipping mechanism present in the PPO objective removes the incentive for the probability ratio π(a|s) /π k (a|s) to leave the clipping range [1 − , 1 + ]. Written differently, the clipping mechanism removes the incentive for the magnitude of to exceed . We now see that (5) is closely related to the penalty term of the standard policy improvement lower bound in Lemma 1 as follows: Lemma 2. The expected total variation distance between the current policy π k and the future policy π that appears in Lemma 1 can be rewritten as Proof. See the Appendix.
Therefore, the clipping mechanism in PPO can be viewed as a heuristic that controls the magnitude of a sample-based approximation of the expectation on the right-hand side of Lemma 2. It accomplishes this by removing the incentive for (5) to exceed at all state-action pairs sampled from the state-action visitation distribution d π k . As a result, the clipping mechanism in PPO approximately bounds the expected total variation distance between the current policy π k and the future policy π by /2.
Generalized clipping mechanism for off-policy data We can use this connection between the clipping mechanism and penalty term in PPO to derive a generalized clipping mechanism suitable for the off-policy setting. In particular, the decomposition of the off-policy penalty term from Theorem 1 that appears in (4) suggests that we should control the expected total variation distance at each policy update, which can be rewritten as follows: Lemma 3. The expected total variation distance between the current policy π k and the future policy π in (7) can be rewritten as Proof. Apply the same techniques as in the proof of Lemma 2. See the Appendix for details.
The right-hand side of Lemma 3 provides insight into the appropriate clipping mechanism to be applied in the off-policy setting in order to approximately control the penalty term in the generalized policy improvement lower bound: . Consider a current policy π k and clipping parameter . For a state-action pair generated using a prior policy π k−i , the generalized clipping mechanism is defined as Note that the probability ratio for each state-action pair in the off-policy setting begins in the center of the clipping range for every policy update just as in PPO, where now the center is given by π k (a|s) /π k−i (a|s). Also note that we recover the standard clipping mechanism used in PPO when samples are generated by the current policy π k .
Impact of learning rate on clipping mechanism Due to the heuristic nature of the clipping mechanism, it can only approximately bound the penalty term in the corresponding policy improvement lower bound if the learning rate used for policy updates is sufficiently small. To see why this is true, note that the clipping mechanism has no impact at the beginning of each policy update since each probability ratio begins at the center of the clipping range [5]. If the learning rate is too large, the initial gradient steps of the policy update can result in probability ratios that are far outside the clipping range. In addition, the sensitivity of the probability ratio to gradient updates can change as training progresses, which suggests that the learning rate may need to change over time in order for the clipping mechanism to approximately enforce a total variation distance trust region throughout the course of training.
In order to address these issues, we propose a simple adaptive learning rate method that is directly connected to our goal of controlling a total variation distance penalty term via the clipping mechanism.
Using Lemma 3, we can approximate the expected total variation distance of interest using a samplebased estimate. We reduce the learning rate if the estimated total variation distance exceeds our goal of /2, and we increase the learning rate if the estimated total variation distance is significantly lower than /2. This approach more closely connects the implementation of PPO to the policy improvement lower bound on which the algorithm is based. In addition, the adaptive learning rate prevents large policy updates that can lead to instability, while also increasing the speed of learning when policy updates are too small. We formally describe this method in Algorithm 1.

Algorithm
The surrogate objective from the generalized policy improvement lower bound in Theorem 1, coupled with the generalized clipping mechanism in Definition 1 that controls the penalty term in Theorem 1, motivate the following generalized PPO objective that directly considers the use of off-policy data: Our algorithm, which we call Generalized Proximal Policy Optimization with Sample Reuse (GePPO), approximates this objective using samples collected from each of the last M policies and approximately optimizes it using minibatch stochastic gradient ascent. In addition, we update the learning rate at every iteration using the adaptive method described in the previous section. GePPO, which we detail in Algorithm 1, represents a principled approach to improving the sample efficiency of PPO while retaining its approximate policy improvement guarantees.

Sample efficiency analysis
Generalized clipping parameter In order to compare GePPO to PPO, we first must determine the appropriate choice of clipping parameter GePPO that results in the same worst-case expected performance loss at every update: Lemma 4. Consider PPO with clipping parameter PPO and GePPO with clipping parameter GePPO . If then the worst-case expected performance loss at every update is the same under both algorithms.
Proof. See the Appendix.
Lemma 4 shows that we must make smaller policy updates compared to PPO in terms of total variation distance, which is a result of utilizing samples from prior policies. However, these additional samples stabilize policy updates by increasing the batch size used to approximate the true objective, which allows us to make policy updates more frequently. Ultimately, this trade-off results in faster and more stable learning, as we detail next.
Update policy: Approximately maximize the empirical objective using minibatch stochastic gradient ascent.
Update learning rate: Calculate sample-based estimate TV of expected total variation distance in Lemma 3.
if TV > /2 then η = η · 1 /(1+α) ; end Balancing stability and sample efficiency For concreteness, in this section we restrict our attention to uniform policy weights over the last M policies, i.e., ν i = 1 /M for i = 0, . . . , M − 1. We provide additional details in the Appendix on how these policy weights can be optimized to further improve upon the results shown for the uniform case.
Assume we require N = Bn samples for the empirical objective to be a sufficiently accurate estimate of the true objective, where n is the smallest possible batch size we can collect and B is some positive integer. In this setting, PPO makes one policy update per N samples collected, while GePPO leverages data from prior policies to make B updates per N samples collected as long as M ≥ B. First, we see that GePPO can increase the change in total variation distance of the policy throughout training compared to PPO without sacrificing stability in terms of sample size: Theorem 2. Set M = B and consider uniform policy weights. Then, GePPO increases the change in total variation distance of the policy throughout training by a factor of 2B /(B+1) compared to PPO, while using the same number of samples for each policy update as PPO.
Proof. See the Appendix.
Alternatively, we see that GePPO can increase the sample size used to approximate each policy update compared to PPO, while maintaining the same change in total variation distance throughout training: Theorem 3. Set M = 2B − 1 and consider uniform policy weights. Then, GePPO increases the sample size used for each policy update by a factor of (2B−1) /B compared to PPO, while maintaining the same change in total variation distance of the policy throughout training as PPO.
Proof. See the Appendix.
By combining the results in Theorem 2 and Theorem 3, we see that GePPO with uniform policy weights improves the trade-off between stability and sample efficiency in PPO for any choice of B ≤ M ≤ 2B − 1. Also note that the benefit of GePPO increases with B, where a larger value of B indicates a more complex problem that requires additional samples to estimate the true objective at every policy update. This is precisely the scenario where the trade-off between stability and sample efficiency becomes critical.

Experiments
In addition to the theoretical support for our algorithm in the previous section, we aim to investigate the stability and sample efficiency of GePPO experimentally through simulations on several MuJoCo  environments [21] in OpenAI Gym [3]. In particular, we consider six continuous control locomotion tasks which vary in dimensionality: Swimmer-v3, Hopper-v3, HalfCheetah-v3, Walker2d-v3, Ant-v3, and Humanoid-v3. We compare the performance of our algorithm to PPO, which is the default on-policy policy optimization algorithm. We do not consider a comparison with popular off-policy algorithms since they lack approximate policy improvement guarantees, and as a result the risk associated with each policy update is not comparable.
We consider the default implementation choices used by Henderson et al. [12] for PPO. In particular, we represent the policy π as a multivariate Gaussian distribution, where the mean action for a given state is parameterized by a neural network with two hidden layers of 64 units each and tanh activations. The state-independent standard deviation is parameterized separately. The default value for the clipping parameter is PPO = 0.2, and the default batch size is N = 2,048. Sample trajectories for the tasks we consider can contain up to one thousand steps, so we represent the default batch size as n = 1,024 and B = 2 using the notation from the previous section.
For GePPO, we select M and the corresponding policy weights ν to maximize the effective batch size used for policy updates while maintaining the same change in total variation distance throughout training as PPO. The clipping parameter GePPO is chosen according to Lemma 4, which in our experiments results in GePPO = 0.1. We estimate A π k (s, a) with an off-policy variant of Generalized Advantage Estimation [18] that uses the V-trace value function estimator [6]. We run each experiment for a total of one million steps over five random seeds. See the Appendix for additional implementation details, including the values of all hyperparameters. 1 As shown in Table 1 and Figure 1, GePPO results in fast and reliable learning. We see that GePPO leads to improved final performance across all environments. In addition to final performance, we assess the sample efficiency of our algorithm by considering the average performance over the course of training as well as the number of samples required for GePPO to match the final performance of PPO. Despite the fact that the default implementation of PPO achieves stable learning with a small batch size (B = 2), our results still demonstrate the sample efficiency benefits of GePPO. Compared to PPO, GePPO improves the average performance over training by between 8% and 65%. Moreover, GePPO requires between 15% and 77% fewer samples to reach the final performance level of PPO.
In addition to improving sample efficiency, GePPO also ensures that the total variation distance between consecutive policies remains close to the target determined by the clipping parameter through the use of an adaptive learning rate. This is not the case in PPO, where we observe that the change in total variation distance per policy update increases throughout training. As shown on the left-hand side of Figure 2, the change in total variation distance for PPO under default settings is almost 40% higher than desired after one million steps on Walker2d-v3. We demonstrate that this can lead to instability in the training process by considering a standard wide policy network with two hidden layers of 400 and 300 units, respectively. We see on the right-hand side of Figure 2 that this minor implementation change exacerbates the trend observed in PPO under the default settings, resulting in unstable learning where performance declines over time due to excessively large policy updates. GePPO, on the other hand, successfully controls this source of instability through its adaptive learning rate, resulting in stable policy improvement that is robust to implementation choices.

Conclusion
We have presented a principled approach to incorporating off-policy samples into PPO that is theoretically supported by a novel off-policy policy improvement lower bound. Our algorithm, GePPO, improves the sample efficiency of PPO, and can be viewed as a more reliable approach to sample reuse than standard off-policy algorithms that are not based on approximate policy improvement guarantees. This represents an important step towards developing stable, sample efficient reinforcement learning methods that can be applied in high-stakes real-world decision making.
Despite this progress, there remain limitations that must be addressed in order for reinforcement learning to achieve widespread real-world adoption. Because our algorithm is based on PPO, policy improvement guarantees are only approximately achieved due to the use of the clipping mechanism heuristic. In addition, the constant factor in the penalty term on which our algorithm is based may be too large to deliver practical guarantees. Finally, we considered PPO as our starting point due to its theoretical support and stable performance, but there may exist other approaches that more effectively balance the goals of stability and sample efficiency. These represent interesting avenues for future work in order to develop reinforcement learning methods that can be trusted to improve real-world decision making.

A Proofs
A.1 Proof of Theorem 1 We begin by stating results from Kakade and Langford [14] and Achiam et al. [1] that we will use in our proof. Lemma 5 (Kakade and Langford [14]). Consider a current policy π k . For any future policy π, we have Lemma 6 (Achiam et al. [1]). Consider a reference policy π ref and a future policy π. Then, the total variation distance between the state visitation distributions d πref and d π is bounded by where TV(π, π ref )(s) is defined as in Lemma 1.
Using these results, we first generalize Lemma 1 to depend on expectations with respect to any reference policy: Lemma 7. Consider a current policy π k , and any reference policy π ref . For any future policy π, we have where C π,π k and TV(π, π ref )(s) are defined as in Lemma 1.
Proof. The proof is similar to the proof of Lemma 1 in Achiam et al. [1]. Starting from the equality in Lemma 5, we add and subtract the term By doing so, we have [ A π k (s, a) ] We can bound the second term in (16) using Hölder's inequality: where d π and d πref represent state visitation distributions. From the definition of total variation distance and Lemma 6, we have Also note that E a∼π(·|s) As a result, we have that Finally, assume that the support of π is contained in the support of π ref for all states, which is true for common policy representations used in policy optimization. Then, we can rewrite the first term on the right-hand side of (20) as which results in the lower bound in (14).
We are now ready to prove Theorem 1: Proof of Theorem 1. Consider prior policies π k−i , i = 0, . . . , M − 1. For each prior policy, assume that the support of π is contained in the support of π k−i for all states, which is true for common policy representations used in policy optimization. Then, by Lemma 7 we have for each π k−i , i = 0, . . . , M − 1. Consider policy weights ν = [ν 0 · · · ν M −1 ] over the last M policies, where ν is a distribution. Then, for any choice of distribution ν, the convex combination determined by ν of the M lower bounds given by (22) results in the lower bound

A.2 Proof of Lemma 2
Proof. From the definition of total variation distance, we have that Assume that the support of π is contained in the support of π k for all states, which is true for common policy representations used in policy optimization. Then, by multiplying and dividing by π k (a | s), we see that

A.3 Proof of Lemma 3
Proof. From the definition of total variation distance, we have that For i = 0, . . . , M − 1, assume that the supports of π and π k are contained in the support of π k−i for all states, which is true for common policy representations used in policy optimization. Then, by multiplying and dividing by π k−i (a | s), we see that (27)

A.4 Proof of Lemma 4
Proof. From Lemma 2, PPO approximately bounds the penalty term in the standard policy improvement lower bound in Lemma 1 by Using the triangle inequality for total variation distance, we see that the penalty term in the generalized policy improvement lower bound in Theorem 1 can be bounded by where we have written the future policy π as π k+1 on the right-hand side. Note that policy updates in GePPO approximately bound each expected total variation distance that appears on the right-hand side of (29) by GePPO /2. Therefore, the penalty term in the generalized policy improvement lower bound is approximately bounded by By comparing the bounds in (28) and (30), we see that the worst-case expected performance loss at every update is the same for PPO and GePPO when A.5 Proof of Theorem 2 Proof. For M = B with uniform policy weights, we see by Lemma 4 that PPO makes one policy update per N = Bn samples collected, which results in a policy change of PPO /2 in terms of total variation distance. By leveraging data from prior policies to obtain N samples per update, GePPO makes B policy updates per N samples collected. This results in an overall policy change of in terms of total variation distance for every N samples collected. Therefore, GePPO increases the change in total variation distance of the policy throughout training by a factor of 2B /(B+1) compared to PPO, while using the same number of samples for each policy update.
A.6 Proof of Theorem 3 Proof. Because M = 2B − 1, GePPO uses (2B − 1)n samples to compute each policy update, compared to N = Bn samples used in PPO. Therefore, GePPO increases the sample size used for each policy update by a factor of (2B−1) /B compared to PPO.
For M = 2B − 1 with uniform policy weights, we see by Lemma 4 that As in Theorem 2, PPO makes one policy update per N samples collected, while GePPO makes B policy updates per N samples collected. This results in an overall change in total variation distance of which is the same as in PPO.

B Optimal policy weights
In Section 7, we demonstrated the benefits of our algorithm with uniform policy weights, i.e., ν i = 1 /M for i = 0, . . . , M − 1. Because our generalized policy improvement lower bound holds for any choice of policy weights ν, we can improve upon the results in Theorem 2 and Theorem 3 by optimizing ν.
Non-uniform policy weights introduce an additional source of variance, so in order to account for this we must extend the notion of sample size to effective sample size. The effective sample size represents the number of uniformly-weighted samples that result in the same level of variance. For n samples collected under each of the prior M policies, the effective sample size used in the empirical objective of GePPO with policy weights ν can be written as Note that the effective sample size of GePPO with non-uniform policy weights is always smaller than the true number of samples used to calculate the empirical objective, i.e., ESS GePPO < M n unless ν is the uniform distribution.
By Lemma 4, GePPO results in an overall policy change of in terms of total variation distance for every N = Bn samples collected, as long as the effective sample size of GePPO is at least N . Using the general forms of effective sample size in (36) and total variation distance change in (37), we can optimize the results in Theorem 2 as follows: Theorem 4. LetM ≥ B be the maximum number of prior policies. Consider the goal of maximizing the change in total variation distance of the policy with GePPO while maintaining the same effective sample size of N = Bn used in PPO. Then, the policy weights ν that achieve this goal are the optimal solution to the convex optimization problem Proof. We can maximize the total variation distance change in (37) by choosing ν that minimizes the denominator, leading to the objective in (38). Next, we must have an effective sample size that is at least N = Bn. Equivalently, we need which can be rewritten as the first constraint in (38). Finally, the other constraints in (38) ensure that ν is a distribution.
Theorem 2 considers uniform policy weights with M = B, which are a feasible solution to (38). As a result, Theorem 4 increases the change in total variation distance compared to Theorem 2.
Similarly, we can optimize the results in Theorem 3 as follows: Theorem 5. LetM ≥ 2B − 1 be the maximum number of prior policies. Consider the goal of maximizing the effective sample size with GePPO while maintaining the same change in total variation distance of the policy throughout training as PPO. Then, the policy weights ν that achieve this goal are the optimal solution to the convex optimization problem Proof. We can maximize the effective sample size in (36) by choosing ν that minimizes the denominator, leading to the objective in (40). Next, the total variation distance change in (37) must equal PPO /2, which we accomplish with the first constraint in (40). Finally, the other constraints in (40) ensure that ν is a distribution. Theorem 3 considers uniform policy weights with M = 2B − 1, which are a feasible solution to (40). Therefore, Theorem 5 increases the effective sample size compared to Theorem 3. Also note that by selectingM to be large, Theorem 4 and Theorem 5 solve for both the optimal choice of M and the corresponding optimal weights. See Figure 3 for a comparison of the optimal and uniform policy weights when B = 2, which is the setting for the experiments we considered. Note that the optimal policy weights can be found very efficiently, and the convex optimization problems in Theorem 4 and Theorem 5 only need to be solved once at the beginning of training to determine the policy weights ν.

C Implementation details
To aid in reproducibility, we describe the implementation details used to produce our experimental results. Note that all choices are based on the default implementation of PPO in Henderson et al. [12].
Network structures and hyperparameters As discussed in Section 8, we represent the policy π as a multivariate Gaussian distribution where the mean action for a given state is parameterized by a neural network with two hidden layers of 64 units each and tanh activations. The stateindependent standard deviation is parameterized separately, where for each action dimension the standard deviation is initialized as a multiple of half of the feasible action range. The value function V π (s) is parameterized by a separate neural network with two hidden layers of 64 units each and tanh activations. Observations are standardized using a running mean and standard deviation throughout the training process. Both the policy and value function are updated at every iteration using minibatch stochastic gradient descent. All hyperparameters associated with these optimization processes can be found in Table 2. Due to the high-dimensional nature of Ant-v3 and Humanoid-v3, we tuned the initial learning rate and standard deviation multiple of the policy used for PPO on these tasks. These values can also be found in Table 2. For a fair comparison, we used the same hyperparameter values for GePPO.
Following Henderson et al. [12], we consider the clipping parameter PPO = 0.2 and a batch size of N = 2,048 for PPO. Because sample trajectories for the tasks we consider can contain up to one thousand steps, we consider a minimum batch size of n = 1,024 for GePPO. When writing the default batch size in PPO as N = Bn, this results in B = 2. Using this value of B, the number of prior policies M and the corresponding policy weights ν for GePPO are calculated according to Theorem 5. These weights are shown on the right-hand side of Figure 3. The clipping parameter GePPO is calculated based on these policy weights using Lemma 4, which results in GePPO = 0.1. Finally, the adaptive factor α and minimum threshold factor β used for our adaptive learning rate method can be found in Table 2.
Advantage estimation Advantages A π k (s, a) of the current policy in PPO are estimated using Generalized Advantage Estimation (GAE) [18] with λ = 0.97. Note that the parameter λ in GAE determines a weighted average over K-step advantage estimates. When samples are collected using the current policy π k , these multi-step advantage estimates are unbiased except for the use of bootstrapping with the learned value function. In GePPO, however, we must estimate A π k (s, a) using samples collected from prior policies, so the multi-step advantage estimates used in GAE are no longer unbiased. Instead, we use V-trace [6] to calculate corrected estimates that are suitable for the off-policy setting. V-trace corrects multi-step estimates while controlling variance by using truncated importance sampling. For a learned value function V , current policy π k , and prior policy π k−i used to generate the data, this results in the following K-step target for the value function: where δ V t = r(s t , a t ) + γV (s t+1 ) − V (s t ) and c t = min (c, π k (at|st) /π k−i (at|st)) represents a truncated importance sampling ratio with truncation parameterc. We can use the same correction techniques to generate K-step advantage estimates from off-policy data. For K ≥ 2, the corresponding K-step advantage estimate is given by and for K = 1 we have the standard one-step estimate A π k trace (s t , a t ) = δ V t that does not require any correction. We usec = 1.0 in our experiments, which is the default setting in Espeholt et al. [6]. Note that Espeholt et al. [6] treat the final importance sampling ratio in each term separately, but in practice the truncation parameters are chosen to be the same so we do not make this distinction in our notation. Finally, we consider a weighted average over these corrected multi-step advantage estimates as in GAE.
Typically, the resulting advantage estimates are standardized within each minibatch of PPO. Note that the expectation of A π k (s, a) with respect to samples generated by π k is zero, so the centering of advantage estimates ensures that the empirical average also satisfies this property. In the off-policy setting, the appropriate quantity to standardize is the starting point of policy updates π k (a | s) since the expectation of (43) with respect to samples generated by prior policies is zero. Note that the standardization of (43) generalizes the standardization done in PPO, where the probability ratios at the beginning of each policy update are all equal to one.
Computational resources All experiments were run on a Windows 10 operating system, Intel Core i7-9700 CPU with base speed of 3.0 GHz and 32 GB of RAM, and NVIDIA GeForce RTX 2060 GPU with 6 GB of dedicated memory. OpenAI Gym [3] is available under The MIT License, and we make use of MuJoCo [21] with a license obtained from Roboti LLC. Using code that has not been optimized for execution speed, simulations for all seeds on a given environment required approximately 3 hours of wall-clock time for PPO and 4 hours of wall-clock time for GePPO. The increased wall-clock time of GePPO is due to the fact that GePPO performs twice as many updates in our experiments compared to PPO. Note that on average the sample efficiency benefits of GePPO not only lead to improved performance compared to PPO for a fixed number of samples, but also for a fixed amount of wall-clock time.

D Additional experimental results
In this section, we provide additional experimental results to further analyze the performance of our algorithm. In particular, we include results across all MuJoCo tasks for both the default policy network with two hidden layers of 64 units each and a standard wide policy network with two hidden layers of 400 and 300 units, respectively. In all cases, we also consider a variant of PPO that uses our adaptive learning rate method to better understand the drivers of performance in GePPO. Figure 5 show the performance throughout training and change in average total variation distance per policy update, respectively, when using the default policy network. Note that the results shown in Figure 1 and Figure 2 for PPO and GePPO with the default policy network are repeated here for reference. As discussed in Section 8, we see that the change in total variation distance per policy  update in PPO increases throughout training across all environments. Because hyperparameters were tuned using the default policy network, this trend does not lead to unstable performance. The addition of our adaptive learning rate to PPO results in comparable performance in this well-tuned setting, while ensuring that the change in total variation distance remains close to the target determined by the clipping parameter. This causes a decrease in total variation distance change per policy update compared to PPO at the end of training in most environments, and an increase compared to PPO at the beginning of training in Swimmer-v3 and Hopper-v3. Finally, note that GePPO outperforms the variant of PPO with our adaptive learning rate, which indicates that sample reuse is an important driver of performance in GePPO. On average, GePPO improves average performance throughout training by 31% compared to PPO and 32% compared to PPO with our adaptive learning rate. Figure 6 and Figure 7 show the same metrics for a standard wide policy network with two hidden layers of 400 and 300 units, respectively. The results shown in Figure 2 for Walker2d-v3 are repeated here for reference. As described in Section 8 for Walker2d-v3, we see that the wide policy network exacerbates the total variation distance trend observed in PPO under the default settings. The increased size of the policy network causes the probability ratio to be more sensitive to gradient updates during training, which renders the clipping mechanism ineffective and leads to excessively large policy updates. These large updates result in poor performance across several environments, and even cause performance to decline over time for Hopper-v3 and Walker2d-v3. The addition of our adaptive learning rate to PPO controls this source of instability, resulting in improved performance throughout training and stable policy updates with acceptable levels of risk. The exception to this trend is Humanoid-v3, where PPO outperforms PPO with our adaptive learning rate. This suggests that a more aggressive risk profile may improve performance on Humanoid-v3 without sacrificing training stability. Finally, by reusing samples from prior policies, GePPO further improves upon the performance of PPO with our adaptive learning rate. On average, GePPO improves average performance throughout training by 63% compared to PPO and 34% compared to PPO with our adaptive learning rate.

Figure 4 and
From these results, we see that the principled sample reuse in GePPO is a key driver of performance gains compared to PPO, while the use of an adaptive learning rate is important for stable performance that is robust to hyperparameter settings. Note that it is possible to achieve strong performance without the use of our adaptive learning rate, but this requires careful tuning of the learning rate that depends on several factors including the environment, policy network structure, length of training, and other hyperparameter settings.