Offline RL Without Off-Policy Evaluation

David Brandfonbrener, William F. Whitney, Rajesh Ranganath, Joan Bruna

Introduction

An important step towards effective real-world RL is to improve sample efficiency. One avenue towards this goal is offline RL (also known as batch RL) where we attempt to learn a new policy from data collected by some other behavior policy without interacting with the environment. Recent work in offline RL is well summarized by Levine et al. .

In this paper, we challenge the dominant paradigm in the deep offline RL literature that primarily relies on actor-critic style algorithms that alternate between policy evaluation and policy improvement [Fujimoto et al., 2018a, 2019, Peng et al., 2019, Kumar et al., 2019, 2020, Wang et al., 2020b, Wu et al., 2019, Kostrikov et al., 2021, Jaques et al., 2019, Siegel et al., 2020, Nachum et al., 2019]. All these algorithms rely heavily on off-policy evaluation to learn the critic. Instead, we find that a simple baseline which only performs one step of policy improvement using the behavior Q function often outperforms the more complicated iterative algorithms. Explicitly, we find that our one-step algorithm beats prior results of iterative algorithms on most of the gym-mujoco [Brockman et al., 2016] and Adroit [Rajeswaran et al., 2017] tasks in the the D4RL benchmark suite [Fu et al., 2020].

We then dive deeper to understand why such a simple baseline is effective. First, we examine what goes wrong for the iterative algorithms. When these algorithms struggle, it is often due to poor off-policy evaluation leading to inaccurate Q values. We attribute this to two causes: (1) distribution shift between the behavior policy and the policy to be evaluated, and (2) iterative error exploitation whereby policy optimization introduces bias and dynamic programming propagates this bias across the state space. We show that empirically both issues exist in the benchmark tasks and that one way to avoid these issues is to simply avoid off-policy evaluation entirely.

Finally, we recognize that while the the one-step algorithm is a strong baseline, it is not always the best choice. In the final section we provide some guidance about when iterative algorithms can perform better than the simple one-step baseline. Namely, when the dataset is large and behavior policy has good coverage of the state-action space, then off-policy evaluation can succeed and iterative algorithms can be effective. In contrast, if the behavior policy is already fairly good, but as a result does not have full coverage, then one-step algorithms are often preferable.

A demonstration that a simple baseline of one step of policy improvement outperforms more complicated iterative algorithms on a broad set of offline RL problems.

An examination of failure modes of off-policy evaluation in iterative offline RL algorithms.

A description of when one-step algorithms are likely to outperform iterative approaches.

Setting and notation

Following Fu et al. and others in this line of work, we allow access to the environment to tune a small (< 10) set of hyperparameters. See Paine et al. for a discussion of the active area of research on hyperparameter tuning for offline RL. We also discuss this further in Appendix C.

Related work

Most prior work on deep offline RL consists of iterative actor-critic algorithms. The primary innovation of each paper is to propose a different mechanism to ensure that the learned policy does not stray too far from the data generated by the behavior policy. Broadly, we group these methods into three camps: policy constraints/regularization, modifications of imitation learning, and Q regularization:

The majority of prior work acts directly on the policy. Some authors have proposed explicit constraints on the learned policy to only select actions where (s,a)(s,a) has sufficient support under the data generating distribution [Fujimoto et al., 2018a, 2019, Laroche et al., 2019]. Another proposal is to regularize the learned policy towards the behavior policy [Wu et al., 2019] usually either with a KL divergence [Jaques et al., 2019] or MMD [Kumar et al., 2019]. This is a very straighforward way to stay close to the behavior with a hyperparameter that determines just how close. All of these algorithms are iterative and rely on off-policy evaluation.

Siegel et al. , Wang et al. [2020b], Chen et al. all use algorithms that filter out datapoints with low Q values and then perform imitation learning. Wang et al. , Peng et al. use a weighted imitation learning algorithm where the weights are determined by exponentiated Q values. These algorithms are iterative.

Another way to prevent the learned policy from choosing unknown actions is to incorporate some form of regularization to encourage staying near the behavior and being pessimistic about unknown state, action pairs [Wu et al., 2019, Nachum et al., 2019, Kumar et al., 2020, Kostrikov et al., 2021, Gulcehre et al., 2021]. However, being able to properly quantify uncertainty about unknown states is notoriously difficult when dealing with neural network value functions [Buckman et al., 2020].

