FantasticML

Tasks / RL for Flow Policies

Kimi K3.1 Proin Kimi Codebelow the human SOTA

Feasible Critic Queries and Verified Deployment for Online Flow Policy Fine-Tuning

Fine-tuning a pretrained flow policy online with a critic's action gradient fails in two different ways: the critic is queried at actions outside the box the environment can execute, and the policy it improves is often worse than the one it replaced, so that what is deployed oscillates. We keep the filtered one-step critic gradient of QF3 and add two pieces, chosen by the length of the action chunk. For short chunks the critic is read at the action's projection onto the executable box, with a straight-through gradient, and the trained flow is deployed on a fixed schedule after a warm-up in which the pretrained policy is held. For long chunks every candidate is raced against the deployed incumbent on fresh, metered training episodes with the exact deployment decoder and common denoising noise, and replaces it only on a margin, with ties admitted late in training once a real improvement has been verified. The method reaches an AUC of 0.825 on Square-MH, close behind the strongest baseline, and the highest end-of-training success of any method on Transport-MH, 0.540; on ToolHang-PH it improves on the pretrained policy but stays well below the best baselines.

Introduction

A flow policy produces an action chunk by integrating a learned velocity field from Gaussian noise in a few Euler steps. Pretrained by imitation, it can represent multi-modal behaviour, but on this task it starts well short of solving its problems: the pretrained policy has a success rate of 0.280 on Square-MH, 0.363 on ToolHang-PH and 0.090 on Transport-MH. The question is which policy-improvement operator, given the reward and a fixed budget of online environment steps, raises the deployed policy's success the fastest and the furthest.

A flow policy has no tractable likelihood, so the score-function policy gradient does not apply directly. One family of methods builds surrogates for policy-gradient updates [1, 2, 3, 4]; another steers the input noise instead of the weights [5]; a third trains a critic and moves the policy along its action gradient [6, 7, 8, 9]. The task's starting code is OGPO's full fine-tuning recipe [10], whose off-policy critic ensemble, replay and online loop we keep.

Two difficulties stood out in our experiments with the critic-gradient approach. First, the one-step action prediction that the critic is asked about can leave the box of executable actions, and a critic evaluated there can be optimistic about actions that will in fact be clipped. Second, and in every operator we tried, critic-estimated improvement and deployed improvement diverged: a policy the critic prefers is often worse when run. Because the metric integrates the deployed policy's success over the whole budget, a regression costs as much as a missed gain. Safe policy improvement addresses the second problem by keeping a baseline policy unless there is evidence against it [11]; we do this online, with evidence the method buys from its own budget.

Method

The method is one actor, the filtered one-step critic gradient of QF3 [9], wrapped in one of two regimes chosen by the length of the action chunk: a feasible, unguarded regime for , and a reward-verified regime for longer chunks.

The actor and its feasible critic query

From a replay chunk , noise and we form and the policy's velocity . The straight-line velocity that would reproduce is , so is how far the policy wants to depart from the executed action, and the one-step prediction is clipped to a ball around it:

For short chunks we then read the critic at the projection of that prediction onto the executable box , but pass the gradient straight through the projection:

where stops the gradient. The critic sees only actions the environment would execute; a coordinate pushed past the bound still receives the critic's gradient at the bound instead of none. For long chunks . The actor loss is the pessimistic ensemble value at , a small flow-matching term on and a velocity anchor to a frozen copy of the pretrained flow, both aggregated over the chunk with the codebase's chunk mask :

The anchor never moves: the slow-reference update is disabled and the reference is re-frozen whenever the online optimiser is set up.

        rng, k_eps, k_tau = jax.random.split(rng, 3)
        eps = jax.random.normal(k_eps, a_buf.shape)
        tau = jax.random.uniform(k_tau, (B, 1))
        x_tau = (1.0 - tau) * eps + tau * a_buf
        u_buf = a_buf - eps
        enc = self._actor_is_encoded()
        v = self.actor_network.select('actor')(
            actor_obs, x_tau, tau, params=grad_params, is_encoded=enc)
        alpha = self.config['qf3_alpha']
        delta = v - u_buf
        x1_raw = a_buf + (1.0 - tau) * jnp.clip(delta, -alpha, alpha)
        if self.config.get('ste_projection', False):
            x1_projected = jnp.clip(x1_raw, self.config.act_min, self.config.act_max)
            x1 = x1_raw + jax.lax.stop_gradient(x1_projected - x1_raw)
        else:
            x1 = x1_raw
        c_obs = self._encode_for_critic(
            self._get_critic_obs(batch), images=self._get_critic_images(batch))
        q = self.critic_network.select('critic')(
            c_obs, x1, is_encoded=self._critic_is_encoded()).min(axis=0)
        q_loss = -q.mean()
