Skip to content

Flow matching: regress the field the sampler integrates

Flow matching trains a generator by regressing the velocity field its ODE sampler integrates: conditional targets, the optimal-transport path, and why it trains robustly.

Line diagram: noise samples at t = 0 travel in straight optimal-transport paths to data samples at t = 1, while a VP diffusion path curves and overshoots

Flow matching trains a continuous normalizing flow by plain least squares: regress a network vθ(x,t)v_\theta(x, t) onto the velocity field that carries noise to data, then sample by integrating that field.

Diagram: on the optimal-transport path a noise sample x_0 at t = 0 moves in a straight line to a data sample x_1 at t = 1, with the constant velocity target x_1 - (1 - sigma_min) x_0; a VP diffusion path curves instead
The regression target is the velocity the sampler integrates; on the OT path it is constant along each line.
LFM=Et,  x∼pt∥vθ(x,t)−ut(x)∥2\mathcal{L}_{\mathrm{FM}} = \mathbb{E}_{t,\; x \sim p_t} \bigl\| v_\theta(x, t) - u_t(x) \bigr\|^2

The target is the field the solver integrates, at a uniform scale over time, and the path is a free choice that admits the straight optimal-transport path.

The definition in full, and why those two properties make it the default

A continuous normalizing flow is a generative model that parameterizes a time-dependent vector field vθ(x,t)v_\theta(x, t) with a neural network and produces samples by drawing noise x0x_0 from N(0,I)\mathcal{N}(0, I) and integrating the ODE dx/dt=vθ(x,t)dx/dt = v_\theta(x, t) from t=0t = 0 to t=1t = 1. The training objective, introduced by Lipman et al., is plain least squares: choose a probability path ptp_t that interpolates between the noise distribution and the data distribution, and regress vθv_\theta onto the velocity field utu_t that generates that path, meaning that transporting samples along utu_t reproduces ptp_t at every tt.

Two properties make this the default way to train continuous generators. The regression target is the same field the ODE solver integrates at sampling time, and its scale can be made uniform over tt, which together make training markedly more robust than score matching at identical architecture and compute. And the path is a free choice rather than the byproduct of a diffusion process, which admits the straight optimal-transport path: a velocity target that is constant in time during training, and, empirically, the same sample quality at a fraction of the solver steps.

Checkerboard density evolution and low-NFE sampling for three objectives
With the OT path, flow matching forms the pattern earliest and stays clean at few function evaluations. Source: Flow Matching for Generative Modeling, Figure 4, p. 7.What to see

on the left, the 2D checkerboard pattern emerges much earlier along the flow for FM with OT (bottom row) than for the diffusion-path models above it; on the right, FM-OT samples remain clean at NFE 4 to 20 while the other objectives' samples degrade.

View full size: Checkerboard density evolution and low-NFE sampling for three objectives

Per-example velocity targets optimize the intractable marginal objective

utu_t depends on the unknown data density, so conditional flow matching (CFM) regresses onto closed-form per-example targets instead.

Two velocity fields over the same noise-to-data path

Per-example target (closed form)

Condition on one data sample x1x_1: a Gaussian path from standard noise at t=0t = 0 to N(x1,σmin⁡2I)\mathcal{N}(x_1, \sigma_{\min}^2 I) at t=1t = 1, with a velocity ut(x∣x1)u_t(x \mid x_1) written down exactly.

Marginal field (what the network learns)

At each xtx_t, the posterior-weighted average of the per-example velocities over every x1x_1 that could have produced it. Intractable to compute, and the least-squares minimizer of the per-example loss.

One conditional flow matching training step

  1. Samplett uniformly on [0,1][0, 1], a data sample x1x_1, and noise x0x_0
  2. Formxt=σt(x1) x0+μt(x1)x_t = \sigma_t(x_1)\, x_0 + \mu_t(x_1), the path's mean μt\mu_t plus its spread σt\sigma_t times the noise
  3. Regressa gradient step on the squared error against the closed-form target

Least squares makes the minimizer the conditional expectation of the targets: the marginal field, exactly, in expectation.

The CFM loss, Theorems 1 to 3, the closed-form target, and time conventions

The loss above cannot be computed as written: for any path that ends at the data distribution, utu_t depends on the unknown data density, so there is nothing to regress onto. Conditional flow matching (CFM) is the construction that fixes this.