One-step algorithms.

Some recent work has also noted that optimizing policies based on the behavior value function can perform surprisingly well. As we do, Goo and Niekum studies the continuous control tasks from the D4RL benchmark, but they examine a complicated algorithm involving ensembles, distributional Q functions, and a novel regularization technique. In contrast, we analyze a substantially simpler algorithm and get better performance on the D4RL tasks. We also focus more of our contribution on understanding and explaining this performance. Gulcehre et al. studies the discrete action setting and finds that a one-step algorithm (which they call “behavior value estimation”) outperforms prior work on Atari games and other discrete action tasks from the RL Unplugged benchmark [Gulcehre et al., 2020]. They also introduce a novel regularizer for the evaluation step. In contrast, we consider the continuous control setting. This is a substantial difference in setting since continuous control requires actor-critic algorithms with parametric policies while in the discrete setting the policy improvement step can be computed exactly from the Q function. Moreover, while Gulcehre et al. attribute the poor performance of iterative algorithms to “overestimation”, we define and separate the issues of distribution shift and iterative error exploitation which can combine to cause overestimation. This separation helps to expose the difference between the fundamental limits of off-policy evaluation from the specific problems induced by iterative algorithms, and will hopefully be a useful distinction to inspire future work. Finally, a one-step variant is also briefly discussed in Nadjahi et al. , but is not the focus of that work.

There are also important connections between the one-step algorithm and the literature on conservative policy improvement [Kakade and Langford, 2002, Schulman et al., 2015, Achiam et al., 2017], which we discuss in more detail in Appendix B.

Defining the algorithms

In this section we provide a unified algorithmic template for model-free offline RL algorithms as offline approximate modified policy iteration. We show how this template captures our one-step algorithm as well as a multi-step policy iteration algorithm and an iterative actor-critic algorithm. Then any choice of policy evaluation and policy improvement operators can be used to define one-step, multi-step, and iterative algorithms.

We consider a generic offline approximate modified policy iteration (OAMPI) scheme, shown in Algorithm 1 (and based off of Puterman and Shin , Scherrer et al. ). Essentially the algorithm alternates between two steps. First, there is a policy evaluation step where we estimate the Q function of the current policy πk−1\pi_{k-1} by Q^πk−1\widehat{Q}^{\pi_{k-1}} using only the dataset DND_{N}. Implementations also often use the prior Q estimate Q^πk−2\widehat{Q}^{\pi_{k-2}} to warm-start the approximation process. Second, there is a policy improvement step. This step takes in the estimated Q function Q^πk−1\widehat{Q}^{\pi_{k-1}}, the estimated behavior β^\hat{\beta}, and the dataset DND_{N} and produces a new policy πk\pi_{k}. Again an algorithm may use πk−1\pi_{k-1} to warm-start the optimization. Moreover, we expect this improvement step to be regularized or constrained to ensure that πk\pi_{k} remains in the support of β\beta and DND_{N}. Choices for this step are discussed below. Now we discuss a few ways to instantiate the template.

The simplest algorithm sets the number of iterations K=1K=1. We learn β^\hat{\beta} by maximum likelihood and train the policy evaluation step to estimate QβQ^{\beta}. Then we use any one of the policy improvement operators discussed below to learn π1\pi_{1}. Importantly, this algorithm completely avoids off-policy evaluation.

Multi-step.

The multi-step algorithm now sets K>1K>1. The evaluation operator must evaluate off-policy since DND_{N} is collected by β\beta, but evaluation steps for K≥2K\geq 2 require evaluating policies πk−1≠β\pi_{k-1}\neq\beta. Each iteration is trained to convergence in both the estimation and improvement steps.

Iterative actor-critic.

An actor critic approach looks somewhat like the multi-step algorithm, but does not attempt to train to convergence at each iteration and uses a much larger KK. Here each iteration consists of one gradient step to update the Q estimate and one gradient step to improve the policy. Since all of the evaluation and improvement operators that we consider are gradient-based, this algorithm can adapt the same evaluation and improvement operators used by the multi-step algorithm. Most algorithms from the literature fall into this category [Fujimoto et al., 2018a, Kumar et al., 2019, 2020, Wu et al., 2019, Wang et al., 2020b, Siegel et al., 2020].