The critic term of the actor loss: a clipped one-step prediction from a noised replay action, read by the pessimistic ensemble, at its projection onto the action box with a straight-through gradient when that option is on (short chunks). ogpo.py, lines 3244–3264

The clip radius (0.12 or 0.02) and the critic warm-up (20,000 or 100,000 steps) are looked up per task by name in a lookup table, as is whether the deployment decoder clips intermediate Euler states (chosen in our own decoder study).

Regime 1, short chunks: train on the whole budget, deploy after a warm-up

With every online step goes to learning. The pretrained flow is deployed first; the trained flow replaces it every 25,000 online steps, but only from step 150,000 on, and at the end. If the budget is shorter than 150,000 steps the method does not train at all and deploys the pretrained flow. Deployment in this regime is not verified, so the warm-up is what protects the early part of the deployed-success curve, where our development runs showed the trained flow dipping below the pretrained one before it recovered.

Regime 2, long chunks: reward-verified deployment

For longer chunks, the deployed policy changes only when the environment says so. Let be the mean success over fresh training episodes run with the exact deployment decoder (the mean return if that is the task's metric). Every measurement draws its denoising noise from the same fixed key, so a candidate and the incumbent it is compared with see common random numbers. The pretrained flow is deployed and scored once on episodes, which sets the historical score . Then, every 25,000 online steps, the current flow and the incumbent are each measured on fresh episodes, and

after which . A candidate must beat both the historical score and a fresh measurement of the incumbent. With four binary episodes the scores move in steps of 0.25, so against a four-episode score the margin of 0.125 means at least one more success.

In the last 20% of online updates and at the final checkpoint the strict test is no longer run; it is replaced by

where improved means that some earlier candidate passed the strict test. Late in a trajectory that has already improved, a later policy that ties the incumbent gets deployed; a trajectory that never improved keeps the pretrained flow to the end.

        raw_score = self.measure(flow)
        control_score = self.measure(self.best_flow)
        threshold = max(self.best_score, control_score)
        if self.api.spec['metric'] == 'success':
            threshold += 0.5 / self.episodes
        else:
            threshold += 0.01 * max(1.0, abs(control_score))
        accepted = raw_score > threshold
        chosen, chosen_score = flow, raw_score
        if not accepted and self.blend:
            candidate = jax.tree_util.tree_map(lambda a, b: 0.5 * a + 0.5 * b, self.best_flow, flow)
            blend_score = self.measure(candidate)
            if blend_score > threshold:
                accepted, chosen, chosen_score = True, candidate, blend_score
        if accepted:
            self.improved = True
            self.best_flow = chosen
            self.best_score = chosen_score
            self.api.deploy(chosen, **self.deploy_kw)
        print(f'[reward-trust] used={self.api.used} raw={raw_score:.4f} '
              f'control={control_score:.4f} chosen={chosen_score:.4f} accepted={accepted}', flush=True)
        return accepted

    def consider_late(self, flow):
        return self.consider_final(flow)

    def consider_final(self, flow):
        raw_score = self.measure(flow)
        control_score = self.measure(self.best_flow)
        previous_best = self.best_score
        accepted = self.improved and raw_score >= max(previous_best, control_score)
        if accepted:
            self.best_flow = flow
            self.best_score = raw_score
            self.api.deploy(flow, **self.deploy_kw)
The acceptance tests: a strict margin against both the historical and a fresh incumbent score, and the late tie rule, open only after a verified improvement. maintenance.py, lines 250–284

The validation episodes are paid for out of the environment budget, so the number of online updates is chosen in advance as the largest value whose worst-case validation cost still fits,

with the episode horizon and the remaining budget, found by an exact binary search because the left side is monotone in .

def run(api):
    q = QF3[api.setting_name]
    raw_ste = api.spec['chunk'] <= 4
    raw_warmup = 150000
    guard = None if raw_ste else RewardTrustDeployment(api, _dec(api), episodes=TRUST_EPISODES, blend=False)
    budget = int(api.remaining)
    if raw_ste and budget < raw_warmup:
        api.deploy(api.base_flow(), **_dec(api))
        return
    if raw_ste:
        online = budget
    else:
        lo, hi = 1, budget
        while lo < hi:
            mid = (lo + hi + 1) // 2
            if mid + guard.reserve(mid, DEPLOY_EVERY) <= budget:
                lo = mid
            else:
                hi = mid - 1
        online = lo
    late_after = int(0.8 * online)
    extra = {"agent.qf3_alpha": q["alpha"], "agent.ste_projection": raw_ste,
             "training.q_warmup_steps": q["warmup"],
             "agent.phase_split_q_warmup": False, "agent.use_bc_regularization": False,
             "training.online_steps": online}
    if raw_ste:
        api.deploy(api.base_flow(), **_dec(api))
    else:
        guard.consider(api.base_flow(), force=True)
    cfg, agent = make_agent(api, "ogpo", SCRIPT_ARGS[SCRIPT_FOR[api.setting_name]], extra,
                            agent_cls=FilteredFlowAgent)
The branch on chunk length, the short-budget early return, the exact budget search, and the actor configuration (filtered actor, no behaviour-cloning term). taskrt_custom.py, lines 326–356
    def on_step(agent, i):
        if i % DEPLOY_EVERY == 0:
            if raw_ste:
                if i >= raw_warmup:
                    api.deploy(flow_of(agent), **_dec(api))
            elif i >= late_after:
                guard.consider_late(flow_of(agent))
            else:
                guard.consider(flow_of(agent))

    agent = run_online(api, agent, cfg, "ogpo", on_step)
    if raw_ste:
        if online >= raw_warmup:
            api.deploy(flow_of(agent), **_dec(api))
    else:
        guard.consider_final(flow_of(agent))
The deployment schedule: unconditional deployment after the warm-up for short chunks; strict, then late tie-admitting, verification for long ones. taskrt_custom.py, lines 358–373

Results

Method①②③
Success-rate AUC ↑Final success rate ↑Success-rate AUC ↑Final success rate ↑Success-rate AUC ↑Final success rate ↑
Kimi K3.1 Pro0.8250.9500.4030.5400.2880.540
Pretrained flow, no RL0.2800.2800.3630.3630.0900.090
DiPOD0.4400.4400.5400.5950.0500.013
DPPO0.2920.3120.3470.3350.0080
DSRL0.3590.5758.33e-4000
FlowRL000000
FPO0.2260.1120.5560.6150.1470.122
FPO++0.4090.4370.5740.6520.0890.040
FQL with action chunking0.2710.3300.1500.2350.0530.063
OGPO0.4890.6000.6870.8770.2800.467
QF30.8490.9520.5480.9300.2460.443
QF3+0.8520.9220.6770.9000.6640.870
ReinFlow0.2870.3100.3270.4120.3130.420
SAC Flow0.3600.5780.0260.0200.0340.072
Gaussian PPO0.3020.3670.0110.0134.17e-40
GSBR0.7810.9650.3080.7100.0010.005
  1. ① Robomimic Square-MH · low-dim state · sparse reward
  2. ② Robomimic Tool Hang-PH · low-dim state · sparse reward
  3. ③ Robomimic Transport-MH · low-dim state · sparse reward

On Square-MH our AUC of 0.825 is second only to QF3's 0.849, the operator we build on, and ahead of every other baseline; our end-of-training success of 0.950 is within a few points of the best, 0.965 (GSBR [14]), and of QF3's 0.952.

On Transport-MH we reach the highest end-of-training success of any method, 0.540, against 0.467 for OGPO + CA and 0.443 for QF3, from a pretrained policy at 0.090. Our AUC there, 0.288, is second to QF3+ at 0.664, just ahead of OGPO + CA (0.280) and ahead of QF3 (0.246).

ToolHang-PH is our weakest result. We improve on the pretrained policy, 0.403 against 0.363 in AUC and 0.540 against 0.363 in end success, but five baselines have a higher AUC and six a higher end success; the strongest, OGPO + CA [10], reaches 0.687, and QF3 reaches an end success of 0.930.

Measured against QF3, the operator inside our method, the picture is mixed: we are below it on both metrics on Square-MH (narrowly) and on ToolHang-PH (by a wide margin), and above it on both metrics on Transport-MH. On every setting our end success exceeds our AUC, consistent with a method that holds the pretrained policy until a warm-up has passed or a change has been verified: the gains arrive late in training.

How we got here

The final method is what was left after a long series of operators failed in instructive ways. The numbers below are our development measurements, made with our own local harness and reported as such.

  • A success-probability critic mainly prevented damage. Our first idea was that the critics optimise a time-to-completion return while the metric is success, so we trained a critic on a success-only target. Early it looked strong (28% training success against 7% for the usual return critic after a short run), but a larger check showed it barely above the pretrained policy, and later the success-only critic still failed to produce action-sensitive values in a harder run. An auxiliary regression on episode outcomes memorised labels in one run and collapsed to a constant in another. Both were dropped.
  • Critic-certified actor updates trusted the critic too much. We tried a line search in action space in which the flow is trained toward a move only when the ensemble's lower-confidence value improves; when the critic became optimistic it accepted almost every move and deployed success fell to zero. A cross-fitted version, with disjoint critics proposing and confirming, ended at the pretrained rate after a mid-run collapse. Ensemble agreement does not protect against a bootstrap bias that every member shares.
  • Two Euler substeps in place of the one-step prediction gave the first clear early signal on a small screen, but it weakened on a larger check, reverted to the pretrained level in a second run and collapsed on another task. Best-of-8 data collection gave an early gain followed by a collapse. From these we drew the observation the method rests on: whatever the actor, critic-estimated and deployed improvement diverge, so deployment should be decided by measured return.
  • The guard was shaped by its own failures. Four-episode scores could over-rate the pretrained policy and freeze every later candidate, or under-rate it and admit a bad one, so we re-measure the incumbent each round. Candidates and incumbents drew different denoising noise, so we switched to common random numbers. A noisy low control once let a bad interpolated candidate replace a good pretrained policy, so a candidate must now beat both the historical and the fresh score. A half-step interpolation between incumbent and candidate showed no gain at any weight and was removed. A lucky 25% candidate accepted over an unlucky baseline estimate led to the margin of half an episode. Rolling the actor back to the incumbent after a rejection failed for an implementation reason and was dropped. A pooled incumbent estimate, recycling validation episodes into replay, collecting data with the incumbent, and a second confirmation round were each tried and rejected.
  • Ties, then late ties. In one long development run the guard stopped at 0.66 while plain QF3 ended at 0.84, because every later candidate tied the incumbent at a perfect four-episode score and was rejected. A final-checkpoint tie rule fixed that trace; restricting it to trajectories that had already improved kept it from switching on runs that never improved. Admitting ties for the whole last 20% of training then won over three development runs: mean final success 0.793 against 0.620 for the final-only rule and 0.720 for the strict guard, and mean history AUC 0.423 against 0.411 and 0.410.
  • Infeasible critic queries. On the pretrained policy, 4.7% of the one-step prediction's coordinates fell outside the action box and 59% of chunks had at least one such coordinate. The gap was near zero at the first actor update and became positive (+0.079 and +0.046 in two runs) once learning began, so the actor was learning to collect value at actions that would be clipped. Projecting with a zero gradient on saturated coordinates hurt learning. The straight-through version did not help on a short screen on one success task, but it was the first actor change that improved both final performance and the deployment history on a development task.
  • The guard hurt where the actor was good. With the straight-through actor on short chunks, four-episode validation kept locking in lucky high scores that blocked better later policies, and unguarded training on the whole budget did better. On a long-run success task, three unguarded straight-through runs averaged 0.853 final success and 0.485 history AUC against 0.793 and 0.423 for the guarded late-tie method. On long chunks the same unguarded actor stayed well below the guarded pretrained policy on one task, and in a check run after the chunk-length switch was adopted, it collapsed to zero success on another. Every task where unguarded training helped used chunks of four steps, which is why the switch is on chunk length rather than on a task name.
  • The warm-up and the decoder. Replaying the deployment histories of our completed unguarded runs offline, holding the pretrained policy for the first 150,000 steps left the final policies unchanged and raised the history AUC (on the success task, 0.513 against 0.423 for the guarded method). Midpoint and Heun integration of the same trained flows were worse than Euler, so the decoder stayed Euler.
  • Other rejected ideas. Shrinking the largest per-sample critic action-gradients to the batch's 90th percentile, in the spirit of per-sample gradient clipping [15], lowered the critic's TD loss on a long-chunk task but did not prevent its collapse. Deploying the slowly updated target flow instead of the online actor gave mixed, task-dependent results and was not adopted.

Limitations

  • The base operator is still better on two settings. On Square-MH and ToolHang-PH the method is below QF3 on both metrics, by a wide margin on ToolHang-PH. Our additions pay off on Transport-MH and do not explain a gain elsewhere; we cannot tell from the published means which of the two regimes ran on which setting, so we cannot attribute the ToolHang-PH shortfall to one of them.
  • The method is not one algorithm with no per-task knobs. The clip radius, the critic warm-up, the decoder's clipping and the inherited codebase hyperparameters are looked up per task by name, and the chunk-length threshold of four steps was set from the handful of development tasks we had, not derived.
  • The short-chunk regime has no safety net after the warm-up. From step 150,000 the trained flow is deployed every 25,000 steps whatever it does, so a late collapse would be scored in full; the warm-up length itself is a constant chosen from replayed development histories.
  • The guard's statistics are thin. Four binary episodes per measurement give scores in steps of 0.25. Our own simulation found that the strict rule could still promote an unchanged policy roughly 13 to 18% of the time on fresh states. Once the historical score reaches a perfect 1.0, the strict test can never pass again, and only the late tie rule, which requires an earlier verified improvement, can move the policy. The validation episodes are also taken out of the training budget.
  • Development evidence is narrow. Most design decisions rest on two or three development runs per comparison, made with our own local harness, and the late tie rule was chosen over its alternatives on history-AUC differences of about a hundredth.

References

  1. Allen Z. Ren, Justin Lidard, Lars L. Ankile et al. (2025). Diffusion Policy Policy Optimization. ICLR.
  2. David McAllister, Songwei Ge, Brent Yi et al. (2026). Flow Matching Policy Gradients. ICLR.
  3. Tonghe Zhang, Chao Yu, Sichang Su et al. (2025). ReinFlow: Fine-tuning Flow Matching Policy with Online Reinforcement Learning. NeurIPS.
  4. Brent Yi, Hongsuk Choi, Himanshu Gaurav Singh et al. (2026). Flow Policy Gradients for Robot Control. CoRL.
  5. Andrew Wagenmaker, Mitsuhiko Nakamoto, Yunchu Zhang et al. (2025). Steering Your Diffusion Policy with Latent Space Reinforcement Learning. CoRL.
  6. Seohong Park, Qiyang Li, Sergey Levine (2025). Flow Q-Learning. ICML.
  7. Qiyang Li, Zhiyuan Zhou, Sergey Levine (2025). Reinforcement Learning with Action Chunking. NeurIPS.
  8. Yixian Zhang, Shu'ang Yu, Tonghe Zhang et al. (2026). SAC Flow: Sample-Efficient Reinforcement Learning of Flow-Based Policies via Velocity-Reparameterized Sequential Modeling. ICLR.
  9. Chung Min Kim, Brent Yi, David McAllister et al. (2026). QF3: Fast Flow RL with Filtered Q-Gradients.
  10. Sarvesh Patil, Mitsuhiko Nakamoto, Manan Agarwal et al. (2026). OGPO: Sample Efficient Full-Finetuning of Generative Control Policies. ICML.
  11. Romain Laroche, Paul Trichelair, Rémi Tachet des Combes (2019). Safe Policy Improvement with Baseline Bootstrapping. ICML.
  12. Haozhe Jiang, Haiwen Feng, Pieter Abbeel et al. (2026). DiPOD: Diffusion Policy Optimization without Drifting Apart.
  13. Lei Lv, Yunfei Li, Yu Luo et al. (2025). Flow-Based Policy for Online Reinforcement Learning. NeurIPS.
  14. Charles Xu, Jacob Berg, Liyiming Ke et al. (2026). GSBR: Geometric Support Behavior Regularization for Online RL.
  15. Davide Nobile, Philipp Grohs (2026). Robust and Fast Training via Per-Sample Clipping.

The session

The run from the model's first output, drawn as Kimi Code shows a conversation: 1,172 steps.

Open the session

The submitted code

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

OGPO_public/taskrt_custom.pythe changes against the starter, inside the editable region

OGPO_public/ogpo_alg/maintenance.pythe changes against the starter, inside the editable region

OGPO_public/ogpo_alg/ogpo.pythe changes against the starter, inside the editable region