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:
- 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.
- 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)$.
- 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.
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, andcube-quadruple. - 3M to 1B-transition datasets for harder, long-horizon, goal-conditioned tasks (
puzzle-4x5,puzzle-4x6, andcube-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