2 Policy evaluation operator

Following prior work on continuous state and action problems, we always evaluate by simple fitted Q evaluation [Fujimoto et al., 2018a, Kumar et al., 2019, Siegel et al., 2020, Wang et al., 2020b, Paine et al., 2020, Wang et al., 2021]. In practice this is optimized by TD-style learning with the use of a target network [Mnih et al., 2015] as in DDPG [Lillicrap et al., 2015]. We do not use any double Q learning or Q ensembles [Fujimoto et al., 2018b]. For the one-step and multi-step algorithms we train the evaluation procedure to convergence on each iteration and for the iterative algorithm each iteration takes a single stochastic gradient step. See Voloshin et al. , Wang et al. for more comprehensive examinations of policy evaluation and some evidence that this simple fitted Q iteration approach is reasonable. It is an interesting direction for future work to consider other operators that use things like importance weighting [Munos et al., 2016] or pessimism [Kumar et al., 2020, Buckman et al., 2020].

3 Policy improvement operators

To instantiate the template, we also need to choose a specific policy improvement operator I\mathcal{I}. We consider the following improvement operators selected from those discussed in the related work section. Each operator has a hyperparameter controlling deviation from the behavior policy.

The simplest baseline worth including is to just return β^\hat{\beta} as the new policy π\pi. Any policy improvement operator ought to perform at least as well as this baseline.

Constrained policy updates.

Algorithms like BCQ [Fujimoto et al., 2018a] and SPIBB [Laroche et al., 2019] constrain the policy updates to be within the support of the data/behavior. In favor of simplicity, we implement a simplified version of the BCQ algorithm that removes the “perturbation network” which we call Easy BCQ. We define a new policy π^kM\hat{\pi}^{M}_{k} by drawing MM samples from β^\hat{\beta} and then executing the one with the highest value according to Q^β\widehat{Q}^{\beta}. Explicitly:

Regularized policy updates.

Another common idea proposed in the literature is to regularize towards the behavior policy [Wu et al., 2019, Jaques et al., 2019, Kumar et al., 2019]. For a general divergence DD we can define an algorithm that maximizes a regularized objective:

A comprehensive review of different variants of this method can be found in Wu et al. which does not find dramatic differences across regularization techniques. In practice, we will use reverse KL divergence, i.e. KL(π(⋅∣si)∥β^(⋅∣si))KL(\pi(\cdot|s_{i})\|\hat{\beta}(\cdot|s_{i})). To compute the reverse KL, we draw samples from π(⋅∣si)\pi(\cdot|s_{i}) and use the density estimate β^\hat{\beta} to compute the divergence. Intuitively, this regularization forces π\pi to remain within the support of β\beta rather than incentivizing π\pi to cover β\beta.

Variants of imitation learning.

Another idea, proposed by [Wang et al., 2018, Siegel et al., 2020, Wang et al., 2020b, Chen et al., 2020] is to modify an imitation learning algorithm either by filtering or weighting the observed actions to incentivize policy improvement. The weighted version that we implement uses exponentiated advantage estimates to weight the observed actions:

With these definitions, we can now move on to testing various combinations of algorithmic template (one-step, multi-step, or iterative) and improvement operator (Easy BCQ, reverse KL regularization, or exponentially weighted imitation).

Benchmark Results

Our main empirical finding is that one step of policy improvement is sufficient to beat state of the art results on much of the D4RL benchmark suite [Fu et al., 2020]. This is striking since prior work focuses on iteratively estimating the Q function of the current policy iterate, but we only use one step derived from Q^β\widehat{Q}^{\beta}. Results are shown in Table 1. Full experimental details are in Appendix C and code can be found at https://github.com/davidbrandfonbrener/onestep-rl.

As we can see in the table, all of the one-step algorithms usually outperform the best iterative algorithms tested by Fu et al. . The one notable exception is the case of random data (especially on halfcheetah), where iterative algorithms have a clear advantage. We will discuss potential causes of this further in Section 7.

To give a more direct comparison that controls for any potential implementation details, we use our implementation of reverse KL regularization to create multi-step and iterative algorithms. We are not using algorithmic modifications like Q ensembles, regularized Q values, or early stopping that have been used in prior work. But, our iterative algorithm recovers similar performance to prior regularized actor-critic approaches. These results are shown in Table 2.

