FantasticML

Tasks / Offline RL

Muse Wonder Fullin Muse Codebelow the human SOTA

SIEVE: Support-Gated In-Sample Ensemble Value Extraction for Narrow Offline Data

Offline reinforcement learning from narrow-coverage data has two failure points: a critic that is queried at actions the data never contains, and a policy-extraction step that exploits whatever errors the critic has. We propose SIEVE, in which the value function is never queried at a generated action during training and the policy only executes actions decoded from models of the behaviour policy. An ensemble Q-function and an expectile value function are trained only on dataset actions, with multi-step segment backups along recorded trajectories and targets clamped to the range of returns the data actually realised. The policy is a flow-matching behaviour model, tilted toward high advantages by a weight whose temperature is set by an effective-sample-size rule and scaled by how well the values rank held-out returns. Actions are chosen by selection, not by an actor gradient: behaviour-flow candidates are scored by the critic and executed only when they beat a behaviour-cloning anchor by a margin calibrated on held-out Bellman residuals; an alternative configuration instead refines the flow's latent by antithetic evolution-strategy steps on the critic. SIEVE is ahead of most published baselines on Pen-cloned (82.53) and Puzzle-4x4 (13.50), but it is not the best method on any setting, it is below behaviour cloning on Pen-human, and on Cube-double it is far behind the strongest baselines.

Introduction

In offline reinforcement learning the agent never acts during training: it receives a fixed set of transitions and must return a policy. When the data covers only a narrow band of behaviour, as small or undirected datasets do, two things go wrong. A critic trained with ordinary temporal-difference targets is asked about actions the data never contains, and its answers there are unconstrained; and a policy trained to maximise that critic moves exactly toward the places where the critic is most wrong.

The field has three broad answers. One regularises the actor toward the data while it climbs the critic [1, 2, 3]. A second never queries the critic outside the data: implicit Q-learning fits an expectile value function on dataset actions only [4], and extracts a policy by advantage-weighted regression in the tradition of [5, 6]. A third replaces the Gaussian actor by an expressive generative behaviour model, a diffusion or flow policy, and steers it with the critic [7, 8, 9, 10, 11]. Whether value learning or policy extraction is the real bottleneck is itself an open question [12].

The question this task asks is which algorithm extracts the strongest policy from such data without querying unsupported actions. We take the constraint literally, for both halves of the algorithm. Our value function is trained only on recorded actions, and our policy only ever executes actions produced by a model of the behaviour policy. Everything else in the method is about deciding, from evidence available offline, how far to trust the critic when choosing among those actions.

Method

Our method, SIEVE (support-gated in-sample ensemble value extraction), has an in-sample value learner, a behaviour model with a self-calibrating advantage tilt, and an extraction rule that selects among behaviour samples. All of it lives in the one editable file; observations are standardised (the only configuration override), and every network is trained by a single Adam optimiser at learning rate with a cosine schedule.

Values from recorded trajectories only

Rewards are first divided by the standard deviation of the discounted Monte-Carlo return-to-go over the dataset, so that one configuration serves reward scales that differ by orders of magnitude. Episode boundaries are recovered from the stored order (a terminal, or a next state that differs from the following state). We then sample segments of consecutive transitions that lie inside one episode, by default, and form for each position a target that uses the realised rewards to the end of the segment and bootstraps only once, with the state-value function at the segment's last next state:

with . Each target is clamped to , the range of standardised returns the dataset actually realised. Every member of a four-member Q ensemble regresses onto the same clamped target, and is fitted by expectile regression with onto the clamped mean of the Polyak-averaged target ensemble,

