Flow Matching & Beyond
Random numbers with no pattern. Generation starts from noise and ends at a picture.
The route one sample takes from a noise point to a data point. It can be straight or curved.
The direction and speed a sample should move at one moment. The network predicts it.
A rule that says how a point moves, given where it is and the time. Following it step by step draws the path.
One small move along the ODE. Each step costs one run of the network, so fewer steps is cheaper.
Flow matching trained on straight lines from noise to data. Stable Diffusion 3 and FLUX.1 use it.
Training a small fast model to copy a large slow one. It is how 1 to 4 step models are made.
After this lesson, you will be able to:
- Explain the ODE-based flow matching framework and why its straight training paths can be solved with larger steps than a typical diffusion path
- Derive the flow matching training objective — predicting the velocity field v = x_1 - x_0 along linear interpolation paths
- Compare rectified flows (iterative straightening) with consistency models (endpoint prediction, taught in full in their own lesson) as routes to 1-4 step generation
- Describe how FLUX.1 and Stable Diffusion 3 use rectified flow, and why straighter paths let a solver take larger steps
Before you start
#Straight Lines Beat Curved Paths
Flow matching changes how the network is trained. You train directly on a straight line between a noise sample and a data sample. There is no alpha_bar schedule, which is the diffusion table that says how much of the picture is left at each step.
#From Diffusion to Flows: The Conceptual Shift
The real differences are three: the path, the target and the weighting of the loss across times. Straight paths are the part that helps a solver. The table puts the two recipes side by side.
| Diffusion | Flow matching | |
|---|---|---|
| Path from noise to data | Set by the noise schedule (alpha_bar), usually curved | A straight line, x_t = (1-t) x_0 + t x_1 |
| What the network predicts (target) | The noise, or the score | The velocity, x_1 - x_0 |
| Weighting of the loss across times | A design choice | A design choice. SD3 samples t from a logit-normal to stress middle times |
| Sampler | Noisy (DDPM, ancestral) or deterministic (DDIM, probability-flow ODE). Typical samplers use 20-50 steps | The ODE, with Euler, Heun or DPM-Solver++. FLUX.1 [dev] pipelines default to about 28 steps |
| Products | SD 1.5, SD 2.x and SDXL (U-Net backbone). Stable Video Diffusion is an EDM-style diffusion model | Stable Diffusion 3 and FLUX.1 (rectified flow) |
The recipe and the backbone are separate choices: a U-Net or a DiT (Diffusion Transformer) can be trained either way. Step counts are pipeline defaults as of Oct 2026, not benchmarks.
Three sources use three conventions, so settle them before reading any formula.
| Symbol | This lesson | Diffusion lessons | SD3 and FLUX papers |
|---|---|---|---|
| Clean data | x_1 | x_0 | x_0 |
| Noise | x_0 | epsilon | epsilon |
| t = 0 means | pure noise | clean data | clean data |
| t = 1 means | clean data | pure noise | pure noise |
| Path | x_t = (1-t) x_0 + t x_1 | x_t = sqrt(alpha_bar) x_0 + sqrt(1-alpha_bar) epsilon | x_t = (1-t) x_0 + t epsilon |
| Velocity target | x_1 - x_0 | not used (noise or score) | epsilon - x_0 |
Try it! Draw two dots on paper (one is "noise", one is "data"). Draw a curvy path between them with 20 waypoints. Now draw a straight line between them with 4 waypoints. Both connect the same two points, but the straight line needs far fewer waypoints to trace. That picture is the intuition behind straight training paths.
Generation here is a deterministic ODE. That alone does not separate it from diffusion, because a diffusion model's probability-flow ODE is also deterministic and also exactly invertible. What flow matching changes is the path and the training recipe:
- Straight training paths (less bending, so larger solver steps)
- A velocity target with no alpha_bar schedule
- A simple regression loss that needs no ODE solve during training
Why does a velocity field carry a whole density of samples from noise to data, and not just one point? Because probability mass is conserved: it can only move, never appear or vanish. In one dimension that single fact gives the equation every flow model rests on. The d-dimensional version and its log-density consequence are derived in Flow Matching: The Training Objective Behind SD3 and FLUX.
Drag the time slider along the path, then cut the step count and watch where the particles land.
Do: Press Play, then drop the step count from 40 to 5 and switch between field arrows and traces.Notice: With fewer steps the traces turn jagged but still land on the two moons.Why: Drawn stand-in, not a trained model. Real trained fields bend more where paths cross, so real models need more steps.
Now put the two kinds of path side by side, with the error counted for you.
Do: Set the steps to 1, switch between One target and Two targets, and drag the time slider from 0 to 1.Notice: With one target the straight flow lands exactly on it after a single step (error 0.00) while the curved flow misses by about 1.6. With two targets the straight flow's one step lands between them (error about 1.0), and by 5 steps its error is 0.00 against about 0.08 for the curved flow.Why: A straight path can be covered in one big step because the arrow stays the same, and a curved path needs many small steps because the arrow keeps turning. Drawn stand-in, not a trained model: both fields are exact for a data set of one or two points.
The five steps below come with a second picture, a drawn illustration of a curved path against a straight one.
Do: Change the step count and compare the wavy diffusion-style path with the straight flow-matching path.Notice: With few steps the wavy path misses its target by more than the straight one.Why: Drawn illustration, not a computed path or a trained model. It shows the idea: a bent path needs smaller steps to follow.
#Step 1: Source Distribution (Noise)
We start with samples from a simple source distribution — standard Gaussian noise N(0, I). Each sample is a random tensor with no structure. In the flow matching framework, this is time t = 0: the beginning of the transport path.
#Step 2: Target Distribution (Data)
At t = 1, we want to arrive at samples from the data distribution — real images of faces, landscapes, cats. The target distribution is complex, high-dimensional, and only known through training examples. The goal of flow matching is to learn the smooth transformation that connects these two distributions.
#Step 3: Learn Velocity Field v(x, t)
A neural network learns a velocity field v_theta(x_t, t) that tells every point in space how to move at every moment in time. At t = 0.0 near a noise sample, the velocity points toward data. At t = 0.5, the velocity refines the partially-formed image. The training target is simple: the straight-line direction from the noise sample to its paired data sample, v = x_1 - x_0.
#Step 4: ODE Integration
To generate an image, we start from a noise sample x_0 and follow the velocity field forward using an ODE solver. The Euler method takes discrete steps: x_(t+dt) = x_t + v_theta(x_t, t) * dt. Higher-order solvers (Heun, DPM-Solver++) take fewer steps for the same accuracy. Straighter paths let even simple Euler take larger steps, though production models still use tens of steps by default.
#Step 5: Transform Noise to Data in One Flow
The ODE integration carries the noise sample along a smooth path until it arrives at a valid data sample at t = 1. A diffusion model sampled with its probability-flow ODE is also deterministic, so compare like with like: the difference is the path, which is straighter here. FLUX.1 and SD 3 pipelines default to about 28 steps (as of Oct 2026). Getting to 1-4 steps takes distillation on top.
#The Training Objective: Predict the Velocity
Compare this to the diffusion training objective (predict noise): flow matching is arguably even simpler. The interpolation is linear (no alpha_bar schedules), the target is the straight-line direction from noise to data, and the time runs from 0 to 1 (no need for 1000 discrete timesteps).
If the optimal velocity field always pointed in the straight-line direction from the current x_t to the data x_1, how many steps would be needed for perfect generation?
In theory, if the velocity field were a perfect straight-line transport, one Euler step would suffice. In practice, at each point the learned field is the average of the straight paths that cross there, so it bends. The ODE is still deterministic: each noise vector follows one curve to one data point. The bend comes from the averaging (derived below), and straighter training paths keep it small.
A small case makes the curvature exact. Let the data be minus 1 or plus 1 with probability one half each, and the noise be a standard normal in one dimension. The derivation below gets the marginal velocity field in closed form, and it shows that the field is not constant even though every conditional path is a straight line.
Move the time t, the probe point, and the two data positions and their weights, and watch how many straight conditional paths cross the probe: the field the network learns is their weighted average, which bends where the paths cross, and at x = 0.3, t = 0.6 it is 1.273.
Do: Move the time, the probe point and the two data positions and weights.Notice: The arrow at the probe is the average of the straight paths crossing it, and it bends where they cross.Why: The network can only learn the average, since it cannot tell which data point a pair came from. Computed exactly, not trained.
#Rectified Flows: Straightening the Paths
#Consistency Models: One-Step Generation
Consistency models are a different route to few-step generation. They do not straighten paths. They train the network so that every point on one path maps to the same final picture, so one run of the network can be enough.
#Flow Matching in Practice: FLUX and SD 3
The latest production models have adopted flow matching:
Stable Diffusion 3 (Stability AI, 2024)
- Replaced the U-Net with a Multimodal Diffusion Transformer (MM-DiT)
- Uses flow matching (rectified flow) instead of DDPM noise scheduling
- Three text encoders: CLIP-L + CLIP-G + T5-XXL
- Reported better text rendering and prompt adherence than earlier Stable Diffusion models, in the SD3 paper
FLUX.1 (Black Forest Labs, 2024)
- 12B parameter transformer-based architecture
- Trained with rectified flow matching
- Distilled variants exist: FLUX.1 [schnell] is designed for 1-4 steps
- FLUX.1 [dev] pipelines default to about 28 steps and SDXL pipelines to about 50 (as of Oct 2026; default settings, not a benchmark)
In the convention of the SD3 and FLUX papers (see the table above), the same straight path is written:
#The Transformer Takeover: U-Net to DiT
The recipe (flow matching) and the network that follows it are separate choices. For several years the network was a U-Net. Newer models, such as Stable Diffusion 3, use a transformer, called a Diffusion Transformer (DiT).
#ODE Solvers: The Unsung Heroes
The generation step in flow matching involves solving an ODE numerically. The choice of ODE solver directly affects quality and speed:
x_{t+dt} = x_t + v(x_t, t) * dt. Fast but inaccurate with large steps.The beauty of rectified flows is that straighter paths reduce the solver's job. A perfectly straight path would give exact results with Euler in a single step, regardless of step size. Real learned fields are only partly straight, so Euler still needs several steps (the cell at the end measures how many, in a case we can solve exactly). Each Euler step costs one network evaluation, so N steps cost N evaluations, and the open question is how the error depends on N and on how curved the path is.
Flow Matching for Generative Modeling
Yaron Lipman, Ricky T. Q. Chen, Heli Ben-Hamu, Maximilian Nickel (2022)
Introduced conditional flow matching as a simple, scalable alternative to diffusion. Showed that linear interpolation paths can be trained as easily as diffusion noise prediction.
Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow
Xingchao Liu, Chengyue Gong, Qiang Liu (2022)
Introduced rectified flows: iteratively straighten transport paths so fewer solver steps are needed. SD3 trains on the straight-line path; reflow is a separate, optional procedure.
Consistency Models
Yang Song, Prafulla Dhariwal, Mark Chen, Ilya Sutskever (2023)
Proposed a new model family that directly maps any noise level to the clean output, enabling 1-2 step generation. LCM (Latent Consistency Models) applied this to Stable Diffusion.
Tests: Integrate the closed-form field with 1, 2, 4 and 8 Euler steps and read the spread column. One step should land every sample at the data mean (spread 1.0), and the spread should fall as the step count rises. The single known pair is exact for any N only because its velocity is the answer.
#Key Takeaways
- Flow matching learns velocity fields that transport noise to data. Instead of iteratively denoising, the model learns a vector field that maps noise directly to data along smooth paths, enabling more efficient generation
- Straight paths are easier to traverse than curved ones. Rectified flow trains on straight lines, and further reflow rounds straighten them more. Few-step models (1-4 steps) usually also need distillation, and they trade some quality
- Consistency models enable one- or two-step generation. By learning to map any point along a trajectory directly to its endpoint, they generate in very few steps, with some quality loss against many-step sampling
- FLUX.1 and Stable Diffusion 3 are trained with rectified flow. It is one design choice among several (with the transformer backbone and large-scale data), so credit it for a simpler recipe, not for all of their quality
#Quick Check
Which is a real difference between flow matching and standard diffusion training?