Put together, these results immediately suggest some guidance to the practitioner: it is worthwhile to run the one-step algorithm as a baseline before trying something more elaborate. The one-step algorithm is substantially simpler than prior work, but frequently achieves better performance.

What goes wrong for iterative algorithms?

The benchmark experiments show that one step of policy improvement often beats iterative and multi-step algorithms. In this section we dive deeper to understand why this happens. First, by examining the learning curves of each of the algorithms we note that iterative algorithms require stronger regularization to avoid instability. Then we identify two causes of this instability: distribution shift and iterative error exploitation.

Distribution shift causes evaluation error by reducing the effective sample size in the fixed dataset for evaluating the current policy and has been extensively considered in prior work as discussed below. Iterative error exploitation occurs when we repeatedly optimize policies against our Q estimates and exploit their errors. This introduces a bias towards overestimation at each step (much like the training error in supervised learning is biased to be lower than the test error). Moreover, by iteratively re-using the data and using prior Q estimates to warmstart training at each step, the errors from one step are amplified at the next. This type of error is particular to multi-step and iterative algorithms.

To begin to understand why iterative and multi-step algorithms can fail it is instructive to look at the learning curves. As shown in Figure 2, we often observe that the iterative algorithm will begin to learn and then crash. Regularization can help to prevent this crash since strong enough regularization towards the behavior policy ensures that the evaluation is nearly on-policy.

In contrast, the one-step algorithm is more robust to the regularization hyperparameter. The rightmost panel of the figure shows this clearly. While iterative and multi-step algorithms can have their performance degrade very rapidly with the wrong setting of the hyperparameter, the one-step approach is more stable. Moreover, we usually find that the optimal setting of the regularization hyperparameter is lower for the one-step algorithm than the iterative or multi-step approaches.

2 Distribution shift

Any algorithm that relies on off-policy evaluation will struggle with distribution shift in the evaluation step. Trying to evaluate a policy that is substantially different from the behavior reduces the effective sample size and increases the variance of the estimates. Explicitly, by distribution shift we mean the shift between the behavior distribution (the distribution over state-action pairs in the dataset) and the evaluation distribution (the distribution that would be induced by the policy π\pi we want to evaluate).

There is a substantial body of prior theoretical work that suggests that off-policy evaluation can be difficult and this difficulty scales with some measure of distribution shift. Wang et al. [2020a], Amortila et al. , Zanette give exponential (in horizon) lower bounds on sample complexity in the linear setting even with good feature representations that can represent the desired Q function and assuming good data coverage. Upper bounds generally require very strong assumptions on both the representation and limits on the distribution shift [Wang et al., 2021, Duan et al., 2020, Chen and Jiang, 2019]. Moreover, the assumed bounds on distribution shift can be exponential in horizon in the worst case. On the empirical side, Wang et al. demonstrates issues with distribution shift when learning from pre-trained features and provides a nice discussion of why distribution shift causes error amplification. Fujimoto et al. [2018a] raises a similar issue under the name “extrapolation error”. Regularization and constraints are meant to reduce issues stemming from distribution shift, but also reduce the potential for improvement over the behavior.

Empirical evidence.

Both the multi-step and iterative algorithms in our experiments rely on off-policy evaluation as a key subroutine. We examine how easy it is to evaluate the policies encountered along the learning trajectory. To control for issues of iterative error exploitation (discussed in the next subsection), we train Q estimators from scratch on a heldout evaluation dataset sampled from the behavior policy. We then evaluate these trained Q function on rollouts from 1000 datapoints sampled from the replay buffer. Results are shown in Figure 3.

The results show a correlation betweed KL and MSE. Moreover, we see that the MSE generally increases over training. One way to mitigate this, as seen in the figure, is to use a large value of α\alpha. We just cannot take a very large step before running into problems with distribution shift. But, when we take such a small step, the information from the on-policy Q^β\widehat{Q}^{\beta} is about as useful as the newly estimated Q^π\widehat{Q}^{\pi}. This is seen, for example, in Figure 2 where we get very similar performance across algorithms at high levels of regularization.

3 Iterative error exploitation

The previous subsection identifies how any algorithm that uses off-policy evaluation is fundamentally limited by distribution shift, even if we were given fresh data and trained Q functions from scratch at every iteration. But, in practice, iterative algorithms repeatedly iterate between optimizing policies against estimated Q functions and re-estimating the Q functions using the same data and using the Q function from the previous step to warm-start the re-estimation. This induces dependence between steps that causes a problem that we call iterative error exploitation.