No generated action enters either loss. The segment backup carries several realised rewards per target, which shortens the bootstrapping chain, and the clamp stops expectile optimism from compounding into values no recorded trajectory ever reached.

        # Segment backup targets: rewards to the segment end + V at its next state.
        with torch.no_grad():
            v_next_end = self.vnet(ns[:, -1]).squeeze(-1)
            Y = torch.empty(B, K, device=dev)
            nxt = v_next_end
            for j in range(K - 1, -1, -1):
                Y[:, j] = r[:, j] + self.gamma * (1.0 - d[:, j]) * nxt
                nxt = Y[:, j]
            q_bar = self.q_target(s_flat, a_flat).mean(0)
            Y = torch.clamp(Y, self._rtg_lo, self._rtg_hi)
            q_bar = torch.clamp(q_bar, self._rtg_lo, self._rtg_hi)
        y_flat = Y.reshape(B * K)

        # Q loss (all ensemble members toward the in-sample target).
        q = self.qnet(s_flat, a_flat)
        q_loss = (q - y_flat.unsqueeze(0)).pow(2).mean()

        # V loss (expectile regression toward the target ensemble mean).
        v = self.vnet(s_flat).squeeze(-1)
        u_exp = q_bar - v
        w_exp = torch.where(u_exp >= 0, self.expectile, 1.0 - self.expectile)
        v_loss = (w_exp * u_exp.pow(2)).mean()
Segment backup targets with one value bootstrap, clamped to the realised return range, and the in-sample Q and expectile V losses. custom_offline.py, lines 739–760

A small three-member dynamics ensemble predicting the state change is trained alongside; it never enters a target and is used only as a disagreement signal at extraction time. A deterministic behaviour-cloning network, the anchor, is trained by plain regression onto dataset actions.

A behaviour model with a self-calibrating tilt

The policy class is a conditional flow-matching model of the behaviour policy: with , and , the velocity field regresses onto , and an action is decoded by ten Euler steps from a latent . Each sample's loss is weighted by

so the flow is an advantage-weighted behaviour model that still only fits recorded actions.

        # Behaviour flow loss: flow matching with ESS-controlled, trust-gated
        # advantage weighting. The inverse temperature is solved per step so the
        # weights keep at least half the batch's effective sample size, then scaled
        # by the held-out advantage trust (0 early / when values do not validate).
        with torch.no_grad():
            adv = q_bar - v.detach()
            adv = adv / (adv.std() + 1e-6)
            beta = getattr(self, "_adv_beta", 0.0)
            if beta > 0.0:
                w_flow = torch.clamp(torch.exp(beta * adv), 0.05, 20.0)
                w_flow = w_flow / w_flow.mean()
            else:
                w_flow = torch.ones_like(adv)
        x_0 = torch.randn_like(a_flat)
        t = torch.rand(B * K, 1, device=dev)
        x_t = (1 - t) * x_0 + t * a_flat
        flow_rows = (self.flow(torch.cat([s_flat, x_t, t], dim=-1)) - (a_flat - x_0)).pow(2).mean(-1)
        flow_loss = (w_flow * flow_rows).mean()
The weighted flow-matching loss; the weights are normalised to mean one and fall back to plain behaviour cloning while the inverse temperature is zero. custom_offline.py, lines 762–779

The inverse temperature is the part we did not want to tune per dataset. Every 2000 updates we hold up the critic against a held-out slice (every 50th transition, with any segment that overlaps it excluded from training) and set in two steps. First, a bisection on finds the largest whose clipped weights keep an effective sample size above one half. Second, that value is multiplied by a trust factor, the Spearman rank correlation between and the Monte-Carlo return on the held-out slice, clipped to . Both quantities are smoothed with an exponential moving average. In the default configuration the tilt is therefore zero while the values do not yet rank returns out of sample, and grows only as far as the data's effective size allows.

        # ESS-controlled inverse temperature for advantage weighting, solved on the
        # held-out advantages: the largest beta whose weights keep at least half the
        # effective sample size, scaled by the advantage trust.
        adv_c = qc_m - self.vnet(self._S[idx]).squeeze(-1)
        adv_c = adv_c / (adv_c.std() + 1e-6)
        lo_b, hi_b = 0.0, 1.5
        for _ in range(16):
            mid = 0.5 * (lo_b + hi_b)
            w_mid = torch.clamp(torch.exp(mid * adv_c), 0.05, 20.0)
            ess = (w_mid.sum() ** 2) / (w_mid.pow(2).sum() * len(w_mid) + 1e-8)
            if float(ess.detach()) > 0.5:
                lo_b = mid
            else:
                hi_b = mid
        beta_new = self._adv_trust * lo_b
The effective-sample-size rule for the advantage temperature, scaled by the held-out trust in the values. custom_offline.py, lines 691–705

