← Haoran Xu

Uni-RL: Unifying Online and Offline RL via Implicit Value Regularization

Haoran Xu*1, Liyuan Mao*2, Hui Jin*3, Weinan Zhang2, Xianyuan Zhan4, Amy Zhang1

1UT Austin 2Shanghai Jiao Tong University 3Nanyang Technological University 4Tsinghua University

NeurIPS 2025/* equal contribution

Uni-RL is one off-policy algorithm for online, offline and offline-to-online RL. It regularizes the value function toward a reference policy: the dataset behavior offline, and a slowly updated target policy online, which turns the regularizer into an implicit trust region that stays off-policy. Policies are extracted with an in-sample policy gradient that only uses actions from the reference policy.

Three rows over training time. Offline: the reference policy is the dataset behavior, fixed. Online: the reference policy is a target policy that is soft-updated toward the current policy, shown as a chain of increasingly dark purple snapshots. Offline-to-online: the dataset behavior until online training starts, then the moving target policy.

One objective, three settings

Online methods such as PPO and SAC struggle with offline data, offline methods such as CQL and IVR are over-conservative once online access is available, and offline-to-online methods need setting-specific designs. Uni-RL starts from a single constrained problem with a reference policy \(\mu\):

$$\pi^* = \arg\max_\pi\ \mathbb{E}_{(s,a)\sim d^\pi}\big[r(s,a)\big] \quad\text{s.t.}\quad \mathbb{E}_{s\sim d^\pi}\Big[D_f\big(\pi(\cdot|s)\,\|\,\mu(\cdot|s)\big)\Big]\le\epsilon .$$

Its Lagrangian is a behavior-regularized MDP in which the penalty \(\alpha\, g\big(\pi/\mu\big)\) enters the reward, so the regularization acts on the value rather than on the policy. The setting only decides what \(\mu\) is:

In-sample value learning

By duality, as in IVR, the regularized optimal values solve two regression problems that only need samples from \(\mu\):

$$\min_V\ \mathbb{E}_{s\sim\mathcal D,\ {\color{#5B2C8A}a\sim\mu}}\Big[V(s) + \alpha\, f_{\mathrm{IVR}}\big((Q(s,a)-V(s))/\alpha\big)\Big],$$ $$\min_Q\ \mathbb{E}_{(s,a,s')\sim\mathcal D}\Big[\big(r(s,a)+\gamma V(s')-Q(s,a)\big)^2\Big],$$

with \(f_{\mathrm{IVR}}(x)=\exp(x)\) for the KL divergence and \(\mathbb{I}(x>-2)(x^2/4+x+1)\) for \(\chi^2\). Neither \(\pi(a|s)\) nor \(\mu(a|s)\) is ever evaluated, so the policy can be a diffusion or flow model, and offline the dataset actions are the samples from \(\pi_{\mathcal D}\).

Why plain IVR fails online

Online, the replay buffer contains many early, sub-optimal transitions. Regularizing toward the buffer's behavior anchors the value to that data, much like offline RL on a poor dataset. Uni-RL instead regularizes toward a target policy that keeps improving:

$$\min_V\ \mathbb{E}_{s\sim\mathcal D,\ {\color{#5B2C8A}a\sim\bar\pi}}\Big[V(s) + \alpha\, f_{\mathrm{IVR}}\big((Q(s,a)-V(s))/\alpha\big)\Big],\qquad \bar\pi \leftarrow \lambda\pi + (1-\lambda)\bar\pi .$$

A 1-D illustration: each iteration solves the regularized problem in closed form against the current reference.

The real runs show the same effect, for both weighted BC and MaxQ policy extraction:

Four learning curves over 0.5M gradient steps for two policy extraction methods, weighted BC and MaxQ. With the reference policy set to the target policy, both the score and the Q value grow much higher than with the reference set to the replay-buffer behavior.
Online IVR with \(\mu=\pi_{\mathcal D}\) (orange) vs. \(\mu=\bar\pi\) (purple): score (top) and Q value (bottom).

This is a trust-region update, but one imposed through the value function: the policy update itself never needs on-policy samples. Uni-RL is therefore off-policy, unlike TRPO and PPO, and in offline-to-online RL it relaxes the dataset constraint gradually instead of dropping it at once.

Using \(\bar\pi\) as the reference gives an off-policy trust region and removes IVR's online over-conservatism.

In-sample policy gradient

The regularized optimum has a closed-form ratio to the reference policy, \(w^*_{\mathrm{IVR}}(s,a) = \pi^*/\mu = \max\big\{0,(f')^{-1}\big((Q^*-V^*)/\alpha\big)\big\}\). The two usual ways to extract it each give something up:

InPG keeps the weighted-BC form and treats the weights as free variables. It picks the non-negative weights whose BC gradient is closest to the policy gradient:

$$w^*_{\mathrm{InPG}} = \arg\min_{w\ge 0}\ \mathbb{E}_{s\sim\mathcal D}\Big[\big\|G_{\mathrm{PG}} - G_{\mathrm{BC}}(w)\big\|^2\Big],$$ $$G_{\mathrm{PG}} = \nabla_\theta\mathbb{E}_{a\sim\pi_\theta}\big[Q(s,a)\big],\quad G_{\mathrm{BC}}(w) = \mathbb{E}_{a\sim\mu}\big[w(s,a)\,\nabla_\theta\log\pi_\theta(a|s)\big].$$
Vector diagram. Per-sample behavior-cloning gradients span a shaded cone of directions reachable with non-negative weights. The policy gradient points outside the cone. Weighted BC with IVR weights points into the middle of the cone. The InPG gradient is the projection of the policy gradient onto the cone.

We parameterize \(w\) with a network, train it on this L2 loss, clip it at zero, and extract the policy with \(\max_\pi \mathbb{E}_{a\sim\mu}\big[{\color{#5B2C8A}w^*_{\mathrm{InPG}}}\log\pi(a|s)\big]\). Every BC action comes from \(\mu\), so the update stays inside the reference support, while the weights now follow the value gradient.

Two scatter plots of 2-D velocity actions on maze2d-umaze, with dataset actions in gray. Weighted BC actions (orange) spread over the whole square; InPG actions (purple) concentrate on the boundary of the action space.
maze2d-umaze actions: weighted BC with \(w^*_{\mathrm{IVR}}\) (left) vs. InPG (right); dataset actions in gray.

On maze2d-umaze, weighted BC stays centered on the dataset distribution, while InPG picks out the better actions near the boundary of the action space.

Uni-RL
  1. Update \(V\) with \(a\sim\mu\), and \(Q\) by TD regression on \(V(s')\).
  2. Fit the InPG weights \(w\) with \(a\sim\mu\), then update \(\pi\) by \(w\)-weighted BC (or flow / diffusion matching).
  3. Offline: \(\mu=\pi_{\mathcal D}\). Online: explore with \(\pi\), store the data, and use \(\mu=\bar\pi\) with \(\bar\pi\leftarrow\lambda\pi+(1-\lambda)\bar\pi\).

Online RL

Eight environments from Gym, PyBullet and DMControl; Gaussian policies for every method; 0.5M steps, 5 seeds. Uni-IVR in the legends is Uni-RL.

Eight learning curves comparing Uni-RL with MPO, PPO, SAC and TD3 on AntBulletEnv, BipedalWalker, finger-turn_hard, HalfCheetah, Hopper, Humanoid, quadruped-walk and Walker2d. Uni-RL is highest or tied for highest on all of them, with large margins on finger-turn_hard and quadruped-walk.

Uni-RL is more sample-efficient than both off-policy methods without a trust region (SAC, TD3, MPO) and the on-policy trust-region method PPO. The margin is largest on the hard DMControl tasks finger-turn_hard and quadruped-walk.

Offline RL: D4RL

Normalized scores at the end of training, 5 seeds. Standard deviations and more baselines are in the paper.

Grouped bars of mean normalized score over six D4RL dataset groups. Left: IVR vs. Uni-RL with a Gaussian policy; Uni-RL is higher or tied on every group, most on medium (69 to 79) and antmaze-large (53 to 60). Right: IDQL vs. Uni-RL with a diffusion policy; Uni-RL is higher on every group.
Mean score per dataset group; MuJoCo groups average halfcheetah, hopper and walker2d.

Offline, Uni-RL's value objective reduces to IVR's, so the gain from IVR's 79 to 83 with the same Gaussian policy class reflects better policy extraction. A diffusion policy raises the mean to 87, above Diffusion-QL and IDQL (both 81).

Against prior methods

IQLIVRDiffusion-QLIDQLUni-RL GaussianUni-RL Diffusion
MuJoCo 9 datasets77.883.387.982.187.590.5
AntMaze 6 datasets63.871.869.679.177.282.6
All 15 datasets72.278.780.680.983.487.4

Offline-to-online RL

Online fine-tuning after 250k offline steps on Adroit and AntMaze, 5 seeds.

Eight fine-tuning curves comparing Uni-RL with Cal-QL, AWAC, RLPD and IQL on four Adroit cloned tasks and four AntMaze tasks. Uni-RL ends highest on seven of the eight tasks and starts from a strong offline policy without an initial drop.

Methods constrained to the dataset (IQL, AWAC) barely improve on the pretrained policy, Cal-QL inherits CQL's difficulty on Adroit and large AntMaze, and RLPD, which skips pretraining, learns slowly where the offline data is good. Uni-RL fine-tunes without an early drop and ends highest on every task except pen-cloned.

Takeaways

  1. Regularize the value toward a reference policy, and let the setting choose the reference: the dataset offline, a target policy online.
  2. A moving target policy turns the regularizer into an implicit, off-policy trust region.
  3. In-sample policy gradient projects the policy gradient onto weighted BC: mode-seeking, in-support, and usable with any generative policy.

BibTeX

@inproceedings{xu2025unirl,
  title     = {Uni-RL: Unifying Online and Offline RL via Implicit Value Regularization},
  author    = {Xu, Haoran and Mao, Liyuan and Jin, Hui and Zhang, Weinan and
               Zhan, Xianyuan and Zhang, Amy},
  booktitle = {Advances in Neural Information Processing Systems},
  year      = {2025}
}

IVR: Xu et al., ICLR 2023 · IQL: Kostrikov et al., ICLR 2022 · Diffusion-QL: Wang et al., ICLR 2023 · IDQL: Hansen-Estruch et al., 2023 · Cal-QL: Nakamoto et al., NeurIPS 2023 · RLPD: Ball et al., ICML 2023 · AWAC: Nair et al., 2020 · MPO: Abdolmaleki et al., ICLR 2018 · PPO: Schulman et al., 2017 · D4RL: Fu et al., 2020