In short, iterative error exploitation happens because πi\pi_{i} tends to choose overestimated actions in the policy improvement step, and then this overestimation propagates via dynamic programming in the policy evaluation step. To illustrate this issue more formally, consider the following: at each s,as,a we suffer some Bellman error εβπ(s,a)\varepsilon_{\beta}^{\pi}(s,a) based on our fixed dataset collected by β\beta. Formally,

Intuitively, εβπ\varepsilon_{\beta}^{\pi} will be larger at state-actions with less coverage in the dataset collected by β\beta. Note that εβπ\varepsilon_{\beta}^{\pi} can absorb all error whether it is caused by the finite sample size or function approximation error.

All that is needed to cause iterative error exploitation is that the ϵβπ\epsilon_{\beta}^{\pi} are highly correlated across different π\pi, but for simplicity, we will assume that εβπ\varepsilon_{\beta}^{\pi} is the same for all policies π\pi estimated from our fixed offline dataset and instead write εβ\varepsilon_{\beta}. Now that the errors do not depend on the policy we can treat the errors as auxiliary rewards that obscure the true rewards and see that

This assumption is somewhat reasonable since we expect the error to primarily depend on the data. And, when the prior Q function is used to warm-start the current one (as is generally the case in practice), the approximation errors are automatically passed between steps.

Now we can explain the problem. Recall that under our assumption the εβ\varepsilon_{\beta} are fixed once we have a dataset and likely to have larger magnitude the further we go from the support of the dataset. So, with each step πi\pi_{i} is able to better maximize εβ\varepsilon_{\beta}, thus moving further from β\beta and increasing the magnitude of Q~βπi\widetilde{Q}^{\pi_{i}}_{\beta} relative to QπiQ^{\pi_{i}}. Even though QπiQ^{\pi_{i}} may provide better signal than QβQ^{\beta}, it can easily be drowned out by Q~βπi\widetilde{Q}^{\pi_{i}}_{\beta}. In contrast, Q~ββ\widetilde{Q}_{\beta}^{\beta} has small magnitude, so the one-step algorithm is robust to errorsWe should note that iterative error exploitation is similar to the overestimation addressed by double Q learning [Van Hasselt et al., 2016, Fujimoto et al., 2018b], but distinct. Since we are in the offline setting, the errors due to our finite dataset can be iteratively exploited more and more, while in the online setting considered by double Q learning, fresh data prevents this issue. We are also considering an algorithm based on policy iteration rather than value iteration..

An example.

Now we consider a simple gridworld example to illustrate iterative error exploitation. This example fits exactly into the setup outlined above since all errors are due to reward estimation so the εβ\varepsilon_{\beta} is indeed constant over all π\pi. The gridworld we consider has one deterministic good state with reward 1 and many stochastic bad states that have rewards distributed as N(−0.5,1)\mathcal{N}(-0.5,1). We collect a dataset of 100 trajectories, each of length 100. One run of the multi-step offline regularized policy iteration algorithm is illustrated in Figure 4.

In the example we see that one step often outperforms multiple steps of improvement. Intuitively, when there are so many noisy states, it is likely that a few of them will be overestimated. Since the data is re-used for each step, these overestimations persist and propagate across the state space due to iterative error exploitation. This property of having many bad, but poorly estimated states likely also exists in the high-dimensional control problems encountered in the benchmark where there are many ways for the robots to fall down that are not observed in the data for non-random behavior. Moreover, both settings have larger errors in areas where we have less data. So even though the errors in the gridworld are caused by noise in the rewards, while errors in D4RL are caused by function approximation, we think this is a useful mental model of the problem.

Empirical evidence.

In practice we cannot easily visualize the progression of errors. However, the dependence between steps still arises as overestimation of the Q values. We can track the overestimation of the Q values over training as a way to measure how much bias is being induced by optimizing against our dependent Q estimators. As a control we can also train Q estimators from scratch on independently sampled evaluation data. These independently trained Q functions do not have the same overestimation bias even though the squared error does tend to increase as the policy moves further from the behavior (as seen in Figure 3). Explicitly, we track 1000 state, action pairs from the replay buffer over training. For each checkpointed policy we perform 3 rollouts at each state to get an estimate of the true Q value and compare this to the estimated Q value. Results are shown in Figure 5.