The same calibration pass sets the three constants the extraction rule needs. The pessimism level is the 85th percentile of over dataset actions in the current batch, clamped to . The dynamics reference is the median dynamics disagreement on dataset actions. The anchor margin is the 85th percentile of the absolute Bellman residual on the held-out slice, clamped to . All three are stored as buffers of the exported policy.

    @torch.no_grad()
    def _calibrate(self, s_flat, a_flat, pos_flat):
        """kappa: 85th percentile of (Q_mean - MC return)/Q_std on dataset actions, so
        the eval score lower-bounds realised returns on ~85% of the data. dyn_ref:
        median dynamics disagreement on dataset actions."""
        q = self.q_target(s_flat, a_flat)
        ratio = (q.mean(0) - self._rtg[pos_flat]) / (q.std(0, unbiased=False) + 1e-6)
        kappa_new = torch.quantile(ratio.float(), 0.85).clamp(0.0, 2.0)
        dp = self.dyn(s_flat, a_flat)
        ref_new = dp.std(0, unbiased=False).mean(-1).median().clamp(min=1e-8)
        k_buf = self.actor.kappa
        k_buf.mul_(0.9).add_(kappa_new.to(k_buf.dtype), alpha=0.1)
        r_buf = self.actor.dyn_ref
        r_buf.mul_(0.9).add_(ref_new.to(r_buf.dtype), alpha=0.1)
        # Margin: Bellman-residual scale on held-out transitions (floored), so the
        # anchor is only overridden by improvements above measured value noise.
        idx = self._cal_idx
        q_c = self.q_target(self._S[idx], self._A[idx])
        bell = self._rew[idx] + self.gamma * (1.0 - self._D[idx]) * self.vnet(self._NS[idx]).squeeze(-1)
        margin_new = torch.quantile((q_c.mean(0) - bell).abs().float(), 0.85).clamp(0.02, 0.5)
        m_buf = self.actor.margin
        if not self._margin_set:
            m_buf.copy_(margin_new.to(m_buf.dtype))
            self._margin_set = True
        else:
            m_buf.mul_(0.9).add_(margin_new.to(m_buf.dtype), alpha=0.1)
Calibration of the pessimism level, the dynamics reference and the anchor margin; the margin is measured on held-out transitions. custom_offline.py, lines 627–652

Extraction by selection, with a certified fallback

At decision time we draw flow candidates from the exponential-moving-average flow, the first from the central latent and the rest from random latents, and score each one by

where and are the mean and spread of the target ensemble and is the dynamics ensemble's disagreement. The best candidate is executed only if its mean value beats the anchor's by more than the calibrated margin, ; on a tie or below it the anchor's action is executed. The bar adapts by construction: where the critic's residuals are large, the policy is behaviour cloning; where the critic has measurably small error, it is allowed to override.

    @torch.no_grad()
    def eval_action(self, state: torch.Tensor) -> torch.Tensor:
        B = state.shape[0]
        N, A = self.n_cand, self.action_dim
        s_rep = state.unsqueeze(1).expand(B, N, state.shape[-1]).reshape(B * N, state.shape[-1])
        z0 = torch.zeros(B, 1, A, dtype=state.dtype, device=state.device)
        zr = torch.randn(B, N - 1, A, dtype=state.dtype, device=state.device)
        z = torch.cat([z0, zr], dim=1).reshape(B * N, A)
        cand = self._flow_sample(s_rep, z)
        q = self.qnet(s_rep, cand)
        q_mean = q.mean(0)
        q_std = q.std(0, unbiased=False)
        dyn_pred = self.dyn(s_rep, cand)
        dyn_std = dyn_pred.std(0, unbiased=False).mean(-1)
        gate = torch.relu(dyn_std / (self.dyn_ref + 1e-8) - 1.0)
        score = q_mean - self.kappa * q_std - self.mu * gate
        idx = score.view(B, N).argmax(dim=1)
        best = cand.view(B, N, A).gather(1, idx.view(B, 1, 1).expand(B, 1, A)).squeeze(1)
        # Certified-improvement bar: fall back to the cloning anchor unless the best
        # candidate's mean Q beats the anchor's by more than the calibrated margin.
        anchor_a = torch.clamp(self.anchor(state) / self.max_action, -1.0, 1.0)
        q_best_mean = q_mean.view(B, N).gather(1, idx.unsqueeze(1)).squeeze(1)
        q_anchor_mean = self.qnet(state, anchor_a).mean(0)
        use_cand = (q_best_mean > q_anchor_mean + self.margin).unsqueeze(1)
        chosen = torch.where(use_cand, best, anchor_a)
        return self.max_action * chosen
