Skip to content
AI.info

Research

Neighbor GRPO: Contrastive ODE Policy Optimization Aligns Flow Models

Overview Research area: Computer vision and generative modelling, specifically reinforcement-learning-based alignment (RLHF) of flow matching text-to-image models. Technical level: Advanced. The paper

arXiv
2511.16955
Published
2025-11-21
Authors
Dailan He, Guanlin Feng, Xingtong Ge, Yazhe Niu, Yi Zhang, Bingqi Ma, Guanglu Song, Yu Liu, Hongsheng Li

AI summary

Overview

Research area: Computer vision and generative modelling, specifically reinforcement-learning-based alignment (RLHF) of flow matching text-to-image models.

Technical level: Advanced. The paper derives a policy-gradient objective, reinterprets SDE-based GRPO as contrastive learning, and defines a surrogate softmax-distance policy over ODE neighborhoods.

Scope: The paper proposes Neighbor GRPO, an RLHF algorithm that aligns flow matching models without converting the deterministic ODE sampler into an SDE, and reports training-cost and generation-quality comparisons against DanceGRPO, MixGRPO and BranchGRPO on FLUX.1-dev.

What This Paper Is About

Group Relative Policy Optimization (GRPO) needs stochasticity to explore, but modern flow matching models such as FLUX are built around deterministic ODE sampling, so existing methods convert the ODE into an equivalent SDE to make GRPO applicable. That conversion loses two ODE advantages: it restricts sampling to first-order solvers and makes credit assignment inefficient, since a terminal reward must be spread across all timesteps. Neighbor GRPO instead creates a small neighborhood of candidate trajectories by perturbing the initial noise, then optimizes the model with a softmax distance-based surrogate leaping policy that fits inside the GRPO framework while keeping inference fully deterministic.

Key Contributions

  1. The authors reinterpret GRPO for flow matching from a distance-optimization perspective, showing that SDE-based GRPO is equivalent to advantage-weighted MSE, i.e. a contrastive-learning mechanism in which ODE anchors are pulled toward high-reward SDE samples and pushed away from low-reward ones.
  2. They propose Neighbor GRPO, which builds a group of candidate trajectories by perturbing the shared initial noise and defines a discrete surrogate leaping policy over softmax negative squared distances, allowing policy-gradient optimization without any SDE sampling.
  3. They establish a theoretical link between the distance-based objective and policy gradient optimization, integrating the surrogate policy into the GRPO objective, and introduce three practical strategies: symmetric anchor sampling, group-wise quasi-norm advantage reweighting, and use of high-order solvers such as DPM++.
  4. They report experiments showing better training cost, convergence speed and generation quality than SDE-based counterparts, including 4 hours of training for a standard 300-iteration run on 32 NVIDIA H800 GPUs.

Main Findings

  • ODE conversion is unnecessary: The paper shows that SDE-based GRPO's optimization dynamics amount to aligning the deterministic ODE sample with stochastically perturbed neighbors, so contrastive distance optimization can be performed directly in the ODE neighborhood.
  • Large training-cost reduction: Reported cost per iteration drops from 237.86 s (DanceGRPO) and 237.71 s (MixGRPO) to 141.93 s for Neighbor GRPO with 25-step DDIM, 105.85 s with 16-step DPM++, and 45.08 s with 8-step DPM++. BranchGRPO is listed at 249.33 s.
  • Policy-update cost: With group size G = 12, the group-wise formulation requires only B × K solver calls instead of G × K, saving up to 12 times the forward–backward calculations; the policy-update cost is reported as falling from over 100 to 45 seconds per iteration.
  • Multi-reward comparison (Table 1): Using the DPM++ 8-step configuration with NFE_old = 8, Neighbor GRPO records HPSv2.1 0.366, Pick 0.234, ImageReward 1.640, CLIP 0.391, UnifiedReward 3.334 and Aesthetic 6.621, versus MixGRPO-Flash at 0.343, 0.228, 1.409, 0.374, 3.148 and 6.770 respectively, and DanceGRPO at 0.371, 0.231, 1.306, 0.364, 3.156, 6.552. The untuned FLUX.1-dev baseline is listed at 0.310, 0.227, 1.131, 0.389, 3.211, 6.108.
  • Out-of-domain scores: On the 25-step DDIM setting, Neighbor GRPO records the highest out-of-domain scores (CLIP 0.385, UnifiedReward 3.262, Aesthetic 6.669) while remaining on par with baselines on in-domain metrics.
  • Faster convergence: Training curves show the method exceeding an HPSv2.1 score of 0.35 within only 50 iterations, converging faster than DanceGRPO and showing better long-term stability than MixGRPO.
  • Single-target ablation (Table 2): With p = 0.8, Neighbor GRPO reaches CLIP 0.371, UnifiedReward 3.166 and Aesthetic 6.626, against BranchGRPO's 0.362, 3.138, 6.571 and MixGRPO's 0.367, 3.125, 6.365.
  • Human evaluation: 46 users with varied professional backgrounds preferred Neighbor GRPO's outputs over baselines with win rates of 72% and 61%.
  • Perturbation strength: Testing σ ∈ {0.1, 0.3, 0.5, 1.0} shows a larger σ improves in-domain performance but can hurt out-of-domain performance; σ = 0.3 is chosen as the suitable value (HPSv2.1 0.375, CLIP 0.363, UnifiedReward 3.141, Aesthetic 6.639).
  • Anchor count: With B = 2 anchors, HPSv2.1 exceeds 0.37 while the policy-update process is 6 times faster; B = 4 improves all metrics and is described as the best balance.
  • Quasi-norm reweighting: Testing p ∈ {0.5, 0.8, 1, 2}, p = 0.8 gives the best out-of-domain results (CLIP 0.371, UnifiedReward 3.166, Aesthetic 6.626) and is described as most effective against reward hacking; p = 2 recovers standard GRPO normalization; smaller p loses exploration and reduces all scores.