When are multiple steps useful?

So far we have focused on why the one-step algorithm often works better than the multi-step and iterative algorithms. However, we do not want to give the impression that one-step is always better. Indeed, our own experiments in Section 5 show a clear advantage for the multi-step and iterative approaches when we have randomly collected data. While we cannot offer a precise delineation of when one-step will outperform multi-step, in this section we offer some intuition as to when we can expect to see benefits from multiple steps of policy improvement.

As seen in Section 6, multi-step and iterative algorithms have problems when they propagate estimation errors. This is especially problematic in noisy and/or high dimensional environments. While the multi-step algorithms propagate this noise more widely than the one-step algorithm, they also propagate the signal. So, when we have sufficient coverage to reduce the magnitude of the noise, this increased propagation of signal can be beneficial. The D4RL experiments suggest that we are usually on the side of the tradeoff where the errors are large enough to make one-step preferable.

In Appendix A we illustrate a simple gridworld example where a slight modification of the behavior policy from Figure 4 makes multi-step dramatically outperform one-step. This modified behavior policy (1) has better coverage of the noisy states (which reduces error, helping multi-step), and (2) does a worse job propagating the reward from the good state (hurting one-step).

We can also test empirically how the behavior policy effects the tradeoff between error and signal propagation. To do this we construct a simple experiment where we mix data from the random behavior policy with data from the medium behavior policy. Explicitly we construct a dataset DD out of the datasets DrD_{r} for random and DmD_{m} for medium such that each trajectory in DD comes from the medium dataset with probability pmp_{m}. So for pm=0p_{m}=0 we have the random dataset and pm=1p_{m}=1 we have the medium dataset, and in between we have various mixtures. Results are shown in Figure 6. It takes surprisingly little data from the medium policy for one-step to outperform the iterative algorithm.

Discussion, limitations, and future work

This paper presents the surprising effectiveness of a simple one-step baseline for offline RL. We examine the failure modes of iterative algorithms and the conditions where we might expect them to outperform the simple one-step baseline. This provides guidance to a practitioner that the simple one-step baseline is a good place to start when approaching an offline RL problem.

But, we leave many questions unanswered. One main limitation is that we lack a clear theoretical characterization of which environments and behaviors can guarantee that one-step outperforms multi-step or visa versa. Such results will likely require strong assumptions, but could provide useful insight. We don’t expect this to be easy as it requires understanding policy iteration which has been notoriously difficult to analyze, often converging much faster than the theory would suggest [Sutton and Barto, 2018, Agarwal et al., 2019]. Another limitation is that while only using one step is perhaps the simplest way to avoid the problems of off-policy evaluation, there are possibly other more elaborate algorithmic solutions that we did not consider here. However, our strong empirical results suggest that the one-step algorithm is at least a strong baseline.

Our paper studies a simple and effective baseline approach to the offline RL problem. The effectiveness of this baseline raises some serious questions about the utility of prior work proposing substantially more complicated methods. By making this observation of prior shortcomings, our paper has the potential to encourage researchers to derive new and better methods for offline RL. This has many potential impacts on fields as diverse as robotics and healthcare where better offline decision making can lead to better real-world performance. As always, we note that machine learning improvements come in the form of “building machines to do X better”. For a sufficiently malicious or ill-informed choice of X, almost any progress in machine learning might indirectly lead to a negative outcome, and our work is not excluded from that.

Acknowledgements

This work is partially supported by the Alfred P. Sloan Foundation, NSF RI-1816753, NSF CAREER CIF 1845360, NSF CHS-1901091, Samsung Electronics, and the Institute for Advanced Study. DB is supported by the Department of Defense (DoD) through the National Defense Science & Engineering Graduate Fellowship (NDSEG) Program.

References

Appendix A Gridworld example where multi-step outperforms one-step