Condition on one data sample x1x_1 and define a per-example Gaussian path pt(x∣x1)p_t(x \mid x_1) that starts at standard noise at t=0t = 0 and ends at a concentrated Gaussian N(x1,σmin⁡2I)\mathcal{N}(x_1, \sigma_{\min}^2 I) around the sample at t=1t = 1, with σmin⁡\sigma_{\min} a small constant, typically 10−510^{-5}. Marginalizing over the data distribution q(x1)q(x_1) yields a path whose endpoint approximates the data.

Writing xtx_t for a sample on the path at time tt, the field that generates this marginal path is the average of the conditional fields over every x1x_1 that could have produced the observed xtx_t, weighted by the posterior:

ut(x)=E[ ut(x∣x1)  ∣  xt=x ]u_t(x) = \mathbb{E}\bigl[\, u_t(x \mid x_1) \;\big|\; x_t = x \,\bigr]

The CFM loss regresses the network onto closed-form per-example targets instead of the intractable marginal field:

LCFM=Et,  x1∼q,  x∼pt(x∣x1)∥vθ(x,t)−ut(x∣x1)∥2\begin{aligned} \mathcal{L}_{\mathrm{CFM}} &= \mathbb{E}_{t,\; x_1 \sim q,\; x \sim p_t(x \mid x_1)} \\ &\qquad \bigl\| v_\theta(x, t) - u_t(x \mid x_1) \bigr\|^2 \end{aligned}

This works because of what least squares does with targets that vary given the input: the minimizing function is their conditional expectation, which by the equation above is exactly the marginal field. Training on closed-form per-example targets therefore optimizes the intractable marginal objective exactly, in expectation.

Lipman et al. prove the two statements that make this exact: the marginal field assembled from conditional fields generates the marginal path (Theorem 1), and LCFM\mathcal{L}_{\mathrm{CFM}} and LFM\mathcal{L}_{\mathrm{FM}} differ by a constant independent of θ\theta, so their gradients are identical (Theorem 2). The construction is the same one denoising score matching uses for diffusion models, generalized from scores to arbitrary velocity fields.

For a Gaussian conditional path N(μt(x1),σt(x1)2I)\mathcal{N}(\mu_t(x_1), \sigma_t(x_1)^2 I), the affine map ψt(x)=σt(x1) x+μt(x1)\psi_t(x) = \sigma_t(x_1)\, x + \mu_t(x_1) pushes standard noise onto the path, and Theorem 3 derives the unique field whose flow is that map (primes denote time derivatives):

