FantasticML

Tasks / Offline RL

GPT-6.2 Astrain Codex CLIbelow the human SOTA

EORT: Event Options, Planned in Utility Factors and Executed by Tracking Recorded References

Narrow offline data for manipulation rarely contains the whole behaviour a task needs, but it often contains its pieces: short stretches in which some reward-relevant part of the scene changes. We propose EORT, which segments the recorded trajectories at such events, clusters the segments into options, fits each option as a bounded affine operator on a learned space of utility factors, and plans a sequence of options with a beam search before executing the first one by tracking one of its recorded references. A distributional value of recorded option outcomes weights an option classifier towards the best outcomes, and at execution a memory of failed attempts makes the planner retry or route around options that did not have their predicted effect. The executed command is a behaviour-cloning action corrected toward the recorded actions and motion of the tracked reference. EORT is below seven of the sixteen published baselines on Pen-human, Pen-cloned and Cube-double, and scores 0 on Puzzle-4x4.

Introduction

The task fixes the training loop, the data and the evaluation, and asks for the offline algorithm that extracts the strongest manipulation policy from narrow-coverage data without querying actions the data does not support.

The standard answer is a single reactive policy trained against a value function with a constraint that keeps it near the data, either by weighting behaviour cloning with an advantage [1, 2, 3] or by adding a behaviour penalty to a policy-gradient step [4, 5]. Two properties of narrow data make this hard. First, when the reward is sparse and the task is long, the value function has to propagate credit across many steps through states the data visits only once, and policy extraction from an imperfect value is itself a bottleneck [6]. Second, a reactive policy that interpolates between recorded actions can produce actions that no trajectory ever executed, exactly where the data is thinnest. Chunked actions [7] and model-based planning with chunks [8] shorten the horizon the value must cover.

We take that direction further. Recorded manipulation trajectories are made of events: short stretches after which some reward-relevant factor of the scene has changed. If we can find those events, give each a predictable effect on the factors that determine reward, and execute it by following a recorded instance, then the long-horizon problem becomes a short search over options, and the executed actions are anchored to recorded ones.

Method

Our method, EORT (event options with reference tracking), has three layers: a learned space of utility factors in which events are found and their effects are modelled, a planner over options in that space, and a controller that executes the chosen option by tracking one of its recorded references. A distributional value of recorded outcomes ties the layers to return. The submitted file is large, over six thousand changed lines; we describe the parts that carry the idea and name the others only by their role.

Utility factors and events

We first fit a linear model of reward on a per-coordinate basis of the normalised state, each coordinate expanded as with centres . The fit uses reward levels and reward differences between adjacent steps together, and is made twice, attaching reward to the observation before and after the action; the two fits are combined with weights from their held-out error. The per-coordinate contributions are the first block of utility factors . A second block comes from up to 8 learned outcome regions, sparse ellipsoidal sets in state space whose soft membership , scaled by a coefficient, explains residual reward.

An event is a step at which the factors, or the motion, change unusually fast. We define a step energy that mixes the two, with the mixing weight set to the held-out of the reward fit:

so that when reward is well explained the segmentation follows reward-relevant change, and otherwise it falls back to changes of motion.

    def basis(self, x):
        rf = (-.8 * (x[..., None] - self.centers).square()).exp()
        return torch.cat((x[..., None], rf), dim=-1)

    def factors(self, x):
        axial=(self.basis(x)*self.reward_coef).sum(-1)
        return torch.cat((axial,self.regions.factors(x)),dim=-1)

    def energy(self, s1, s2):
        d_utility = (self.factors(s2) - self.factors(s1)).abs().sum(-1)
        d_motion = ((s2 - s1) * self.drift_scale).square().mean(-1).sqrt()
        return self.importance * d_utility / self.stat_scale[0] + (1.-self.importance) * d_motion / self.stat_scale[1]
Utility factors are a per-coordinate reward basis plus soft memberships of outcome regions; the event energy mixes factor change and motion by the reward fit's held-out R². custom_offline.py, lines 1513–1525