As explained in the main text, this section presents an example that is only a slight modification of the one in Figure 4, but where a multi-step approach is clearly preferred over just one step. The data-generating and learning processes are exactly the same (100 trajectories of length 100, discount 0.9, α=0.1\alpha=0.1 for reverse KL regularization). The only difference is that rather than using a behavior that is a mixture of optimal and uniform, we use a behavior that is a mixture of maximally suboptimal and uniform. If we call the suboptimal policy π−\pi^{-} (which always goes down and left in our gridworld), then the behavior for the modified example is β=0.2⋅π−+0.8⋅u\beta=0.2\cdot\pi^{-}+0.8\cdot u, where uu is uniform. Results are shown in Figure 7.

By being more likely to go to the noisy states, this behavior policy allows us to get lower variance estimates of the rewards. Essentially, the coverage of the behavior policy in this example reduces the magnitude of the evaluation errors. This allows for more aggressive planning using multi-step methods. Moreover, since the behavior is less likely to go to the good state, the behavior Q function does not propagate the signal from the rewarding state as far, harming the one-step method.

Appendix B Connection to policy improvement guarantees

The regularized or constrained one-step algorithm performs an update that directly inherits guarantees from the literature on conservative policy improvement [Kakade and Langford, 2002, Schulman et al., 2015, Achiam et al., 2017]. These original papers consider an online setting where more data is collected at each step, but the guarantee at each step applies to our one-step offline algorithm.

Then, Corollary 1 from Achiam et al. (reproduced below) gives a guarantee for the one-step algorithm. The key idea is that when π\pi is sufficiently close to β\beta, we can use QβQ^{\beta} as an approximation to QπQ^{\pi}.

For any two policies π\pi and β\beta, let ∥Aπβ∥∞=sup⁡s∣Qβ(s,π)−Qβ(s,β)∣\|A^{\beta}_{\pi}\|_{\infty}=\sup_{s}|Q^{\beta}(s,\pi)-Q^{\beta}(s,\beta)|. Then,

where DTVD_{TV} denotes the total variation distance.

Replacing QβQ^{\beta} with Q^β\widehat{Q}^{\beta} and the TV distance by the KL (using Pinsker’s inequality), we get precisely the objective that we optimize in the one-step algorithm. This shows that the one-step algorithm indeed optimizes a lower bound on the performance difference. Of course, in practice we replace the potentially large multiplier on the divergence term by a hyperparameter, but this theory at least motivates the soundness of the approach.

We are not familiar with similar guarantees for the iterative or multi-step approaches that rely on off-policy evaluation.

Appendix C Experimental setup

Code for our experimental setup can be found at https://github.com/davidbrandfonbrener/onestep-rl.

We use the datasets from the D4RL benchmark [Fu et al., 2020]. We use the latest versions, which are v2 for the mujoco datasets and v1 for the adroit datasets.

Hyperparameter tuning.

We follow the practice of Fu et al. and tune a small set of hyperparameters by interacting with the simulator to estimate the value of the policies learned under each hyperparameter setting. The hyperparameter sets for each algorithm can be seen in Table 3. We tune hyperparameters using 3 seeds, but then evaluate the best hyperparameter by training on an additional 7 seeds and then report results on the 10 total seeds.

This may initially seem like “cheating”, but can be a reasonable setup if we are considering applications like robotics where we can feasibly test a small number of trained policies on the real system. Also, since prior work has used this setup, it makes it easiest to compare our results if we use it too. While beyond the scope of this work, we do think that better offline model selection procedures will be crucial to make offline RL more broadly applicable. A good primer on this topic can be found in Paine et al. .

Models.

All of our Q functions and policies are simple MLPs with ReLU activations and 2 hidden layers of width 1024. Our policies output a truncated normal distribution with diagonal covariance where we can get reparameterized samples by sampling from a uniform distribution and computing the differentiable inverse CDF [Burkhardt, 2014]. We found this to be more stable than the tanh of normal used by e.g. Fu et al. , but to achieve similar performance when both are stable. We use these same models across all experiments.

One-step training procedure.

For all of our one-step algorithms, we train our β^\hat{\beta} behavior estimate by imitation learning for 500k gradient steps using Adam [Kingma and Ba, 2014] with learning rate 1e-4 and batch size 512. We train our Q^β\widehat{Q}^{\beta} estimator by fitted Q evaluation with a target network for 2 million gradient steps using Adam with learning rate 1e-4 and batch size 512. The target is updated softly at every step with parameter τ=0.005\tau=0.005. All policies are trained for 100k steps again with Adam using learning rate 1e-4 and batch size 512.

