Test-Time Gradient Guidance of Flow Policies in Reinforcement Learning

Zhiyuan Zhou, Andy Peng, Charles Xu, Qiyang Li, Jost Tobias Springenberg, Kevin Frans, Sergey LevineNeurIPS 2026

TL;DR

Generative models like diffusion and flow matching are fantastic at imitating robot behaviors, but trying to fine-tune them with reinforcement learning (RL) usually turns into an unstable, hyperparameter-sensitive nightmare. This paper introduces Q-Guided Flow (QGF), an algorithm that skips RL policy training entirely: you train a standard imitation policy and a value function separately, then use gradients from the value function to gently nudge action generation toward higher rewards at test time. It turns out that doing RL on the fly is not only vastly more stable and scalable, it actually rivals or beats state-of-the-art training-time RL methods.

What Problem Does This Paper Address?

Imagine teaching a robot to manipulate objects using an offline dataset of mixed-quality demonstrations. Lately, the go-to architectures for continuous control are flow and diffusion models, which generate actions by iteratively denoising random Gaussian noise into smooth, complex, multimodal trajectories. When trained via simple supervised learning—known as Behavioral Cloning (BC)—these models scale beautifully.

The trouble starts when you want the robot to do better than the dataset average using Reinforcement Learning (RL). Standard actor-critic RL alternates between learning a value function (the "critic," $Q(s,a)$, which scores actions) and updating the policy (the "actor") to maximize that score. Because flow policies generate actions over many iterative steps, pushing gradients from the critic back into the actor requires backpropagating through the entire denoising chain. This Backpropagation Through Time (BPTT) is computationally heavy, high-variance, and notoriously unstable.

Alternatively, you could leave training alone and optimize at test time—for instance, generating $N$ candidate actions and picking the one the critic likes best ("Best-of-N"). However, in high-dimensional action spaces, sampling enough candidates becomes prohibitively expensive. Can we instead use the critic's gradient ($\nabla_a Q(s,a)$) to steer the denoising process directly at inference time? Naïvely, no: the critic was only trained on clean, finished actions, so querying it on intermediate "noisy" actions yields out-of-distribution garbage, while backpropagating through the remaining denoising steps brings back high variance and instability.

Methods

The authors propose Q-Guided Flow (QGF), which decouples training from policy optimization:

  1. Standard Pre-training: First, train a reference flow-matching policy (which learns a velocity field $v_\theta$ pointing from noise to dataset actions) using plain supervised Behavioral Cloning. Separately, train a critic $Q(s,a)$ on the offline dataset using Implicit Q-Learning (IQL), which learns values without needing to sample from a changing policy.
  2. Test-Time Lookahead: At inference time, as the policy integrates from pure noise ($t=0$) toward a clean action ($t=1$), QGF needs to know how to nudge the current noisy action $a_t$. Instead of querying $Q$ at $a_t$ or running the full ODE solver to the end, QGF takes a single, giant first-order Euler step along the current velocity vector to estimate the clean action: $\hat{a}_1 = a_t + (1 - t)v_\theta(s, a_t, t)$.
  3. Simplified Gradient Nudge: QGF evaluates the critic's gradient right at that approximated clean action, $\nabla_{\hat{a}_1} Q(s, \hat{a}_1)$. Crucially, rather than differentiating through the velocity network $v_\theta$ (which introduces an ill-behaved Jacobian matrix), the authors replace the Jacobian with the identity matrix. That clean gradient is simply scaled by a guidance weight $1/\beta$ and added directly to the velocity field at every denoising step.
Figure 1: We propose QGF (Q-Guided Flow), an RL algorithm that guides denoising steps of a policy trained via flow matching with critic gradient at test time. Our critic gradient estimator avoids both taking gradient at noisy action not seen during training and performing expensive, high-variance backpropagation through time, and performs better than other test-time RL methods while being competitive with the best train-time baseline.

Datasets

The authors evaluate QGF on offline RL manipulation tasks from OGBench, using an action-chunking setup (predicting sequences of 5 actions at once, creating a complex high-dimensional space). No new benchmarks are introduced, but rather than using the smaller default OGBench datasets (1M–3M transitions) where performance saturates, they test on massive scale variants:

  • 100M-transition datasets across scene, puzzle-4x4, cube-triple, and cube-quadruple.
  • 3M to 1B-transition datasets for harder, long-horizon, goal-conditioned tasks (puzzle-4x5, puzzle-4x6, and cube-octuple), including sparse-reward settings.