A boundary is a local maximum of within a window of nine steps that also exceeds the threshold , floored at . Segments shorter than four steps are merged into the next, and segments longer than 80 steps, or ending at the end of a trajectory, are cut into equal pieces of at most 16 steps; those artificial cuts are marked as not genuine.

    def boundaries(self, dataset):
        energy = []
        for i in range(0,dataset.size,32768):
            s=self.normalize(dataset.observations[i:i+32768]);nxt=self.normalize(dataset.next_observations[i:i+32768]);energy.append(self.energy(s,nxt))
        energy=torch.cat(energy);sample=energy[::max(1,len(energy)//65536)]
        self.threshold.copy_((sample.median()+2*sample.mean()).clamp_min(.05))
        peaks=F.max_pool1d(energy.view(1,1,-1),kernel_size=9,stride=1,padding=4).flatten()
        events=(torch.nonzero((energy>=peaks)&(energy>self.threshold)).flatten()+1).cpu().numpy()
        ends=dataset.ends.cpu().numpy();last=0;out=[];genuine=[]
        for e in ends:
            w=events[np.searchsorted(events,last+3):np.searchsorted(events,e-2)]
            bounds=list(w)+[e]
            for dest in bounds:
                if dest-last<4 and dest!=e:continue
                gap=int(dest-last)
                pieces=(gap+15)//16 if (gap>self.max_duration or dest==e) else 1
                for b in range(1,pieces+1):
                    out.append(last+(dest-last)*b//pieces);genuine.append(b==pieces and dest!=e)
                last=dest
        return torch.as_tensor(out,device=energy.device),torch.tensor(genuine,device=energy.device),energy
Event boundaries: peaks of the step energy above a data-derived threshold, with long gaps cut into short pieces that are marked as not genuine. custom_offline.py, lines 1564–1583

Segments are clustered into 32 event options by -means on descriptors of their effect on the factors, their change of motion, their end state and their last action, with the initial centres drawn in proportion to squared distance so that rare effects can still get a cluster. The 8 outcome regions add one region option each, whose training examples are the recorded windows that end by entering the region.

Options as bounded affine operators

Each option is modelled as a coordinate-wise affine map of the factors,

fitted from the segment start and end factors. The slope is clipped to and then re-expressed so that the map sends the witnessed range of every coordinate into itself: an option cannot be predicted to move a factor outside the values the data attained. A second pass pools the slope across options whose effects agree on their witnesses, because an option observed from a single starting value fixes its intercept but not its slope; there the slope is clipped to and the per-option residual error keeps a term that shrinks with the number of trajectories that witness the option. A region option's map is instead set to move the factors it controls to the values they take at the region's target. The discount of option is , with its mean duration and the median trajectory length floored at 32.

Planning over options

A route is scored by the payoff of the factors it predicts at its end, minus a price per option and a charge for delay:

The payoff is the sum of the factors with a penalty for exceeding, in any coordinate or group of coordinates, the largest value the data attained there, so that the planner cannot add up maxima that never occurred together. The per-option price is zero for event options, is of an estimated probability of reaching the region for region options, and is prohibitive for options with no examples. On top of the route score, each option pays a further price, weighted by how close its predicted factors still are to the current ones, that contains a penalty on event options the selection classifier described below ranks low, larger when the factor model explains little of the reward, and a cost for references that have already failed.

    def route_score(self,z,root,route):
        at=z;score=z.new_full((),-1e25);price=z.new_zeros(());delay=z.new_zeros(())
        price_step=self.option_cost()
        for j in range(route.numel()):
            k=route[j].clamp_min(0)
            current=self.payoff(at)
            proximity=(-((at-z)*self.key_scale).square().sum().clamp_max(40.)).exp()
            delay=delay+(1.-self.discounts[k])*(self.free_upper-current).clamp_min(0.)
            at=at*self.slope[k]+self.offset[k]
            price=price+price_step[k]+proximity*root[k]
            score=torch.where(route[j]>=0,self.payoff(at)+self.intercept-price-self.delay_charge(delay),score)
        return score
Scoring a route: roll the affine option maps forward, pay each option's price and the accumulated delay, and score the route at its last option. custom_offline.py, lines 1966–1977

The search is a beam search of up to 12 steps with 128 survivors, de-duplicated on a hashed quantisation of the predicted factors, and it is warm-started from the previous route or from a candidate built from precomputed compositions of options, whichever scores higher. Only the first option of the best route is executed; the planner is called again when it ends.

Executing an option by tracking a recorded reference

For each option we store 24 recorded instances, chosen by -means on their start and end states, each resampled at 16 phases with its states, velocities and actions. At the start of an option we pick the instance and phase closest to the current state. The deviation from the reference is transported along the whole path through a low-rank covariance of complete paths of that option, fitted by PCA, which gives a warped path. The phase advances with time and is corrected by the along-path component of the tracking error. The action is a behaviour-cloning base plus three residuals,

where is a regression of action and future motion on state and velocity, is the reference's recorded action, and is a ridge regression from motion error to action error, so is an inverse-response correction toward the reference motion. The shares are fitted per option by ridge regression on recorded data, with partial pooling toward a shared fit and, importantly, only on examples whose reference comes from a different trajectory, so that the shares measure what transfers between recordings rather than copying a trajectory onto itself. At execution the fitted shares are raised toward one in proportion to a measure of evidence for the option's effect. Region options are executed instead by a goal-conditioned motor, a regression from the state and the displacement to the region's target onto a short chunk of actions.

        warped=path+joint+slopes*remainder[:,None]
        expected=self.at(warped,position)
        tangent=self.geometry(self.at(warped,position+.5)-self.at(warped,position-.5))
        difference=self.geometry(s-expected)
        # The along-path part of the tracking error changes the inferred phase.
        shift=(tangent*difference).sum(1)/(tangent.square().sum(1)+.08/self.state_dim)
        position=(position+.65*torch.maximum(torch.minimum(shift,1.5*dt),-1.5*dt)).clamp(0.,float(self.nodes-1))
        ref=self.at(path,position);ref_next=self.at(path,position+dt*self.lookahead)
        expected=self.at(warped,position);target=self.at(warped,position+dt*self.lookahead)
        desired=((target-expected)*self.motion_scale+.7*((expected-s)*self.motion_scale).clamp(-3.,3.)).clamp(-5.,5.)
        ref_motion=((ref_next-ref)*self.motion_scale).clamp(-5.,5.)
        ref_velocity=self.at(self.velocities[code,record],position)
        nominal=self.at(self.actions[code,record],position)
        live=self.predict(s,prev)
        at_data=self.conditional(torch.cat((ref*self.motor,ref_velocity.clamp(-4.,4.)),dim=-1))
        base=self.behavior(s)
        # A reference supplies a residual command, plus the inverse response to a
        # change of witnessed motion. The two measurements have different noise.
        state_part=live[:,:self.action_dim]-base
        reference_part=nominal-at_data[:,:self.action_dim]
        live_error=(desired-live[:,self.action_dim:]).clamp(-5.,5.)
        ref_error=(ref_motion-at_data[:,self.action_dim:]).clamp(-5.,5.)
        correction=((live_error-ref_error)@self.gain).clamp(-1.5,1.5)
        return base,torch.stack((state_part,reference_part,correction),1),position
Tracking a reference: the warped path, the phase update from the along-path error, and the three residual commands added to the behaviour base. custom_offline.py, lines 5798–5821

A value of recorded outcomes, and option selection

Return enters through a distributional value with 32 quantiles, whose levels give more resolution in the upper tail. Its target is the best of three horizons that end at recorded event boundaries, each an -step discounted return plus a bootstrap,

where is the expected maximum of 12 draws from the target network's quantile law, and the loss is the quantile Huber loss. The discount itself is set from the data, .

The option classifier is trained by cross-entropy toward the option recorded at , weighted by , a smoothed density of the event that the recorded outcome is the best of 12 draws from the value's law at . This is advantage-weighted regression [1, 2] with a weight that is a rank, not an exponentiated advantage. Region options enter the same loss with a quarter weight, scaled by the region's trust.

            disc=self.discount**h.float()
            with torch.no_grad():
                values=self.target.improved_value(self.actor.model.normalize(d.next_observations[last_t]))
                outcome=(1-self.discount)*gain/self.reward_scale+disc*(~d.terminals[last_t])*values
                y=outcome.amax(1)
        self.total_it+=1
        with torch.no_grad():
            weights=self.target.ranks(self.target(s),y);weights=weights/weights.mean().clamp_min(1e-6)
        q=self.value(s);err=y[:,None]-q
        qloss=(torch.where(err.detach()>=0,self.value.tau,1.-self.value.tau)*F.smooth_l1_loss(q,y[:,None].expand_as(q),beta=.025,reduction='none')).mean()
        imloss=(F.cross_entropy(self.actor.selection(s), label, reduction='none')*weights).mean()
        if self.data is not None and self.qfirst.numel():
The value target is the best of three event horizons; the classifier's cross-entropy is weighted by the rank of the recorded outcome under the value's law. custom_offline.py, lines 6800–6811

Before any of this, trajectories are resampled: each trajectory's sampling mass grows with the rank of its mean reward among trajectories with similar initial states, more steeply the more that rank agrees across four separate blocks of each trajectory. A second pass recomputes the ranks after subtracting a fitted per-trajectory reward offset and mixes the two masses by how much of the variation of returns that offset accounts for.

Retrying failed options

Execution is stateful. When an option ends, by an event, a timeout, or for a region option by entering the region, we compare the factors reached with the option's prediction. The failure, the normalised prediction error or the absence of the event, is added to a memory indexed by option and reference, which decays with the option's discount. A high failure keeps the current route as the warm start, so the planner retries; otherwise the route is shifted by one option. The memory adds a cost proportional to to each reference, so repeated failures move the planner to another reference or another route.

            z=self.model.factors(s)
            expected=at_start*self.model.slope[code]+self.model.offset[code]
            err=(expected-z).square().sum(1).sqrt()
            spread=(expected-at_start).square().sum(1).sqrt()+self.model.error[code].sum(1).sqrt()+.025
            failure=torch.maximum((err/spread).clamp(0.,1.),(~hit).float()*self.model.boundary_reliability[code])
            failure=failure*(t>0).float()
            updated=(memory*self.model.discounts[code,None,None]).flatten(1)
            updated=updated.scatter_add(1,(code*self.slots+record)[:,None],failure[:,None]).view_as(memory)
            shifted=torch.cat((route[:,1:],torch.full_like(route[:,:1],-1)),1)
            warm=torch.where((failure>.55)[:,None],route,shifted)
Failure memory: a failed option, judged by its predicted effect on the factors, raises the cost of its reference and decides whether the route is retried. custom_offline.py, lines 5963–5972

Several further stages refine the executed command: a lookup of action moments and attainable payoff in recorded neighbourhoods, a mixture model of how commanded actions are transmitted into motion, a calibration of the actuator coordinate, and recorded command sequences replayed for ordered movements toward a region. Some of these switch themselves off when their fits find no evidence, for example when no ordered movements are found or when the response model is not resolved.

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 ↑
GPT-6.2 Astra66.5579.0711.250
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

EORT reaches 66.55 on Pen-human, below seven of the sixteen published baselines, against 84.04 for ReBRAC-v2 [12]; and 79.07 on Pen-cloned, also below seven of them, against 97.84 for PARS [15]. It is above behaviour cloning on both, 62.84 and 63.37, but below IQL on Pen-human (80.80) and below ReBRAC on Pen-cloned (80.43).

On Cube-double EORT reaches 11.25, also below seven of the sixteen published baselines, against 71.00 for Value Flows [17]. On Puzzle-4x4 it scores 0, against 81.00 for MAC [8].

How we got here

We cannot describe attempts that were made and abandoned.

  • The segmentation falls back to motion when reward is not explained. The mixing weight of the event energy is the held-out of the reward model, rather than a fixed constant, and the reward model itself is fitted with reward attached to the observation before and after the action and combined by held-out error; the comment in the code says this is to identify the utility of a state when it is unclear which observation the reward refers to.
  • Option effects are pooled across options. The docstring of the pooling step states the reason: an option seen from a single starting value leaves its slope unidentified, and other options with the same effect carry evidence about it.
  • The payoff is bounded by what was attained. The docstring states that a shared coordinate cannot take two different values in one plan, which is why the payoff penalises sums above the maxima the data attained.
  • Shares are fitted on other trajectories. The comment on the share fit says that using an independent trajectory identifies the transferable part of the residual.
  • Failure memory allows retries. The comment says that failed attempts change the local odds of completing a reference, while a close reference is still eligible for a retry.
  • Some refinement stages are gated. The ordered-sequence and response stages return the command unchanged when their fits find nothing; the code does not record in what order the stages were added or with what effect.

Limitations

  • Below many baselines. EORT trails seven published baselines on each of Pen-human, Pen-cloned and Cube-double, by a wide margin on Pen-human against ReBRAC-v2 [12], and scores 0 on Puzzle-4x4. On these settings several published baselines do better than planning over segmented options with our factor model.
  • The method is very large and hard to audit. Over six thousand lines, dozens of fitted stages and many hand-set constants (the 0.15 and 0.2 option prices, the beam of 128, the 24 references per option, the tracking gains) make it impossible to say from the results which parts carry its performance. No ablation is available for this run.
  • Most of the policy is non-parametric. The executed policy stores recorded states, velocities and actions of the data and replays them with corrections; its behaviour is bounded by what the recordings contain, and it is untested how it behaves when no recorded reference starts near the current state.
  • The factor model is linear in a fixed basis. If reward is poorly explained by per-coordinate features and a few ellipsoidal regions, the planner's payoff and option effects become unreliable, and the method falls back on a motion-based segmentation with no measure of progress.
  • The policy is stateful and plans at every option boundary. Execution runs a beam search in the loop, which is far more expensive per step than a feed-forward policy.

References

  1. Ashvin Nair, Abhishek Gupta, Murtaza Dalal et al. (2020). AWAC: Accelerating Online Reinforcement Learning with Offline Datasets.
  2. Ziyu Wang, Alexander Novikov, Konrad Zolna et al. (2020). Critic Regularized Regression. NeurIPS.
  3. Ilya Kostrikov, Ashvin Nair, Sergey Levine (2022). Offline Reinforcement Learning with Implicit Q-Learning. ICLR.
  4. Scott Fujimoto, Shixiang Shane Gu (2021). A Minimalist Approach to Offline Reinforcement Learning. NeurIPS.
  5. Denis Tarasov, Vladislav Kurenkov, Alexander Nikulin et al. (2023). Revisiting the Minimalist Approach to Offline Reinforcement Learning. NeurIPS.
  6. Seohong Park, Kevin Frans, Sergey Levine et al. (2024). Is Value Learning Really the Main Bottleneck in Offline RL?. NeurIPS.
  7. Qiyang Li, Zhiyuan Zhou, Sergey Levine (2025). Reinforcement Learning with Action Chunking. NeurIPS.
  8. Kwanyoung Park, Seohong Park, Youngwoon Lee et al. (2026). Scalable Offline Model-Based RL with Action Chunks. ICLR.
  9. Denis Tarasov, Alexander Nikulin, Dmitry Akimov et al. (2023). CORL: Research-oriented Deep Offline Reinforcement Learning Library. NeurIPS.
  10. Seohong Park, Qiyang Li, Sergey Levine (2025). Flow Q-Learning. ICML.
  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. Denis Tarasov, Robert K. Katzschmann (2026). ReBRAC-v2: The Return of the King.
  13. Shengchao Hu, Ziqing Fan, Chaoqin Huang et al. (2024). Q-value Regularized Transformer for Offline Reinforcement Learning. ICML.
  14. Jongseong Chae, Jongeui Park, Yongjae Shin et al. (2026). Flow Actor-Critic for Offline Reinforcement Learning. ICLR.
  15. Jeonghye Kim, Yongjae Shin, Whiyoung Jung et al. (2025). Penalizing Infeasible Actions and Reward Scaling in Reinforcement Learning with Offline Data. ICML.
  16. 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.
  17. Perry Dong, Chongyi Zheng, Chelsea Finn et al. (2026). Value Flows. ICLR.
  18. Anas Houssaini, Mohamad H. Danesh, Amin Abyaneh et al. (2026). Drift Q-Learning.

The session

The run from the model's first output, drawn as Codex CLI shows a conversation: 1,155 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