Train a network to point from noise toward data along straight lines, with no ODE solver inside the training loop. Then a sampler reaches the data in about 10 steps, where a curved diffusion path needs 100 or more.
Pick a path, then drag the number of solver steps down. Watch the curved path miss the data while the straight path still lands. Then we build, piece by piece, how to train those straight paths without ever simulating an ODE.
You need probability distributions and sampling, basic ODEs and a feel for score matching or diffusion. We build the rest from zero.
Yaron Lipman, Ricky T. Q. Chen, Heli Ben-Hamu, Maximilian Nickel and Matt Le, Meta AI, 2022.
A toy, not the paper’s experiment. The data are eight points on a ring of radius 3.5; the noise is a unit Gaussian. Both paths use their exact velocity field for this data (the average of the conditional fields, Chapter 4), integrated with Euler steps. The diffusion path is the usual linear-beta VP schedule; the straight path is xt = (1 − t) x0 + t x1. A dot counts as landed if it ends within 0.45 of a data point. The paper’s own numbers are in Chapter 7.
Chapter 0
See why straight noise-to-data paths are worth having, and why they were out of reach until training stopped needing an ODE solver
You want to turn noise into images. Diffusion models do this brilliantly, but they found an unintuitive trick: add noise gradually, then learn to reverse it. The resulting trajectories from noise to data are curved, wandering paths through high-dimensional space.
What if you could just learn straight lines from noise to data? Straight lines are faster to traverse (fewer ODE steps at inference), easier to learn (a simpler vector field) and more stable to train. But there is a catch. The elegant framework for this, Continuous Normalizing Flows, has been impractical, because training one requires simulating ODEs, which is extremely expensive.
The key advantages of Flow Matching over traditional diffusion training:
The same six noise dots and six data dots, joined two ways. Diffusion models follow the curved dashed paths (warm). Flow Matching with OT follows the straight paths (teal). Press Resample to draw new pairs.
Illustrative: the pairs are random and the curved path is a smooth bow through the middle, standing in for a diffusion trajectory. The path lengths are measured live on this picture, in screen pixels.
The page follows the paper’s own order: the flow, the obstacle, the trick that removes it, the loss, the best path, and what it unifies.
Chapter 1
Move a cloud of noise to a cloud of data by following a vector field through time
A Continuous Normalizing Flow (CNF) defines a generative model by moving samples along a time-dependent vector field. Think of it as a river: at time t = 0 you drop particles into noise, and the flow carries them to data at t = 1.
A CNF is defined by a vector field vt : Rd → Rd that generates a flow φt via the ODE:
Starting from φ0(x) = x (identity at t = 0), the flow map φt transforms samples from the source distribution p0 (noise) to the target distribution p1 (data). At each time t, there is an intermediate distribution pt = [φt]# p0, the pushforward of p0 through φt.
The densities pt satisfy the continuity equation:
This is a conservation law: probability mass is neither created nor destroyed, it just flows. The vector field vt generates the probability path pt. Given vt, you can compute pt by solving this PDE (or equivalently, by simulating the ODE and pushing samples forward).
To generate a sample, draw x0 ~ p0 = N(0, I), then solve the ODE forward from t = 0 to t = 1 using an ODE solver (Euler, RK45, etc.):
With a learned vθ, this gives you a sample from the model’s approximation of q (the data distribution).
Particles start as noise (t = 0) and flow to data (t = 1) along the vector field. Drag the time slider to see the intermediate clouds.
Illustrative: twelve seeded particles that move in straight lines from a noise sample to a data sample, to show the idea of a flow. A real CNF learns the field that does this for a whole data set.
Chapter 2
Find out why a beautiful generative model hit a wall, and what the wall was made of
We have a beautiful generative model: learn vθ, integrate it to generate samples. But how do we train vθ? This is where CNFs ran into a wall for years.
The most natural objective is to match our learned vector field to the true one that generates the data distribution:
Here ut is the vector field that generates a probability path pt interpolating between p0 and the data distribution q.
Problem 1: We don’t know ut. It’s defined implicitly as whatever vector field generates pt via the continuity equation. There’s no closed-form expression for the marginal ut(x).
Problem 2: Even if we could compute ut, sampling from pt requires simulating the ODE forward from t = 0, which means running an ODE solver inside the training loop. This is the same issue that plagued original CNF training (FFJORD): backpropagating through an ODE solver is expensive, memory-intensive and numerically unstable.
Flow Matching’s insight: we can get the simplicity of score matching (closed-form targets, no simulation) but for any probability path, not just diffusion paths.
ODE-based training needs expensive forward and backward solves at every step. Flow Matching needs a single network evaluation. Choose a method to read its cost.
Illustrative: the heights are the page’s rough estimates, not measured numbers from the paper. They follow the text above: simulation-based CNF training costs 10 to 100 times more per step than a diffusion step, and DDPM and Flow Matching both use one forward pass.
Chapter 3
Aim at one data point at a time, and turn an impossible target into a one-line formula
Here is the key insight that unlocks everything. Instead of thinking about the marginal probability path pt (which is intractable), we think about conditional probability paths pt(x | x1): the path from noise to a specific data point x1.
Define a conditional probability path pt(x | x1) that:
The simplest choice is a Gaussian conditional path:
Here μt and σt are differentiable functions of t with boundary conditions μ0 ≈ 0, σ0 ≈ 1, μ1 = x1, σ1 ≈ 0.
For any Gaussian conditional path, there exists a unique vector field ut(x | x1) that generates it (via the continuity equation). For Gaussian paths, it has a closed-form expression:
This is exact. No approximation. No simulation needed. Given a sample xt from pt(x | x1), we can compute the vector field analytically.
Sampling from pt(x | x1) is trivial via reparameterization:
For the simplest choice (linear interpolation, a.k.a. Optimal Transport path):
This is just linear interpolation between a noise sample and a data sample! And the conditional vector field becomes:
The target is simply the displacement from noise to data. It is constant in time. A straight line.
Each data point x1 (warm) defines a conditional path from a noise sample x0. The conditional vector field is constant: x1 − x0. Drag the time and watch each dot ride its path with the same arrow.
Illustrative: five made-up data points and three seeded noise samples for each. The paths are xt = (1 − t) x0 + t x1, exactly as in the text, and the arrow is x1 − x0 drawn at the dot.
Chapter 4
Prove that the easy conditional loss trains the same field as the impossible marginal one, then write the training step
We now have all the pieces. The conditional vector field ut(x | x1) is tractable. But we want to learn the marginal vector field ut(x) that generates the marginal pt. How does conditioning on x1 help?
The crucial mathematical result (Theorem 2 in the paper): the marginal probability path can be recovered by marginalizing over the conditional paths:
And the marginal vector field that generates this pt is:
This is still intractable (it involves an integral over all data points). But here is the punchline:
Define the Conditional Flow Matching (CFM) loss:
The proof uses a simple trick. Expand LFM:
The cross term ⟨vθ(t,x), ut(x)⟩ under Ex ~ pt can be rewritten by substituting the marginal expressions. After expanding pt(x) = ∫ pt(x|x1)q(x1)dx1 and ut(x) as its conditional mixture, the cross term becomes Ex1 ~ q Ex ~ pt(x|x1) ⟨vθ, ut(x|x1)⟩, which is exactly the cross term in LCFM. The squared norms also match up to constants independent of θ.
With OT conditional paths, training is beautifully simple:
# Flow Matching training step (OT path) def fm_step(model, x1, optimizer): # x1: batch of data samples [B, d] t = torch.rand(B, 1) # sample time x0 = torch.randn_like(x1) # sample noise xt = (1 - t) * x0 + t * x1 # interpolate target = x1 - x0 # conditional vector field pred = model(t, xt) # predict vector field loss = (pred - target).pow(2).mean() loss.backward() optimizer.step()
That’s it. Four lines of math. No ODE solver. No score function. No noise schedule to tune.
Chapter 5
Choose the straight path, and see where it leaves the diffusion path behind
Flow Matching works with any Gaussian conditional path. But which path should you choose? This is where the Optimal Transport (OT) path shines, and where FM decisively separates from diffusion.
The OT path uses linear interpolation:
For practical purposes with σmin → 0:
This is the displacement interpolation from Optimal Transport theory. The sample moves along a straight line from x0 to x1 at constant speed.
In OT theory, the optimal way to transport mass from one distribution to another (minimizing total displacement) is via straight lines. The conditional OT path xt = (1-t)x0 + tx1 moves each particle along the shortest path between its noise sample and its data target. While this is only the true OT map when conditioning on a single x1, the conditional paths still produce straighter marginal flows than diffusion paths.
The Variance Preserving path used by DDPM:
where αt = exp(−½ ∫0t β(s) ds) with some noise schedule β(t). This produces curved trajectories: the particle first drifts toward the origin (as noise is added), then curves toward x1 (as signal emerges).
Teal is OT (straight lines). Warm is diffusion VP (curved). Drag the time slider, or press Play, to animate. Notice how the OT paths cross directly while the diffusion paths bend through the middle first.
Illustrative: eight seeded pairs. The teal dots follow the exact OT formula. The warm dots follow a smooth curve that starts by shrinking toward the middle, standing in for a VP diffusion trajectory; its shape is a sketch, not a measurement from the paper.
Chapter 6
Show that score matching is Flow Matching on one particular path, and see what Flow Matching adds
Flow Matching doesn’t replace diffusion. It generalizes it. Score matching for diffusion models is a special case of Conditional Flow Matching when you choose the diffusion probability path.
Recall: in diffusion models, we have a noising process:
The score function is ∇x log pt(x | x1) = −(xt − αt x1) / σt2 = −ε / σt.
Denoising score matching trains the network to predict ε from xt.
Now, the conditional vector field for the diffusion (VP) path is:
Substituting x = αt x1 + σt ε:
This is a linear combination of ε and x1, exactly what diffusion models predict (up to reparameterization). Training a network to predict this vector field is equivalent to training it to predict ε or x1.
| Property | Diffusion (VP/VE) | Flow Matching |
|---|---|---|
| Path geometry | Curved (noise schedule-dependent) | Any, including straight OT lines |
| Training target | ε or x0 or score | Vector field (encompasses all above) |
| Inference | SDE/ODE solver (many steps) | ODE solver (fewer steps with OT) |
| Path flexibility | Locked to diffusion process | Any Gaussian path works |
| Noise schedule | Critical hyperparameter | Not needed (for OT paths) |
Rectified Flows (Liu et al., 2022) independently proposed the same OT conditional path xt = (1-t)x0 + tx1 and the same training objective. The key difference: Rectified Flows additionally proposed reflow, which iteratively straightens trajectories by using the model’s own predictions as new training pairs. Flow Matching provides the theoretical foundation (the equivalence theorem), while Rectified Flows provide the practical refinement technique.
Chapter 7
Read the ImageNet numbers, then see which models and robots now run on Flow Matching
Flow Matching isn’t just a theoretical curiosity. It achieves state-of-the-art results and has become the foundation for modern generative models.
On ImageNet 64×64 (unconditional), comparing different probability paths with the same architecture:
| Method | Path | NLL (bpd) | FID | NFE |
|---|---|---|---|---|
| FM + VP path | Diffusion (VP) | 0.97 | 4.31 | 142 |
| FM + OT path | Optimal Transport | 0.93 | 3.50 | 110 |
| DDPM (original) | Diffusion (VP) | 3.70 | 11.0 | 1000 |
| Score SDE (VP) | Diffusion (VP) | 2.99 | 2.41* | 2000 |
*Score SDE uses 2000 NFEs and Predictor-Corrector sampling. OT-CFM uses only 110 NFEs with an adaptive ODE solver.
The paper shows that FM with OT paths has significantly more stable training dynamics compared to VP paths:
Flow Matching has become the standard training paradigm for modern generative models:
OT paths (teal) reach a lower FID with fewer steps than VP diffusion paths (warm). Lower is better. Drag the budget to read both curves at the same number of function evaluations.
From the paper’s ImageNet 64×64 table: FM + OT reaches FID 3.5 at 110 NFE, and FM + VP reaches 4.3 at 142 NFE. The other points, and the lines between them, are an illustrative sketch of the shape of the trade-off, not measured values.
Chapter 8
Place Flow Matching in its lineage, sample from it in six lines, and pick what to read next
Flow Matching sits at the intersection of several major ideas in generative modeling and beyond. In one paragraph: a CNF moves noise to data along a vector field; training it used to need an ODE solver; conditioning on one data point at a time makes the target a closed-form arrow, with the same gradients as the impossible marginal loss; and the straight OT path makes that arrow constant, so a sampler needs only a handful of steps.
Chapter 4 gave the training step. Sampling is the other half: the same Euler loop the hero runs, with the number of steps as your quality knob.
# Flow Matching sampling: integrate the learned field with Euler steps @torch.no_grad() def sample(model, shape, steps=10): x = torch.randn(shape) # x0 ~ N(0, I) for k in range(steps): t = torch.full((shape[0], 1), k / steps) x = x + model(t, x) / steps # x += v(t, x) * dt return x # x1 ~ model of the data
Ready to test yourself? Open Present to explain the idea out loud, or Teach to draw it on a whiteboard. Or go back to the hero and drag the steps down once more.