Conservative Offline RL: BCQ, CQL & IQL
Constraining the policy, penalizing unseen actions, or never querying them.
Three ideas carry most practical offline RL: keep the policy where the data are (BCQ, TD3+BC), push down the values of what the data do not show (CQL), or never evaluate it at all (IQL). Each comes with a precise statement of what it achieves, under conditions that matter: deterministic dynamics for BCQ, a large enough penalty for CQL's lower bound, an expectile parameter approaching 1 for IQL. This lesson derives those statements, then weighs them against what the benchmarks show.
What you’ll learn
- Define batch-constrained policies, state the convergence theorem for batch-constrained Q-learning and why it assumes deterministic dynamics, and describe how deep BCQ approximates the constraint.
- Derive CQL's regularizer from a min–max problem, show that its evaluation step is policy evaluation with a penalized reward, and state its pointwise and value lower bounds with their conditions.
- Prove the properties of expectiles that make IQL approach the best in-support action as , and explain why IQL fits to rather than to the TD target.
- Compare critic ensembles and TD3+BC with these methods, and assess what benchmark comparisons do and do not show.
Batch-constrained Q-learning
Fujimoto, Meger and Precup (2019) began with a tabular question: which policies can a dataset evaluate without extrapolating? Call a policy batch-constrained if every state–action pair it can reach and choose appears in . Q-learning on never bootstraps from an unseen pair when it evaluates such a policy, and restricting the maximum accordingly gives batch-constrained Q-learning (BCQL):
Why determinism? One logged transition of a deterministic system is that transition. In a stochastic system it is a sample, and the batch defines its own empirical MDP, whose optimal policy can differ from the true one however carefully it stays on the data. BCQL is exact only where the data pin down the dynamics of every pair it uses. That is the template for everything that follows: trust values only where the data determine them.
In continuous action spaces you cannot enumerate "the actions logged at ", so deep BCQ learns them. A conditional variational autoencoder models ; the policy samples candidates from it, nudges each by a learned perturbation , and takes the best:
With and this is behavior cloning; with the whole action range and it is Q-learning again. The target uses the same candidates and a soft clipped double Q, with . For discrete actions, BCQ simply forbids actions whose probability under a learned behavior model is below a fixed fraction of the most likely action's (Fujimoto, Conti, Ghavamzadeh & Pineau, 2019).
Later methods kept the constraint and dropped the generative model from action selection. BEAR (Kumar et al., 2019) constrains the support of the policy rather than its distribution, with a maximum mean discrepancy penalty, so the policy may put all its mass on the best logged actions instead of copying their frequencies. TD3+BC (Fujimoto & Gu, 2021) adds to TD3's actor loss against , with and (Offline RL).
In deep BCQ, set the perturbation range to the full action range and sample very many candidates. What does the policy become, and why is that dangerous offline?
- Behavior cloning, which cannot improve on the data
- The greedy policy of Q-learning, which again maximizes over actions the data do not support
- A uniformly random policy
- The optimal batch-constrained policy
Show the answer
B. The greedy policy of Q-learning, which again maximizes over actions the data do not support
Large perturbations carry the chosen action away from the generative model's samples, and many candidates let the maximum find extrapolation errors again. Small and few candidates move BCQ toward behavior cloning; the useful settings lie in between.
CQL: pessimism as a penalized reward
Conservative Q-learning (Kumar, Zhou, Tucker & Levine, 2020) leaves the policy class alone and changes the evaluation step, so that actions the data do not support come out with low values. Its general form is a min–max problem over and an adversarial action distribution (Kumar et al. call it , which this course reserves for the initial-state distribution):
The inner maximum has a closed form, the Gibbs variational principle: , attained at . The penalty becomes , a soft maximum pushed down and the data's actions pushed up. This is CQL(H), the version used in practice; with continuous actions the log-sum-exp is estimated by importance sampling. To see what the penalty does to values, freeze and solve the evaluation step exactly in a tabular problem.
For a fixed and a fixed target, the loss separates over pairs. Pair carries regression weight and penalty weight , so the minimizer is the regression target minus a correction:
Since , each iteration is an ordinary Bellman backup for with the reward . CQL's fixed point is therefore the value of under a penalized reward: lower where puts more mass than the data, higher where it puts less. The data's frequent actions are pushed up.
Now take , the policy being evaluated. Averaged over , the penalty in state is a chi-squared divergence between the policy and the data:
So the state values solve a Bellman equation with reward . With exact backups (, ), the estimate is the true value minus times the discounted sum of divergences along 's own trajectories, a lower bound for every :
The condition deserves a second look. The required grows with the sampling error , as a confidence bound would. But it also grows as shrinks: a policy close to the data is barely penalized, so certifying a lower bound on its value needs a large . CQL's penalty measures distance from the data, not statistical uncertainty, and the two agree only roughly. Kumar et al. also prove a gap-expanding property (their Theorem 3.4): for large enough , the difference between the values of the data's actions and of the adversary's actions is larger under CQL than under the true action values, which is what keeps the improved policy near the data.
A one-step problem () has two actions. The data choose them with frequencies , and their true mean rewards are 0.5 and 0.6. With exact backups, CQL values a deterministic policy at its reward minus . Above what does CQL rank the common action above the rare, better one?
Show the answer
0.01125
For "always the rare action", ; for "always the common action", . The estimates and tie at . Above that, pessimism prefers the frequent action. Whether that is a mistake depends on how much the data say about the rare one: if its estimate rests on a handful of samples, its apparent advantage may be noise. Over stochastic policies, the penalized objective is maximized ever closer to itself as grows.
IQL: expectiles and the in-support maximum
Implicit Q-learning (Kostrikov, Nair & Levine, 2022) approximates a maximum over supported actions without evaluating an unsupported one. Its tool is the expectile: for a bounded random variable and , the -expectile minimizes . Three properties do all the work.
A self-weighted mean. Setting the derivative to zero gives . Equivalently, the expectile is the mean of after values above it are weighted by and values below it by :
Monotone in (Kostrikov et al., Lemma 2). Let . It decreases in , with slope , and increases in , with slope . Its root therefore rises with , starting from the mean:
Reaches the top of the support (Lemma 1). Let be the supremum of the support. Since , the first-order condition gives . If stayed below , the left side would stay above , a contradiction:
IQL backs up an expectile over the behavior's actions in place of a maximum. Its idealized values satisfy
and the networks of Offline RL fit them by regression on dataset tuples.
Proof sketch (finite states and actions). An expectile is monotone and shifts with its argument, so the backup is a -contraction in the max norm, like the constrained optimality backup , which takes the maximum over supported actions instead. An expectile never exceeds the maximum of its support, so , and monotonicity of the operators carries this to the fixed points; property 2 gives monotonicity in the same way. Finally , and the right side vanishes as by property 3, applied in each state.
Why fit to , not to the TD target? Regressing onto an upper expectile of would take the expectile over the next state as well, rewarding lucky transitions: a risky action that occasionally reaches a great state would be scored by its best outcomes. Fitting to , which already averages over , puts the expectile over actions only. The same luck problem returns, harder, in return-conditioned sequence models (RL as Sequence Modeling).
Policy extraction. The KL-regularized improvement step is solved by . Projecting onto a parametric family by maximum likelihood gives advantage-weighted regression on dataset pairs, . IQL therefore touches only logged actions, and it can improve on the data only by reweighting them: that is both its safety and its ceiling.
Ensembles, minimalism and the evidence
Pessimism from an ensemble. TD3 and SAC already take the minimum of two critics to counter overestimation (clipped double Q). An, Moon, Kim and Song (2021) observed that with many critics the same trick is an uncertainty penalty. If critics' estimates at a pair scatter with mean and standard deviation , roughly as independent Gaussians, then by symmetry
a lower confidence bound whose multiplier is 0.56 for , 1.54 for and 2.25 for , growing roughly like . Critics trained on the same data agree where the data are dense and disagree away from them, so the minimum penalizes exactly the out-of-distribution actions. Their SAC-N needed large ensembles on some tasks; EDAC adds a term that diversifies the critics' gradients and cut the required ensemble size to about a tenth.
| Method | Where unseen actions are evaluated | Extra components | Main knob | What is proved (tabular or idealized) |
|---|---|---|---|---|
| BCQ | only at perturbed samples near the data | behavior model, perturbation network | , | convergence to the best batch-constrained policy (deterministic MDPs) |
| TD3+BC | at , held near by the cloning term | none | nothing specific | |
| CQL | a soft maximum over all actions, pushed down | none | value lower bound for large enough ; gap expansion | |
| IQL | never | none | , | convergence to the in-support optimum as |
| SAC-N, EDAC | at , penalized by disagreement | critics | , diversity weight | no guarantee beyond the confidence-bound heuristic |
What the benchmarks show. On many D4RL locomotion datasets these methods perform broadly similarly. On AntMaze, where trajectories must be stitched, multi-step value propagation matters, and IQL and CQL are much stronger than one-step methods. The comparisons are fragile in ways worth knowing. Scores move with implementation details and with hyperparameters that were often tuned using online evaluations; a carefully re-tuned TD3+BC variant, ReBRAC (Tarasov et al., 2023), was competitive with most later methods. Brandfonbrener et al. (2021) traced much of the iterative methods' trouble to the variance of repeated off-policy evaluation, which is why one step of improvement can suffice on data from a single, fairly good policy.
Key takeaways
- Batch-constrained Q-learning restricts the maximum to logged actions and converges to the best batch-constrained policy in deterministic MDPs with coherent data; deep BCQ approximates the constraint with a generative model and small perturbations, and TD3+BC with a cloning term.
- CQL's evaluation step is policy evaluation with the penalized reward . Its value estimate falls below the truth by times discounted chi-squared divergences, and with sampling error a large enough makes it a lower bound; the penalty tracks distance from the data, not uncertainty.
- Expectiles are self-weighted means that rise monotonically to the top of the support. IQL backs up an expectile over logged actions, approaches the in-support optimum as , and never evaluates an unseen action.
- The minimum over critics is a lower confidence bound with multiplier (1.54 for ten critics). Benchmark differences among these methods are fragile, and the conservatism knob must be chosen offline.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Kumar et al.'s value lower bound for CQL with both penalty terms needs above a threshold. Which change makes that threshold larger?
- More data in every state
- A policy closer to , that is, a smaller
- Exact Bellman backups instead of empirical ones
- A smaller reward range
Show the answer
B. A policy closer to , that is, a smaller
The threshold is proportional to the sampling error divided by . A policy near the data is barely penalized, so a larger is needed to push its estimate below the truth despite sampling error. The penalty tracks distance from the data, not uncertainty.
Why does IQL fit to an expectile of over logged actions, instead of to an expectile of the TD target ?
- Because is cheaper to evaluate than the TD target
- Because the TD target is not defined for offline data
- So that the expectile ranges over actions only; over the TD target it would also favor lucky next states, scoring a risky action by its best outcomes
- So that is guaranteed to be a lower bound on
Show the answer
C. So that the expectile ranges over actions only; over the TD target it would also favor lucky next states, scoring a risky action by its best outcomes
already averages over the next state, so an upper expectile of over actions approximates a maximum over supported actions. An upper expectile of would also be optimistic about the transition's randomness, a bias that does not vanish with more data.
Why does the convergence theorem for batch-constrained Q-learning assume a deterministic MDP?
- Because Q-learning diverges in stochastic MDPs
- Because stochastic MDPs have no optimal deterministic policy
- Because the behavior model cannot represent stochastic actions
- Because in a stochastic MDP each logged next state is only a sample, so the batch defines an empirical MDP that can differ from the true one
Show the answer
D. Because in a stochastic MDP each logged next state is only a sample, so the batch defines an empirical MDP that can differ from the true one
With deterministic dynamics, one logged transition determines that pair's dynamics exactly, so restricting the maximum to logged pairs removes all extrapolation. With stochastic dynamics, the data still constrain the policy, but the values are those of the batch's empirical MDP: the model bias of Fujimoto et al.'s analysis.
Ten critics' estimates at an out-of-distribution action behave like independent Gaussians with mean 2 and standard deviation 1; at a well-covered action, mean 1.5 and standard deviation 0.1. Which action does a minimum-over-ensemble target favor, in expectation?
- The well-covered action: about 1.35 against 0.46
- The out-of-distribution action, because its mean estimate is higher
- Neither: the two expected minima are equal
- The out-of-distribution action, because the minimum is over critics, not over actions
Show the answer
A. The well-covered action: about 1.35 against 0.46
The expected minimum of 10 such estimates is the mean minus 1.54 standard deviations: for the unseen action, for the covered one. The critics' disagreement acts as the uncertainty penalty.
Further reading
- S. Fujimoto, D. Meger & D. Precup, "Off-policy deep reinforcement learning without exploration," Proceedings of the 36th International Conference on Machine Learning (ICML) (2019).
- A. Kumar, A. Zhou, G. Tucker & S. Levine, "Conservative Q-learning for offline reinforcement learning," Advances in Neural Information Processing Systems 33 (2020).
- I. Kostrikov, A. Nair & S. Levine, "Offline reinforcement learning with implicit Q-learning," International Conference on Learning Representations (ICLR) (2022).
- S. Fujimoto & S. S. Gu, "A minimalist approach to offline reinforcement learning," Advances in Neural Information Processing Systems 34 (2021).
- G. An, S. Moon, J.-H. Kim & H. O. Song, "Uncertainty-based offline reinforcement learning with diversified Q-ensemble," Advances in Neural Information Processing Systems 34 (2021).