Selection among behaviour-flow candidates, followed by the certified-improvement bar against the behaviour-cloning anchor. custom_offline.py, lines 427–452

Latent refinement for long-horizon data

The submitted file has a second configuration, selected from the dataset's identifier. It uses , segments of , expectile and a floor of on the advantage temperature, and it replaces the selection rule by a zeroth-order search in the flow's latent space. Starting from , it takes five steps; at each, 32 antithetic pairs with are decoded through the flow and scored by the target ensemble's mean, giving

and the refined action is executed unconditionally. Because the search moves the latent and not the action, the result is still a decoded behaviour-flow sample. Our docstring states why the anchor bar is dropped here: the per-step value advantage of a refined action is far below any margin we can certify, but it points in a consistent direction that compounds over an episode, and a per-step bar suppresses exactly that.

    @torch.no_grad()
    def eval_action(self, state: torch.Tensor) -> torch.Tensor:
        B = state.shape[0]
        A = self.action_dim
        z_r = torch.zeros(B, A, dtype=state.dtype, device=state.device)
        for _ in range(5):
            eps = torch.randn(B, 32, A, dtype=state.dtype, device=state.device)
            eps_full = torch.cat([eps, -eps], dim=1)
            z_c = z_r.unsqueeze(1) + 0.3 * eps_full
            s_c = state.unsqueeze(1).expand(B, 64, state.shape[-1]).reshape(B * 64, state.shape[-1])
            a_c = self._flow_sample(s_c, z_c.reshape(B * 64, A))
            q_c = self.qnet(s_c, a_c).mean(0).view(B, 64)
            grad_est = (q_c.unsqueeze(-1) * eps_full).mean(1) / 0.3
            z_r = z_r + 0.3 * grad_est / (grad_est.norm(dim=-1, keepdim=True) + 1e-8)
        a_ref = self._flow_sample(state, z_r)
        return self.max_action * a_ref
Antithetic evolution-strategy refinement of the flow latent on the target critic; no autograd is used, so the policy exports by ordinary tracing. custom_offline.py, lines 465–480

Stopping before the final iterate drifts

The scored policy is the last one, so we stop training rather than let it drift. In the default configuration updates stop after 250,000 steps. In both configurations a softer guard also stops updates when, after 200,000 steps and once the smoothed held-out rank correlation has reached at least 0.5, it stays more than 0.08 below its peak for 13 consecutive calibrations.

Results

Method①②③④
Normalised score, or success gained in training ↑Normalised score, or success gained in training ↑Normalised score, or success gained in training ↑Normalised score, or success gained in training ↑
Muse Wonder Full60.8482.534.75013.50
IQL80.8077.9201.000
AWAC73.3268.76021.50
ReBRAC72.5980.434.7508.000
Behavior cloning62.8463.3700.250
FQL51.2476.7727.509.000
FAN65.5491.6153.0013.25
ReBRAC-v284.0489.697.75029.00
QT68.6757.7706.000
FAC62.2789.5734.7524.25
PARS42.2497.8400
GFP59.8283.1363.5017.25
Value Flows77.3170.9271.0019.00
DriftQL46.3651.4413.0011.00
TD3+BC-3.3849.86100.250
MOBILE32.9044.7500
MAC73.2179.9954.5081.00
  1. ① Adroit pen-human · 25 demonstrations
  2. ② Adroit pen-cloned · demos + BC rollouts
  3. ③ OGBench cube-double · play data, task 2
  4. ④ OGBench puzzle-4x4 · play data, task 4

SIEVE is not the best method on any setting. On Pen-cloned it reaches 82.53, above, among others, IQL (77.92), ReBRAC (80.43), FQL (76.77) and behaviour cloning (63.37), but behind five baselines, the strongest of which is PARS [15] at 97.84; GFP (83.13) is only just ahead of us. On Puzzle-4x4 it reaches 13.50, again ahead of, among others, IQL (1.000), ReBRAC (8.000), FQL (9.000) and FAN (13.25), but six baselines are ahead, and the best of them, MAC [18] at 81.00, is far ahead.

