Conservative Q-learning

Also known as: CQL

On this page 7

Conservative Q-learning (CQL) is an offline reinforcement learning algorithm that learns a deliberately pessimistic Q-function from a fixed dataset by pushing down the values of actions the data does not support and pushing up the values of actions it does. The result is a value estimate that, under stated assumptions, lower-bounds the true value of the learned policy, which prevents the overestimation that breaks standard off-policy methods when no new data can be collected.

CQL was introduced in 2020 by Aviral Kumar, Aurick Zhou, George Tucker and Sergey Levine. It became one of the reference baselines for offline reinforcement learning because it is simple to add to existing actor-critic or Q-learning code and performs well on standard benchmarks such as D4RL.

Why offline Q-learning needs conservatism

In offline reinforcement learning, the agent learns only from a logged dataset collected by some behavior policy and cannot explore. Standard Q-learning computes Bellman targets with a maximum over actions, and that maximum often selects out-of-distribution actions whose Q-values were never trained against real outcomes.

Errors on those actions are not corrected, because the agent never tries them. The maximization then amplifies overestimation through bootstrapping, and the learned policy drifts toward actions that look excellent only because the critic is wrong. This distributional shift is the central failure mode that CQL targets.

SettingCan errors be correctedTypical outcome without safeguards
Online Q-learningYes, through explorationOverestimation is self-limiting
Off-policy with replayPartly, as new data arrivesModerate bias, usually manageable
Offline learningNo new data at allSevere divergence of Q-values
Effect of the data regime on value estimation errors

How the CQL objective works

CQL keeps the usual Bellman error term and adds a conservative regularizer weighted by a coefficient α. The regularizer minimizes Q-values under a distribution that favors high-value actions and maximizes Q-values on the actions actually present in the dataset.

In its most widely used form, CQL(H), the penalty is the difference between log Σ_a exp Q(s, a) and the dataset term E_(s,a)~D [Q(s, a)]. The log-sum-exp acts as a soft maximum over all actions, so the penalty grows whenever an unseen action is assigned a higher value than the logged ones. The full objective is the penalty multiplied by α plus the standard temporal difference loss.

ComponentExpressionPurpose
Push-down termlog Σ_a exp Q(s, a)Lowers values of unsupported actions
Push-up termE_D [Q(s, a)]Preserves values of logged actions
Weight αFixed or tuned by LagrangeControls the degree of pessimism
Bellman error(Q − target)²Fits values to observed transitions
Threshold τTarget penalty gapSets α automatically in CQL-Lagrange
Main components of the CQL loss

With a sufficiently large α, theory shows that the expected learned value is a lower bound on the true policy value. In practice the bound is approximate, but the gap between in-distribution and out-of-distribution values is what keeps the policy close to the data.

Variants and implementation choices

CQL is a regularizer rather than a complete architecture, so it is combined with different base learners. For continuous control, it is typically built on soft actor-critic, with the log-sum-exp approximated by sampling actions from a uniform distribution and from the current policy. For discrete actions, such as Atari games, it is added to DQN-style or QR-DQN critics, where the log-sum-exp is computed exactly.

  • CQL(H) uses the entropy-regularized soft maximum and is the default variant.
  • CQL(ρ) replaces it with a KL penalty toward a previous policy.
  • CQL-Lagrange tunes α automatically so the penalty gap stays near a target τ.
  • Cal-QL calibrates the conservative values for later online fine-tuning.

The most sensitive hyperparameter is α or its threshold τ. Values near 1 to 10 are common on locomotion tasks, while narrow expert datasets often need stronger conservatism than broad, noisy ones.

CQL compared with other offline methods

Offline algorithms differ mainly in where they apply pessimism: on the policy, on the value function or on the Bellman backup. CQL acts on the value function directly, which distinguishes it from methods that constrain the policy.

MethodMain mechanismStrengthWeakness
BCQGenerative model limits candidate actionsStrong policy constraintNeeds a good behavior model
BEARKernel divergence to behavior policySupport-level matchingSensitive kernel settings
TD3+BCBehavior cloning term in actor lossVery simple, fastLimited on poor datasets
IQLExpectile regression, no unseen actions queriedStable and efficientLess pessimism control
CQLPenalizes unseen action valuesRobust on mixed dataSlower, sensitive to α
Conservative Q-learning and related offline algorithms

Limitations and practical pitfalls

Conservatism has a cost. An overly large α makes the policy behave almost like behavior cloning and prevents it from improving on the dataset. An overly small α reintroduces overestimation. Because offline training provides no reliable online signal, offline policy evaluation or a small validation budget is needed to choose settings.

Further pitfalls include the extra compute for action sampling in continuous spaces, poor performance when the dataset covers good behavior only sparsely, and slow progress during online fine-tuning, because the critic starts with values that are systematically too low.

The table below links the most common symptoms seen in CQL training runs to their usual causes and to practical remedies.

SymptomLikely causeRemedy
Policy only imitates the dataα set too highLower α or raise threshold τ
Q-values grow without limitα set too lowIncrease α or use CQL-Lagrange
Slow online fine-tuningUnderestimated initial valuesUse calibrated variants such as Cal-QL
Unstable continuous trainingToo few sampled actionsSample more actions per state
Poor results on narrow dataSparse coverage of good actionsCollect broader or mixed datasets
Diagnosing common CQL training problems

A common misconception is that CQL makes a policy safe in the broader sense of safe reinforcement learning. It reduces value overestimation from missing data, but it does not enforce explicit constraints, and it cannot correct errors in the dataset itself.

Explained without jargon

Imagine learning to drive only by watching recorded trips. You cannot test new moves yourself. Some untried moves might seem brilliant on paper. In reality they could be disasters.

Conservative Q-learning adds healthy skepticism. It assumes that anything not shown in the recordings is probably worse than it looks. The learner sticks mostly to proven behavior and improves it carefully. It does not gamble on guesses.

A typical use case

A logistics company wants a warehouse robot arm to pick mixed items faster, but trial-and-error learning on the live line would risk damaged goods. The team instead collects about 200,000 logged grasp attempts from earlier scripted controllers and human teleoperation, including both successes and failures.

Engineers train a soft actor-critic agent with the CQL regularizer and tune the Lagrange threshold on a held-out set of logged episodes. A plain off-policy critic trained on the same data predicts very high values for unusual grasp angles and fails most test picks. The CQL policy stays near grasps the data supports, and in a short supervised trial it achieves a higher success rate than the best scripted controller while producing no unsafe motions.