FLUX.1, Stable Diffusion 3, Stable Video Diffusion — the 2025 generation of state-of-the-art image and video models all share one secret: they're not diffusion anymore. They're flow matching. Same idea (noise → data), but straighter paths through latent space, fewer sampling steps, sharper outputs. This is the algorithm that's quietly replacing DDPM as the field's new default.
Learning Objectives
After this lesson, you will be able to:
Explain the ODE-based flow matching framework and why it produces straighter generation paths than diffusion's stochastic SDE
Derive the flow matching training objective -- predicting the velocity field v = x_1 - x_0 along linear interpolation paths
Compare rectified flows (iterative straightening) and consistency models (endpoint prediction) as strategies for 1-4 step generation
Understand why flow matching is replacing diffusion in next-gen models like FLUX and Stable Diffusion 3, and why straighter paths need fewer ODE solver steps
Flow matching is the cutting edge of generative AI. If diffusion models felt like magic, flow matching is the upgrade that makes the magic faster and more elegant. Do not worry if the ODE math looks intimidating -- the core intuition is simple: straight paths need fewer steps than curvy ones.
Your Reflection
Saves automatically
What’s one thing you learned? What’s still confusing?
Rectified flows are like a city planner who observes thousands of taxi routes and then builds a new highway system -- straightening the most-traveled paths into expressways. After each round of road improvement, the routes become straighter, and eventually you can drive almost as fast as the helicopter.
The destination (image quality) is the same. The path is what changed. Straighter paths = fewer steps = faster generation = lower cost = better user experience.
Diffusion models broke the GAN monopoly on image generation. Now flow matching is poised to evolve beyond the diffusion paradigm itself. The key insight: we do not need the complex forward-reverse noise process. We just need to learn a smooth transformation from noise to data.
In diffusion models, we define a noising process (forward SDE) and learn to reverse it (reverse SDE). The paths from data to noise are inherently curved because the SDE adds noise stochastically. The whole SDE / probability-flow ODE picture rests on stochastic calculusStochastic CalculusStochastic calculus extends derivatives to random processes — Brownian motion, Itô integrals, and stochastic differential equations. The math diffusion models, flow matching, and score-based generative models all live in.Learn more →; flow matching trades the stochastic forward kernel for a deterministic ODE while staying in the same mathematical universe.
In flow matching, we directly learn a velocity field that transports samples from noise to data along an ODE (ordinary differential equation):
dtdxt=vθ(xt,t),t∈[0,1]
Try it! Draw two dots on paper (one is "noise", one is "data"). Draw a curvy path between them with 20 waypoints (diffusion). Now draw a straight line between them with 4 waypoints (flow matching). Both connect the same two points, but the straight line needs far fewer steps. That visual IS the core idea of flow matching.
The key difference from diffusion: there is no stochastic noise injection during generation. The transformation is a deterministic ODE, which enables:
Straighter paths (fewer steps needed)
Exact invertibility (run the ODE backward to encode)
Simpler theory (ODEs are better understood than SDEs)
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.
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.
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.
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. Because rectified flows learn nearly straight paths, even simple Euler with 4-8 steps produces high-quality results.
The ODE integration carries the noise sample along a smooth, approximately straight path through latent space until it arrives at a valid data sample at t = 1. Unlike diffusion's 1000-step stochastic reverse process, flow matching follows a deterministic ODE along paths that are as straight as possible. Straighter paths mean fewer solver steps, which is why flow matching models like FLUX and SD 3 generate high-quality images in 20-28 steps -- and with rectification, as few as 1-4 steps.
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).
What Do You Think?
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, the learned velocity field is not perfectly straight (because the same noise point must map to different data points depending on the training distribution), so a few steps are needed. But the paths are much straighter than diffusion's curved trajectories, which is why flow matching models need far fewer steps.
Consistency models (Song et al., 2023) take a different approach to few-step generation. Instead of straightening paths, they directly enforce a consistency property: any point along a trajectory should map to the same final output.
fθ(xt,t)=fθ(xt′,t′)∀t,t′ on the same trajectory
Consistency models can be trained in two ways:
Consistency distillation: Distill a pretrained diffusion model into a consistency model
Consistency training: Train from scratch using the consistency property
The result: 1-2 step generation with quality approaching full diffusion models. The Latent Consistency Model (LCM) applied this to Stable Diffusion, enabling near-real-time image generation.
A parallel revolution is happening in architecture. The U-Net, which served as the backbone of every diffusion model from DDPM to SDXL, is being replaced by the Diffusion Transformer (DiT):
Aspect
U-Net
DiT (Diffusion Transformer)
Core mechanism
Convolutions + attention
Pure self-attention
Scaling
Limited by convolutional structure
Scales like language models
Spatial inductive bias
Strong (built into convolutions)
Learned (no built-in bias)
Training efficiency
Good at small scale
Better at large scale (>1B params)
Used in
SD 1.5, SD 2.x, SDXL
SD 3, FLUX, Sora, DALL-E 3
The shift to transformers is driven by the same insight that powered the LLM revolution: transformers scale better with data and compute than any other architecture. For generative models above ~1B parameters, DiT outperforms U-Net.
The generation step in flow matching involves solving an ODE numerically. The choice of ODE solver directly affects quality and speed:
Euler method: The simplest solver. Take the predicted velocity and step forward: x_{t+dt} = x_t + v(x_t, t) * dt. Fast but inaccurate with large steps.
Heun's method (2nd order): Evaluate the velocity at the start and predicted end of each step, average them. Twice the compute per step but much more accurate, often allowing half the number of steps.
DPM-Solver++: A purpose-built ODE solver for diffusion/flow models. Exploits the structure of the problem to achieve excellent quality in 15-25 steps.
Euler: xt+Δt=xt+vθ(xt,t)⋅Δt
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 rectified flows are nearly straight, which is why Euler with 4-8 steps works surprisingly well.
Tests · Generate noise-data pairs and compute velocity targets. Run Euler ODE solver with 1, 4, and 20 steps. Verify that straight paths converge with fewer steps. Compare curved vs straight path deviation.
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 faster to traverse than curved ones. Rectified flows straighten the transport paths, reducing the number of steps needed from 50-1000 (diffusion) to as few as 1-4 steps
Consistency models enable single-step generation. By learning to map any point along a trajectory directly to its endpoint, consistency models achieve near-instant generation with minimal quality loss
Flow matching is replacing diffusion in next-generation models. FLUX, Stable Diffusion 3, and other cutting-edge models use flow matching for faster, more stable training and higher-quality generation
What is the key advantage of flow matching over traditional diffusion models?
You now understand the cutting edge of generative model architectures: flow matching, rectified flows, and consistency models. These techniques are making generation faster without sacrificing quality, opening new frontiers in real-time and interactive AI. Next up: Multimodal Generation -- extending these ideas beyond images to video, 3D, audio, and beyond.