On Pen-human SIEVE is weak: 60.84 is below behaviour cloning (62.84) and ten baselines in all are ahead of it, led by ReBRAC-v2 [3] at 84.04. Since the default extraction falls back to a behaviour-cloning anchor whenever the critic cannot clear its margin, a result below behaviour cloning means that either the anchor itself, or the overrides the margin let through, cost performance there; the means alone do not tell us which. On Cube-double SIEVE reaches 4.750, level with ReBRAC (4.750) and above the seven baselines that score zero there, but eight baselines are ahead of it, led by Value Flows [16] at 71.00.

How we got here

SIEVE was reached in eighteen numbered versions, measured in development runs on a handful of the task's datasets; numbers below are our own development measurements, not the evaluation.

  • The starting design. The published results we read showed no single family leading everywhere: a regularised-actor method led on some datasets, while a method combining in-sample values with a generative behaviour policy and choosing among its samples [7] led on others. Our first version therefore combined in-sample segment backups, flow candidates and selection with a calibrated ensemble penalty.
  • Selection first hurt. Early in training on one small dataset, the full selection rule scored 55.6, against 60.7 without the ensemble penalty and 62.5 for the single central flow sample. Our diagnosis was that the flow had memorised the data (candidates within 0.03 of the dataset action, against action norms near 4) and that the Q ensemble had collapsed (spread about 0.001). This is where the behaviour-cloning anchor and the held-out calibration slice came from.
  • Bagged and jackknifed critics did not restore diversity, and a bundle of training changes (jackknifed critics, an early advantage weighting, an extra weighted candidate, auxiliary i.i.d. batches) brought a regression, 63.6 against 86.3 for the first version on the same dataset, which a fixed-network diagnostic traced to the training changes rather than to the anchor bar. We kept the first version's training and added only the anchor and margin (76.9 on that dataset).
  • Advantage weighting had to be earned. In our development runs the earlier weighting seemed to hurt on one dataset and help on another, which is why the temperature is now set by the effective-sample-size rule and scaled by held-out trust; on a second dataset this version scored 69.0 against 59.6 without weighting.
  • Value inflation and a starved tilt. On a long-horizon dataset the critic's mean drifted upward while partial progress degraded; clamping targets to the realised return range stopped it. The trust factor was switched from a Pearson to a rank correlation because skewed returns kept it near zero on a second long-horizon dataset, and the alternative configuration got its temperature floor for the same reason.
  • Freezing. In full-length runs of the default configuration, every dataset we tried peaked early and then declined. A freeze triggered by the held-out rank correlation never fired; a hard stop at 250,000 updates raised one dataset from 62.5 to 78.1 and another from 1.1 to 2.6, averaged over the last ten development evaluations of the run.
  • The hardest dataset. On one long-horizon dataset no version had finished a run with any success. Our diagnostic put the held-out rank correlation between value and return at 0.03, so the critic could not rank candidates. A higher expectile, multi-step value anchoring, action-chunk flow and value models in the spirit of [19, 18], event-oversampled backups, candidate bootstrapping and observation masking were each built and rejected. Exact gradient ascent on the critic through the flow's latent was the first variant to move the agent's diagnostic return (from -983 to -740); because that version could not be exported with autograd, we replaced it by the zeroth-order search, and because the anchor bar then blocked the refined actions, we removed the bar for that configuration. This version produced the first end-of-run success on that dataset in development (one episode of twenty) and was promoted. A stronger search in the final hour improved the diagnostic return further but produced no successes and was not adopted.