Easy BCQ does not require training a policy network and just uses β^\hat{\beta} and Q^β\widehat{Q}^{\beta} to define it’s policy. For the exponentially weighted algorithm, we clip the weights at 100 to prevent numerical instability. To estimate reverse KL at some state we use 10 samples from the current policy and the density defined by our estimated β^\hat{\beta}.

Each random seed retrains all three models (behavior, Q, policy) from different initializations. We use three random seeds.

Multi-step training procedure.

For multi-step algorithms we use all the same hyperparameters as one-step. We initialize our policy and Q function from the same pre-trained β^\hat{\beta} and Q^β\widehat{Q}^{\beta} as we use for the one-step algorithm trained for 500k and 2 million steps respectively. Then we consider 5 policy steps. To ensure that we use the same number of gradient updates on the policy, each step consists of 20k gradient steps on the policy followed by 200k gradient steps on the Q function. Thus, we take the same 100k gradient steps on the policy network. Now the Q updates are off-policy so the next action a′a^{\prime} is sampled from the current policy πi\pi_{i} rather than from the dataset.

Iterative training procedure.

For iterative algorithms we again use all the same hyperparameters and initialize from the same β^\hat{\beta} and Q^β\widehat{Q}^{\beta}. We again take the same 100k gradient steps on the policy network. For each step on the policy network we take 2 off-policy gradient steps on the Q network.

Evaluation procedure.

To evaluate each policy we run 100 trajectories in the environment and compute the mean. We then report the mean and standard error over 10 training seeds.

C.2 MSE experiment (Figure 3)

To get an independently sampled dataset of the same size as the training set, we use the behavior cloned policy β^\hat{\beta} to sample 1000 trajectories. The checkpointed policies are taken at intervals of 5000 gradient steps from each of the three training seeds.

Training procedure.

The Q^πi\widehat{Q}^{\pi_{i}} training procedure is the same as before so we use Adam with step size 1e-4 and batch size 512 and a target network with soft updates with parameter 0.005. We train for 1 million steps.

Evaluation procedure.

To evaluate MSE, we sample 1000 state, action pairs from the original training set and from each state, action pair we run 3 rollouts. We take the mean over the rollouts and then compute squared error at each state, action pair and finally get MSE by taking the mean over state, action pairs. The reported reverse KL is evaluated by samples during training. At each state in a batch we take 10 samples to estimate the KL at that state and then take the mean over the batch.

C.3 Gridworld experiment (Figure 4)

The environment is a 15 x 15 gridworld with deterministic transitions. The rewards are deterministically 1 for all actions taken from the state in the top right corner and stochastic with distribution N(−0.5,1)\mathcal{N}(-0.5,1) for all actions taken from states on the left or bottom walls. The initial state is uniformly random. The discount is 0.9.

Data.

We collect data from a behavior policy that is a mixture of the uniform policy (with probability 0.8) and an optimal policy (with probability 0.2). We collect 100 trajectories of length 100.

Training procedure.

We give the agent access to the deterministic transitions. The only thing for the agent to do is estimate the rewards from the data and then learn in the empirical MDP. We perform tabular Q evaluation by dynamic programming. We initialize with the empirical rewards and do 100 steps of dynamic programming with discount 0.9. Regularized policy updates are solved for exactly by setting πi(a∣s)∝β(a∣s)exp⁡(1αQ^πi−1(s,a))\pi_{i}(a|s)\propto\beta(a|s)\exp(\frac{1}{\alpha}\widehat{Q}^{\pi_{i-1}}(s,a)).

C.4 Overestimation experiment (Figure 5)

This experiment uses the same setup as the MSE experiment. The main difference is we also consider the Q functions learned during training and demonstrate the overestimation relative to the Q functions trained on the evaluation dataset as in the MSE experiment.

C.5 Mixed data experiment (Figure 6)

We construct datasets with pm={0.0,0.1,0.2,0.4,0.6,0.8,1.0}p_{m}=\{0.0,0.1,0.2,0.4,0.6,0.8,1.0\} by mixing the random and medium datasets from D4RL and then run the same training procedure as we did for the benchmark experiments. Each dataset has the same size, but a different proportion of trajectories from the medium policy.

Appendix D Learning curves

In this section we reproduce the learning curves and hyperparameter plots across the one-step, multi-step, and iterative algorithms with reverse KL regularization, as in Figure 2.