ut(x∣x1)=σt′(x1)σt(x1)(x−μt(x1))+μt′(x1)u_t(x \mid x_1) = \frac{\sigma_t'(x_1)}{\sigma_t(x_1)} \bigl(x - \mu_t(x_1)\bigr) + \mu_t'(x_1)

No ODE is solved during training. Papers do not share a time convention (the flow-matching paper puts noise at t=0t = 0 and data at t=1t = 1; much of the diffusion literature and several flow-matching systems run the other way), and velocity signs flip with the convention, so equations cannot be copied across papers without checking it.

The path is a free choice: diffusion paths are special cases, the OT path is the alternative

The other half of the framework is that μt\mu_t and σt\sigma_t are free choices: the VP diffusion schedule recovers the diffusion path exactly.

Two conditional paths from noise to one data sample

VP diffusion path

  • Arises from a forward noising process; never reaches the noise distribution in finite time
  • The conditional field rotates as tt advances
  • Trajectories can overshoot the endpoint and backtrack

Optimal-transport path

  • Mean and standard deviation linear in time
  • Constant target along each trajectory; only the field's scale depends on tt
  • Trajectories stay straight
Diffusion conditional score function versus OT conditional vector field over time
The diffusion score changes direction over time; the OT field keeps a constant direction. Source: Flow Matching for Generative Modeling, Figure 2, p. 6.What to see

across the four time panels, the diffusion path's conditional score (left) changes direction and magnitude as t advances, while the OT path's conditional vector field (right) keeps a constant direction.

View full size: Diffusion conditional score function versus OT conditional vector field over time
Curved diffusion sampling trajectories versus straight OT trajectories
Diffusion trajectories curve and backtrack; OT trajectories run straight. Source: Flow Matching for Generative Modeling, Figure 3, p. 6.What to see

trajectories of the diffusion conditional field (left) curve and backtrack; the OT conditional trajectories (right) run straight to the same endpoints.

Conditional optimality does not make the marginal flow an optimal-transport map; rectified flow's reflow and minibatch OT coupling target that gap.

The OT path's equations, why its target is simpler, and what still separates diffusion from flow matching

The optimal-transport (OT) path makes mean and standard deviation linear in time:

μt(x1)=t x1σt(x1)=1−(1−σmin⁡) txt=(1−(1−σmin⁡) t) x0+t x1ut(xt∣x1)=x1−(1−σmin⁡) x0\begin{aligned} \mu_t(x_1) &= t\, x_1 \\ \sigma_t(x_1) &= 1 - (1 - \sigma_{\min})\, t \\ x_t &= \bigl(1 - (1 - \sigma_{\min})\, t\bigr)\, x_0 + t\, x_1 \\ u_t(x_t \mid x_1) &= x_1 - (1 - \sigma_{\min})\, x_0 \end{aligned}

The conditional flow is the optimal-transport displacement map between the two endpoint Gaussians: each conditional sample moves along a straight line at constant speed, the minimal-cost interpolation under squared distance. Along its own trajectory, the regression target is the constant x1−(1−σmin⁡) x0x_1 - (1 - \sigma_{\min})\, x_0; as a field over all of space, utu_t factors as g(t) h(x∣x1)g(t)\, h(x \mid x_1), so its direction at any point never changes and only its scale depends on tt, a simpler regression target than one that rotates as tt advances. And conditional sampling trajectories stay straight, where diffusion-path trajectories can overshoot the endpoint and backtrack.

The other half of the framework is that μt\mu_t and σt\sigma_t are free choices. Setting them to the schedule of the variance-preserving (VP) diffusion process recovers that diffusion path exactly, and the conditional field Theorem 3 assigns it coincides with the drift of score-based diffusion's probability-flow ODE (Appendix D of the paper).

Deterministic diffusion sampling and flow-matching sampling are therefore the same operation, an ODE solve, and on the same path the ideal field is identical. What distinguishes the methods is the regressed quantity, its loss weighting, and which paths the construction can express: diffusion paths must arise from a forward noising process, and one inherited consequence is that they never reach the noise distribution in finite time, so the prior at t=0t = 0 is only ever approximated.

Conditional optimality does not make the marginal flow an optimal-transport map. Where conditional paths cross, the marginal field is a posterior average of disagreeing conditional velocities, so marginal trajectories still curve; the paper claims only that the marginal field stays relatively simple, and closing this gap is what rectified flow's reflow procedure and minibatch OT coupling target.

The score target's scale diverges; the velocity loss measures the field the solver integrates

Two mechanisms separate the objectives: the target's scale, and what the loss measures.

Property Score (diffusion) Velocity (OT)
Scale near data diverges, d/σt2d/\sigma_t^2 constant
Loss weight λ(t)\lambda(t) required none
Loss measures score error solver's field
NFE over training swings stable

The two mechanisms

Target scale

The score target's norm diverges as d/σt2d / \sigma_t^2 near the data, so score losses need a per-time weight λ(t)\lambda(t); the OT velocity target needs none.

What the loss measures

CFM weights the error of the solver's own field uniformly over time; the score loss weights the same error differently.

Adaptive-solver NFE over training for score matching and flow matching
Score matching's sampling cost swings over training; flow matching's stays near its final value. Source: Flow Matching for Generative Modeling, Figure 10, p. 21 (CIFAR-10, dopri5 solver at tolerance 1e-5).What to see

the score-matching curve (labelled score_dif, the top curve) is the unstable one, spiking past 1,000 evaluations and drifting for hundreds of epochs, while both flow-matching curves stay near their final cost, the OT model (fm_ot, the lowest curve) cheapest.

Grad-TTS documents what that looks like: its diffusion loss converges early and then barely moves while output quality keeps improving across 1.7 million training iterations.

The comparison in full, the target-scale arithmetic, the drift-error weighting, and the Grad-TTS explanation
Property Score target (diffusion) Velocity target (OT path)
Target scale as the path reaches the data Diverges: expected squared norm d/σt2d / \sigma_t^2 The same distribution at every tt
Per-time loss weight Required: every score-matching recipe inserts λ(t)\lambda(t) None
What the loss measures Score error; the solver's drift error is a different time-weighting The error of the field the ODE solver integrates
Evidence Adaptive-solver NFE changes drastically over training; Grad-TTS's loss barely moves while quality keeps improving Adaptive-solver NFE stays near its final value from the first epochs

The first mechanism is target scale: as the path concentrates onto the data, an unweighted score regression is dominated by the times nearest the data, while the OT velocity target needs no weighting.

For a Gaussian conditional path, the score (the gradient of the log density, which diffusion training regresses onto) is −(x−μt)/σt2=−x0/σt-(x - \mu_t) / \sigma_t^2 = -x_0 / \sigma_t, with expected squared norm d/σt2d / \sigma_t^2 in dd dimensions. As the path concentrates onto the data (σt→0\sigma_t \to 0), the target's scale diverges, so an unweighted score regression is dominated by the times nearest the data, and every score-matching recipe inserts a per-time loss weight λ(t)\lambda(t) to compensate. The weightings are heuristics: Grad-TTS, a score-based TTS model, weights its per-time losses by λt\lambda_t and states the rule it follows, that weights should be proportional to 1/E∥target∥21 / \mathbb{E}\|\text{target}\|^2. The OT velocity target needs no weighting; its distribution is the same at every t. The same arithmetic says why a path ending in a near-point mass is trainable under velocity regression and pathological as a score target, whose norm at the endpoint scales as 1/σmin⁡1 / \sigma_{\min}.

The second mechanism is what the loss measures: the CFM loss weights the error of the solver's own field uniformly over time, while the score loss and the error the solver accumulates are different weightings of the same error.

The second is what the loss measures. The CFM loss is the squared error of the field the ODE solver will integrate, weighted uniformly over tt. Score matching trains a score network, and the sampler then assembles the drift from it, with the score entering scaled by β(1−t)/2\beta(1-t) / 2 on the VP path (β\beta is the VP noise schedule; the 1−t1-t argument is the time-convention flip noted above). Converting squared score error into squared drift error therefore means weighting by (β(1−t)/2)2(\beta(1-t) / 2)^2, and neither standard recipe uses that weight: original score matching takes λ(t)=σt2\lambda(t) = \sigma_t^2 and ScoreFlow takes β(1−t)\beta(1-t). The trained loss and the error the solver accumulates are different time-weightings of the same error, so one can be low while the other is not.

The authors' explanation is that score estimates inaccurate on a small subset of t barely move the weighted loss but break the ODE solve whenever the solver lands there. That much is true of any time-integrated loss, flow matching's included; what flow matching removes is the systematic mismatch.

With an adaptive solver, the number of function evaluations (NFE, how many times the solver calls the network) needed to sample a score-matching model changes drastically over training, while the flow-matching models' sampling cost stays near its final value from the first epochs.

Two ablations separate the objective from the path

The flow-matching paper trains the same U-Net architecture with the same hyperparameters under five configurations (three diffusion losses, flow matching on two paths), with the baselines allowed more training iterations to converge.

Same U-Net, five objectives, ImageNet-64 (lower is better)

FID

DDPM (noise)
17.36
Score matching
19.74
ScoreFlow
24.95
FM, diffusion path
16.88
FM, OT path
14.45

Adaptive-solver NFE

DDPM (noise)
264
Score matching
441
ScoreFlow
601
FM, diffusion path
187
FM, OT path
138

FM with the OT path is best on every dataset and metric in the paper's full Table 1; on the fixed VP path, only the constant-scale targets (noise and velocity) stay stable.

Full Table 1 with CIFAR-10 FID, where flow matching does not dominate, and training cost
Loss ImageNet-64 FID ImageNet-64 NFE CIFAR-10 FID
DDPM (noise matching) 17.36 264 7.48
Score matching 19.74 441 19.94
ScoreFlow 24.95 601 20.78
FM, diffusion path 16.88 187 8.06
FM, OT path 14.45 138 6.35

Source: Flow Matching for Generative Modeling, Table 1, p. 8. FID is Frechet Inception Distance, lower is better; the NFE column is the adaptive solver's evaluation count averaged over 50K samples. DDPM regresses the added noise; ScoreFlow is score matching with a likelihood-motivated weighting. None of these unconditional models is tuned for absolute state of the art (the paper suggests the architecture was not optimized for CIFAR-10 at all), so read the columns as controlled within-table contrasts.

FM with the OT path is best on every dataset and metric in the paper's full Table 1, test likelihood included. The within-path contrast carries the objective claim: holding the VP diffusion path fixed, the two score parameterizations degrade sharply on CIFAR-10 while the two constant-scale regression targets, DDPM's noise (a standard Gaussian at every t) and FM's velocity, stay stable. A well-conditioned target buys the stability whether it is noise or velocity; what noise matching does not buy is cheap integration, a roughly 40% higher adaptive-solver cost than FM on the identical path.

The objective's advantage is robustness rather than uniform dominance: score matching edges FM-on-diffusion on ImageNet-32 (FID 5.68 against 6.37, with a lower adaptive NFE as well). Training cost moves the same direction, though only across papers: the ImageNet-128 FM-OT model reached its reported FID on a third fewer total training images than the ADM baseline of Dhariwal and Nichol, with a model 25% larger and otherwise differently tuned.

Voicebox replicates the result in speech: one model and dataset, trained three ways, scored by zero-shot TTS word error rate.

Voicebox zero-shot TTS, WER % (lower is better; ground truth 2.2)

50K updates, NFE 32

FM, OT path
2.5
FM, diffusion path
76.0
SM, diffusion path
73.3

150K updates, NFE 32

FM, OT path
2.1
FM, diffusion path
2.6
SM, diffusion path
5.1

150K updates, NFE 4

FM, OT path
2.4
FM, diffusion path
11.5
SM, diffusion path
94.5

At 50K updates only the OT path is usable; at four evaluations only the OT model still is.

The Voicebox objective table, and what each column shows

Voicebox replicates the factorization in speech: one model, one dataset, trained three ways (FM with the OT path, FM with the VP diffusion path, score matching with the same diffusion path), evaluated as zero-shot TTS by WER, the word error rate of an ASR model transcribing the synthesized speech. The comparison runs in a reduced setup with a lowered learning rate so that all three objectives converge.

Objective WER, 50K updates (NFE 32) WER, 150K updates (NFE 32) WER, 150K updates (NFE 4)
FM, OT path 2.5 2.1 2.4
FM, diffusion path 76.0 2.6 11.5
SM, diffusion path 73.3 5.1 94.5

Source: Voicebox, the objective-comparison tables in Section 5.8 (Tables 8 and 9 in the arXiv version). For scale, ground-truth recordings score WER 2.2 on this evaluation.

At a 50K-update budget only the OT path yields a usable model; both diffusion-path variants still fail to produce intelligible speech. At 150K updates the objective swap on the identical path cuts WER roughly in half, and the path swap closes the rest of the gap to ground truth. In the low-NFE column both factors matter, but only the OT model stays usable at four evaluations, and score matching is still degraded at the table's maximum of 32.

Sampling: the NFE is chosen at inference time, and the path shifts the quality/NFE trade-off

Any off-the-shelf ODE solver samples the learned field, so the quality/latency trade-off is chosen at inference time, per run; the path changes where it sits.

ODE solution error and FID versus NFE for the three objectives
FM-OT reaches a given numerical error, and near-converged FID, at the fewest evaluations. Source: Flow Matching for Generative Modeling, Figure 7, p. 9 (ImageNet-32, fixed-step solvers).What to see

in the left panel the FM-OT model (labelled FM-OT, the lowest curve at high NFE) reaches a given numerical error at the fewest evaluations, and in the FID panels FM-OT sits near its converged quality at NFEs where score matching has not yet left the high-FID regime.

View full size: ODE solution error and FID versus NFE for the three objectives

Fixed-step solvers, ImageNet-32

  • Roughly 60%of the diffusion-path models' function evaluations, for FM-OT at the same numerical error
  • WER 2.4Voicebox FM-OT at NFE 4, the speech version of the same gap
How the solver sets the operating point, and the fixed-step comparison in words

Any off-the-shelf ODE solver turns a noise draw into a sample by integrating the learned field, and with a fixed-step solver the NFE is proportional to the step count, so the quality/latency operating point is chosen at inference time, per run, with no retraining. Deterministic diffusion samplers share that property; what the path changes is where the trade-off sits.

On ImageNet-32 with the same fixed-step solvers, the FM-OT model reaches the same numerical error as the diffusion-path models with roughly 60% of the function evaluations and keeps usable FID at very low NFE, and Voicebox's NFE=4 column above is the speech version of the same gap.

Classifier-free guidance transfers unchanged: train with condition dropout, then mix the conditional and unconditional fields at every solver step, doubling network evaluations for a fixed NFE (how the guidance scale works). In audio the objective appears at more than one interface:

Where it runs Example
Whole mel spectrograms Voicebox
Autoencoder latents latent audio encoders
Inside encoder training SAME
The three audio interfaces in full

Where flow matching sits in audio systems

Whole spectrograms

Voicebox generates whole mel-spectrogram sequences with it.

Autoencoder latents

A growing family generates the latents of a pretrained audio autoencoder, the setting whose encoder-side requirements are covered in Latent audio encoders: reconstruction sets the ceiling, not the ranking.

Inside autoencoder training

SAME makes generation difficulty an autoencoder training loss trains a small flow-matching model jointly with a music autoencoder and backpropagates its loss into the encoder, shaping the latent space the downstream generator inherits.

Sources

All 7 sources and what each supports