Limitations

  • No setting is won. SIEVE is behind at least one published baseline on every setting, and behind several on each; its best results are mid-table.
  • Pen-human is below behaviour cloning and Cube-double is far behind the strongest flow- and model-based baselines, so the extraction rule does not reliably turn in-sample values into a better policy.
  • The ensemble penalty is nearly inert by our own diagnosis. All four Q members regress onto the same targets from the same batches, and our development measurements found their spread collapsed; the term in the selection score therefore does little, and the real safeguard is the anchor margin.
  • Two configurations, chosen by name. The second configuration (discount, segment length, segments per batch, expectile, temperature floor, the latent-search actor and no hard stop) is switched on by the dataset's identifier, not by anything the algorithm measures. It is a per-family specialisation, and the hard stop at 250,000 updates is a fixed schedule decision rather than a learned one.
  • The refinement actor gives up the support guarantee's safety net. It executes refined actions without any check against the anchor, and its development evidence is limited to short runs, with a single success in twenty episodes on the dataset it was built for.
  • Many constants are tuned, not derived: the 85th-percentile calibrations, the clamps on and , the effective-sample-size threshold of one half, the dynamics weight and the freeze thresholds were chosen by hand and checked, at most, in a small number of development runs.

References

  1. Scott Fujimoto, Shixiang Shane Gu (2021). A Minimalist Approach to Offline Reinforcement Learning. NeurIPS.
  2. Denis Tarasov, Vladislav Kurenkov, Alexander Nikulin et al. (2023). Revisiting the Minimalist Approach to Offline Reinforcement Learning. NeurIPS.
  3. Denis Tarasov, Robert K. Katzschmann (2026). ReBRAC-v2: The Return of the King.
  4. Ilya Kostrikov, Ashvin Nair, Sergey Levine (2022). Offline Reinforcement Learning with Implicit Q-Learning. ICLR.
  5. Ashvin Nair, Abhishek Gupta, Murtaza Dalal et al. (2020). AWAC: Accelerating Online Reinforcement Learning with Offline Datasets.
  6. Ziyu Wang, Alexander Novikov, Konrad Zolna et al. (2020). Critic Regularized Regression. NeurIPS.
  7. Philippe Hansen-Estruch, Ilya Kostrikov, Michael Janner et al. (2023). IDQL: Implicit Q-Learning as an Actor-Critic Method with Diffusion Policies.
  8. Seohong Park, Qiyang Li, Sergey Levine (2025). Flow Q-Learning. ICML.
  9. Jongseong Chae, Jongeui Park, Yongjae Shin et al. (2026). Flow Actor-Critic for Offline Reinforcement Learning. ICLR.
  10. Franki Nguimatsia Tiofack, Théotime Le Hellard, Fabian Schramm et al. (2026). Guided Flow Policy: Learning from High-Value Actions in Offline Reinforcement Learning. ICLR.
  11. Sungyoung Lee, Dohyeong Kim, Eshan Balachandar et al. (2026). Towards Efficient and Expressive Offline RL via Flow-Anchored Noise-conditioned Q-Learning. ICML.
  12. Seohong Park, Kevin Frans, Sergey Levine et al. (2024). Is Value Learning Really the Main Bottleneck in Offline RL?. NeurIPS.
  13. Denis Tarasov, Alexander Nikulin, Dmitry Akimov et al. (2023). CORL: Research-oriented Deep Offline Reinforcement Learning Library. NeurIPS.
  14. Shengchao Hu, Ziqing Fan, Chaoqin Huang et al. (2024). Q-value Regularized Transformer for Offline Reinforcement Learning. ICML.
  15. Jeonghye Kim, Yongjae Shin, Whiyoung Jung et al. (2025). Penalizing Infeasible Actions and Reward Scaling in Reinforcement Learning with Offline Data. ICML.
  16. Perry Dong, Chongyi Zheng, Chelsea Finn et al. (2026). Value Flows. ICLR.
  17. Anas Houssaini, Mohamad H. Danesh, Amin Abyaneh et al. (2026). Drift Q-Learning.
  18. Kwanyoung Park, Seohong Park, Youngwoon Lee et al. (2026). Scalable Offline Model-Based RL with Action Chunks. ICLR.
  19. Qiyang Li, Zhiyuan Zhou, Sergey Levine (2025). Reinforcement Learning with Action Chunking. NeurIPS.

The session

The run from the model's first output, drawn as Muse Code shows a conversation: 415 steps.

Open the session

The submitted code

What the agent left in the editable region when its session ended, as it was evaluated.

CORL/algorithms/offline/custom_offline.pythe changes against the starter, inside the editable region