Flow matching & rectified flow
Diffusion's reverse path is a curved, stochastic, thousand-step trajectory. Flow matching asks a simpler question: why not learn a straight path from noise to data? Train a network to predict a velocity field, then follow it with a few ODE steps. It's the formulation behind SD3, Flux, and modern video models — same destination, far simpler road.
What you'll learn
- The probability path from noise to data, and the velocity field
- Why a straight-line (rectified) flow needs far fewer sampling steps
- How flow matching differs from diffusion — ODE vs SDE, straight vs curved
- Why modern generators (SD3, Flux) moved to flow matching
Before you start
Diffusion generates by reversing a noising process — a curved, stochastic trajectory that needs hundreds to a thousand steps. Flow matching reframes the whole thing around a much simpler question: instead of undoing noise step by step, learn a velocity field that flows noise straight to data, then just follow it.
A straight path and a constant velocity
Pick a path from a noise sample x₀ to a data sample x₁. The simplest possible one is a
straight line: x_t = (1−t)·x₀ + t·x₁ for t from 0 to 1. Along a straight line the velocity
is constant — v = x₁ − x₀ — and that’s exactly what the network learns to predict at each point.
Sampling is then just following the velocity field with a few ODE steps:
import numpy as np
x0 = np.array([0.0, 0.0]) # a noise sample
x1 = np.array([3.0, 4.0]) # the target data point
v = x1 - x0 # constant velocity along the straight (rectified) path
x, steps = x0.copy(), 4
for i in range(steps):
x = x + v / steps # Euler step along the straight line
print(f"step {i+1}: x={x.round(2)}")
print(f"reached the data point in {steps} steps (vs ~1000 for DDPM)")
step 1: x=[0.75 1. ]
step 2: x=[1.5 2. ]
step 3: x=[2.25 3. ]
step 4: x=[3. 4.]
reached the data point in 4 steps (vs ~1000 for DDPM)
Four Euler steps along a straight line land exactly on the data point. Of course a single training pair has a trivial straight path; the real model learns a velocity field over the whole distribution (the field that, in expectation, transports the noise distribution to the data distribution — conditional flow matching makes this trainable by regressing the per-sample velocities). The payoff is that straighter paths need fewer steps.
Flow matching vs diffusion
They reach the same destination — transport a noise distribution to the data distribution — but the road differs. Diffusion solves a stochastic differential equation along a curved path (noise injected at every step), needing many steps. Flow matching solves a deterministic ODE along a straight(er) path, so it samples in far fewer steps and has a cleaner training objective (regress a velocity, no noise schedule to tune). Rectified flow even “reflows” the learned paths to be nearly straight, approaching one-step generation.
In one breath
- Flow matching learns a velocity field that flows noise to data along a chosen path, instead of reversing a noising process step by step.
- The simplest path is a straight line
x_t = (1−t)x₀ + t x₁with constant velocityv = x₁ − x₀; sampling follows the field with a few ODE (Euler) steps (the demo: 4 steps vs ~1000). - The model learns the field over the whole distribution (conditional flow matching regresses per-sample velocities to make training tractable).
- vs diffusion: deterministic ODE along a straight path (few steps, clean objective) vs stochastic SDE along a curved path (many steps); rectified flow straightens further toward one-step generation.
- It’s the same noise→data goal, simpler road — and the formulation behind SD3 and Flux (flow matching on a latent with a transformer backbone).
Quick check
Quick check
Next
Flow matching is the faster successor to diffusion, run inside the same latent-diffusion pipeline with a transformer backbone; all sit in the generative-models overview. How to measure these generators is generative evaluation.