Manuscript Offprint

arXiv:2610.01408

Smoother Flow Matching via Contrastive Trajectory Repulsion

Ziqi Jiang, Zhenqi He, Long Chen

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Ziqi Jiang, Zhenqi He, and Long Chen †^{\dagger}

Department of CSE, The Hong Kong University of Science and Technology

zjiangbl@connect.ust.hk, zheci@connect.ust.hk, longchen@ust.hk

Figure

(a) Standard FM

Figure

(b) CoFlow (Ours)

Figure 1: Illustration of our motivation. (a) In standard FM, straight trajectories inevitably cross. At the intersection, spatially adjacent points have conflicting velocity targets ( vA≠vBv_A \neq v_B while xA≈xBx_A \approx x_B), leading to an extremely high local Lipschitz constant LL. (b) CoFlow explicitly repels trajectories to alleviate crossing, keeping xAx_A and xBx_B separated. This significantly reduces the local Lipschitz constant, yielding a smoother target velocity field that is easier to learn and induces lower numerical integration errors during few-step sampling.

ABSTRACT

Trajectory crossing remains a critical bottleneck in Flow Matching (FM), and previous works typically view these crossings from a theoretical optimization perspective causing velocity averaging. They attempt to address it indirectly by post-hoc distillation or endpoint coupling, without explicitly regulating the intermediate trajectories. In this paper, we introduce a new network learning perspective: crossing points inherently induce large local Lipschitz constants in the target velocity field, leading to two drawbacks. First, high Lipschitz constants correspond to high-frequency signals in the velocity field that neural networks struggle to fit due to spectral bias. Second, they also imply drastic velocity variations, leading to severe numerical integration errors in few-step inference. To alleviate this, we propose CoFlow, a framework that introduces the contrastive learning paradigm into FM to explicitly repel trajectories during training, thereby lowering the local Lipschitz constants of the velocity field. Specifically, we formulate CoFlow from a Stochastic Differential Equation (SDE) perspective by injecting a repulsive drift term. This drift actively guides the forward process of “positive samples” away from “negative trajectories”, effectively reducing the local Lipschitz constant. Furthermore, we derive an equivalent stochastic interpolant formulation from this SDE, providing a simple and tractable design space to control the influence of negative samples. Extensive experiments on ImageNet 256×256256 \times 256 demonstrate that CoFlow significantly reduces FID compared to standard FM in few-step inference (e.g., 20 steps), with no added training overhead. The code can be accessed from: https://github.com/HKUST-LongGroup/CoFlow

1 INTRODUCTION

Continuous-time generative models, formulated as stochastic differential equations (SDEs) or ordinary differential equations (ODEs), have driven remarkable breakthroughs in high-quality visual synthesis.

Specifically, diffusion models (Ho et al., 2020; Song et al., 2020) first gradually corrupt data with noise according to a predefined forward SDE and then learn a score function to reverse this process. However, probability paths induced by these forward SDEs are highly curved, thus requiring hundreds of sampling steps during inference. To overcome this, recent flow matching (FM) (Lipman et al., 2022; Liu et al., 2022; Albergo & Vanden-Eijnden, 2022) enables the construction of straight probability paths and directly learns a velocity field, substantially reducing the required sampling steps.

Although designed to straighten paths for rapid sampling, standard flow matching still requires numerous steps (e.g., 50–100) in practice to generate high-fidelity samples. From a theoretical optimization perspective, this gap stems from trajectory crossings (Liu et al., 2022): when trajectories cross 1^{1}, the marginal velocity at intersections inherently becomes the expectation of conflicting velocities, yielding abrupt changes in the velocity field. During inference, these drastic velocity variations will amplify the truncation errors of numerical ODE solvers, thus degrading few-step generation performance. To alleviate this issue, prevailing approaches primarily operate on the boundaries: they either rely on post-hoc distillation to bypass intermediate integration (Yin et al., 2024; Song et al., 2023; Salimans & Ho, 2022; Liu et al., 2022), or optimize endpoint couplings to reduce crossings (Tong et al., 2023; Davtyan et al., 2026). While both approaches are effective, a more straightforward direction seems to remain unexplored: why not fix the simple couplings and directly adjust the intermediate trajectories during training to explicitly mitigate crossings?