Key Insights and Ideas

  • "Crude" approximations actually optimize better: Dropping the Jacobian matrix and using a single-step Euler lookahead sound like corner-cutting hacks for speed. Surprisingly, both outperform their "exact" mathematical counterparts! Differentiating through the velocity network or full ODE chain amplifies sensitivity to noise; QGF's simplified estimator has much lower variance, making it a smoother, more effective optimizer.
  • Escaping the behavioral distribution: Running the full BC denoising chain to look ahead restricts the previewed action to cover the exact dataset distribution (mistakes and all). Taking a single linear Euler step gives the trajectory just enough slack to deviate and lock onto specific, high-reward modes.
  • Supervised scaling meets RL: Because the policy only ever sees a stable supervised BC loss during training, you can crank up the parameter count without triggering the actor-critic collapse that plagues traditional RL. And if you want to adjust how aggressively the robot chases rewards versus staying close to the dataset ($1/\beta$), you can tune a knob at test time without retraining a thing.

Key Results

  • Outperforming Baselines: Across 20 tasks (100M transitions), QGF beats all prior test-time methods—including Best-of-4 sampling, classifier-free guidance, and noisy-action gradients—and matches or slightly edges out the strongest training-time RL baseline (EDP). It also dominates on 1B-transition long-horizon goal-conditioned tasks.
  • Massive Compute Savings: Generating an action with QGF takes 0.0013 GFLOPs, compared to 0.0370 GFLOPs for Best-of-4 (which QGF beats) and 0.1464 GFLOPs for Best-of-16 ( over $100\times$ more compute). Combining QGF with Best-of-4 matches Best-of-16 at a quarter of the sampling cost.
  • Model Scaling: When scaling actor and critic networks from 825K to 3.2M parameters on cube-triple, a top training-time method (QAM) stagnates, whereas QGF sees a nearly $4\times$ jump in success rate (from roughly 20% to over 70%).
  • Plug-and-Play Critics: Swapping the standard IQL critic for a stronger Q-bootstrapped critic (from QAM) boosts QGF even further, outperforming QAM's own trained actor.

Limitations and Future Work

  • Offline Only (For Now): All experiments are conducted on static, offline datasets; adapting test-time flow guidance for online RL exploration is an immediate next step.
  • Garbage-In, Garbage-Out Critics: QGF is purely a policy extraction tool—it assumes you already have a reasonably accurate value function. If the critic has blind spots or noisy gradients, QGF will faithfully follow them. Developing better critic training methods, as well as test-time guidance schemes resilient to noisy critics, remains an open challenge.
  • Overfitting at Extreme Scale: When pushing network sizes to 12.7M parameters, QGF still experiences some offline overfitting, though far less severely than training-time RL baselines (which drop to 0% success).

Summary updated

Abstract

Expressive continuous control policies, such as diffusion and flow models, form the backbone of recent advances in scaling imitation learning for simulated and real robot control. While they are known to scale stably in the supervised imitation learning setting, incorporating them into reinforcement learning (RL) pipelines for policy improvement has proven more difficult. It often requires specialized training objectives or back-propagating through denoising processes, which cause well known issues with stability and affects scalability. In this paper we study the question of whether simple policy improvement schemes at test time alone, leaving stable supervised policy training intact, can be a competitive alternative which side-steps these issues. To this end, we propose QGF (Q-Guided Flow), a new RL algorithm that performs policy optimization entirely during test time. QGF works by pre-training both a reference flow policy (via a standard behavioral cloning objective) and a value function critic and, during test-time, using the value gradient to guide the reference policy to generate higher-value actions without any additional policy learning. Empirically, QGF outperforms prior test-time RL methods while being much cheaper to run, and is competitive with state-of-the-art training-time algorithms on single-task and goal-conditioned offline RL benchmarks with high-dimensional action spaces. Moreover, it exhibits favorable scaling with model size by avoiding the instability of actor-critic training, offering a practical and effective alternative RL algorithm with expressive policies.
BibTeX
@inproceedings{zhou2026test,
  author = {Zhiyuan Zhou and Andy Peng and Charles Xu and Qiyang Li and Jost Tobias Springenberg and Kevin Frans and Sergey Levine},
  title = {{Test-Time Gradient Guidance of Flow Policies in Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=NYzL9idgNU},
}
Figure