Methodology in Plain English

Flow matching models generate images by following a deterministic path from random noise to a data sample, so there is no built-in randomness for reinforcement learning to explore with. Existing approaches inject noise by turning the path into a stochastic differential equation, then use GRPO with a reward such as HPSv2.1.

The authors first show that this stochastic recipe is mathematically equivalent to pushing the deterministic sample toward higher-reward noisy neighbours and away from lower-reward ones, a contrastive-learning pattern. They then remove the noise injection entirely. Starting from one shared random noise vector, they create G slightly different initial noises using a weighted combination of the shared noise and independent Gaussian noise (ε⁽ⁱ⁾ = √(1−σ²)·ε* + σ·δ⁽ⁱ⁾), with σ controlling perturbation strength. Running the deterministic solver on each of these gives a bundle of similar trajectories forming a local neighbourhood.

Because the solver itself is deterministic, they define a training-only "surrogate leaping policy": the probability of jumping to candidate i is a softmax over the negative squared distance between that candidate and a randomly chosen anchor from the group. This distribution, whose likelihood is tractable, is plugged into the standard GRPO clipped objective with group-normalized advantages, so maximizing it simply pulls the anchor's position toward high-advantage candidates and pushes it away from low-advantage ones. Inference never uses this policy — final generation runs the plain deterministic ODE solver.

Three implementation details make this practical. Symmetric anchor sampling exploits the near-equidistance of the grouped initial noises (a consequence of the Johnson–Lindenstrauss Lemma): every candidate can serve as an anchor, so only B anchors are sampled per iteration instead of all G. Group-wise quasi-norm reweighting replaces the L2 normalization of advantages with an Lp norm, p ∈ (0,2], which shrinks the influence of groups whose rewards have flattened and would otherwise produce over-averaged, reward-hacked outputs. Finally, because nothing depends on the SDE, high-order solvers such as DPM++ can be used for rollouts while policy updates use a single-step DDIM transition.

Why This Matters

Impact on research: The paper offers a reinterpretation of why SDE-based GRPO works, framing it as contrastive learning, and then shows the stochasticity can be replaced by neighbourhood structure. This opens a route to RLHF for any deterministic sampler, not only flow matching, and removes the tension between high-order few-step solvers and policy-gradient training.

Real-world applications:

  • Aligning text-to-image generators such as FLUX.1-dev with human aesthetic and prompt-following preferences.
  • Video and image-to-video generation, the task family that DanceGRPO was extended to cover.
  • Low-cost fine-tuning pipelines where four hours of training on 32 NVIDIA H800 GPUs is affordable, versus the costs reported for the SDE baselines.
  • Any deployment relying on few-step sampling, where DPM++ rollouts with 8, 4 or fewer function evaluations matter for latency.

Industry relevance: Reduced per-iteration cost (45.08 s versus 237.86 s in the reported configurations), direct compatibility with DPM++ and mixed-reward training to suppress reward hacking are all practical concerns for teams shipping generative image products.

Future Directions

  • Whether the approach scales beyond the 300-iteration, 4800/9600-prompt HPDv2 training setups used here, since the paper notes better long-term stability implies a possibility for further scaling up.
  • Selecting σ and p automatically: the ablations show in-domain and out-of-domain metrics trade off across σ and that p is described as a critical factor, so per-task tuning remains manual.
  • Extending the surrogate leaping policy beyond text-to-image to other deterministic-sampler modalities such as video, which the paper discusses only as related work context.
  • Understanding the limits of the neighbourhood assumption: the paper notes that too large a σ makes contrastive learning too difficult and raises reward-hacking risk, leaving open how to adapt neighbourhood size during training.

Target Audience

Researchers and engineers working on reinforcement learning from human feedback for visual generative models, particularly those training or fine-tuning flow matching architectures such as FLUX. It is also relevant to practitioners who need efficient, few-step sampling and want to avoid the solver restrictions imposed by SDE-based alignment. A background in diffusion and flow matching, policy gradient methods, and GRPO is assumed.

Authors’ abstract

Group Relative Policy Optimization (GRPO) has shown promise in aligning image and video generative models with human preferences. However, applying it to modern flow matching models is challenging because of its deterministic sampling paradigm. Current methods address this issue by converting Ordinary Differential Equations (ODEs) to Stochastic Differential Equations (SDEs), which introduce stochasticity. However, this SDE-based GRPO suffers from issues of inefficient credit assignment and incompatibility with high-order solvers for fewer-step sampling. In this paper, we first reinterpret existing SDE-based GRPO methods from a distance optimization perspective, revealing their underlying mechanism as a form of contrastive learning. Based on this insight, we propose Neighbor GRPO, a novel alignment algorithm that completely bypasses the need for SDEs. Neighbor GRPO generates a diverse set of candidate trajectories by perturbing the initial noise conditions of the ODE and optimizes the model using a softmax distance-based surrogate leaping policy. We establish a theoretical connection between this distance-based objective and policy gradient optimization, rigorously integrating our approach into the GRPO framework. Our method fully preserves the advantages of deterministic ODE sampling, including efficiency and compatibility with high-order solvers. We further introduce symmetric anchor sampling for computational efficiency and group-wise quasi-norm reweighting to address reward flattening. Extensive experiments demonstrate that Neighbor GRPO significantly outperforms SDE-based counterparts in terms of training cost, convergence speed, and generation quality.

Read the original paper