To bridge this gap, we first examine trajectory crossing from a neural network learning perspective, and use the local Lipschitz constant to quantify the smoothness of the velocity field. As illustrated in Fig. 1(a), when trajectories cross, spatially adjacent points have drastically different velocity targets, causing the Lipschitz constant of the target velocity field to be extremely large. This large Lipschitz constant leads to two critical drawbacks: 1) It corresponds to high-frequency signals in the velocity field, which neural networks struggle to fit due to spectral bias (Rahaman et al., 2019). This will make the velocity field difficult to learn accurately. 2) Theoretically, a high Lipschitz constant directly amplifies the truncation error of ODE solvers, degrading few-step sampling quality.

Building upon this perspective, a compelling direction emerges: Explicitly repelling these conflicting trajectories during training to suppress the Lipschitz constant should enable the network to learn a smoother (i.e., with a lower local Lipschitz constant, see Fig. 1(b)) velocity field. Motivated by this, we introduce CoFlow, a novel framework that systematically rectifies training trajectories via negative samples. Drawing inspiration from contrastive learning (Chen et al., 2020; He et al., 2020), CoFlow explicitly forces the trajectory of a target sample (positive) to repel adjacent negative paths (e.g., paths targeting other data points in a mini-batch). Theoretically, we demonstrate that this dynamic is mathematically equivalent to injecting a repulsive drift into the forward stochastic process, closely related to Doob's h-transform (Zhou et al., 2023). From this SDE we can further derive a closed-form, stochastic interpolant (SI) formulation (Albergo & Vanden-Eijnden, 2022), which provides a flexible design space to control the influence of negative samples. We further prove that, when the repulsive drift vanishes at both endpoints,

Figure

L=∥uθ(x^t)−v^t∥2\mathcal{L} = \|u_\theta(\hat{x}_t) - \hat{v}_t\|^2

DeltaFM

L=∥uθ(xt)−vt∥2\mathcal{L} = \|u_\theta(x_t) - v_t\|^2

−λ∥uθ(xt)−vt−∥2-\lambda \|u_\theta(x_t) - v_t^-\|^2

Figure 2: Comparison between DeltaFM and CoFlow.

CoFlow still maps the source distribution to the target distribution, as in standard flow matching. A 2D experiment (Fig. 3) provides some initial evidence for our motivation, showing that CoFlow can learn a velocity field with lower Lipschitz and decrease the truncation errors during inference.

A closely related contemporary work is DeltaFM (Stoica et al., 2025), which also explores negative samples by introducing an auxiliary contrastive loss to the standard objective to penalize velocity similarity with negative samples. Despite sharing a similar motivation, DeltaFM focuses on velocity-level alignment rather than altering intermediate trajectories, as shown in Fig. 2. Notably, another theoretical contribution of our work is proving that the optimal velocity field learned by DeltaFM is mathematically equivalent to an inference-time affine transformation of the standard FM velocity field. Leveraging this insight, we can seamlessly incorporate this transformation into CoFlow at inference time, achieving further performance gains without extra training overhead.

1^{1}While exact intersections are rare in high-dimensional spaces, we use “crossing” in this paper to describe scenarios where distinct trajectories are close to each other but have divergent target velocities.

(a) Trajectory visualization

Figure

(b) Local Lipschitz

Figure

(c) Euler error reduction

Figure 3: 2D Example: Gaussian to Two Moons. (a) Visualization of generated trajectories: CoFlow yields paths with reduced curvature compared to standard FM. (b) Local Lipschitz constant of the learned velocity field. (c) Relative Truncation Error reduced compared with standard FM.

To further validate the effectiveness of CoFlow, we conduct extensive experiments on the ImageNet-256 generation benchmark (Deng et al., 2009). Our evaluations demonstrate that CoFlow significantly enhances the fidelity of few-step(e.g., 20 steps) image generation. Furthermore, we illustrate its compatibility with complementary techniques, such as REPA (Yu et al., 2024), OT-CFM (Tong et al., 2023), and DeltaFM (Stoica et al., 2025). In summary, our main contributions are as follows:

  1. A Lipschitz perspective on trajectory crossing. We quantify trajectory crossing via the local Lipschitz constant, showing that its explosion amplifies numerical truncation errors and thereby degrades few-step sampling quality.

  2. CoFlow framework inspired by Doob-h transform. We propose CoFlow, which explicitly repels conflicting trajectories via negative samples during training to suppress local Lipschitz constants, thus learning a smoother velocity field. We derive an exact closed-form formulation that enables efficient training without costly numerical simulation.

  3. Theoretical insight into DeltaFM. We theoretically prove that DeltaFM is mathematically equivalent to an inference-time affine transformation, revealing its mechanism and allowing it to be combined with CoFlow for further performance gains.

References (54)