Flow matching

Also known as: rectified flow

On this page 7

Flow matching is a training method for generative models in which a neural network learns a time-dependent velocity field that transports samples from a simple noise distribution to the data distribution along continuous paths. Generation then means solving an ordinary differential equation: start from random noise and follow the learned velocity until the sample becomes an image, an audio clip or another data point.

In generative AI, flow matching has become one of the main alternatives to classic diffusion training. Its best-known variant, rectified flow, uses straight-line paths between noise and data, and this formulation underlies several current text-to-image and text-to-video systems, including Stable Diffusion 3 and the Flux model family. The method is valued for simulation-free training, stable optimization and the ability to generate good samples with relatively few solver steps.

How flow matching learns a velocity field

Flow matching trains a network to predict the direction and speed in which a partially noisy sample should move at a given time t between 0 and 1. The method defines a probability path, a family of intermediate distributions that begins at pure noise and ends at the data distribution, and asks the network to match the velocity that generates this path.

The key practical idea is conditional flow matching. The true velocity of the whole path is intractable, but for a single pair of a noise sample x0 and a data sample x1 the velocity is known in closed form. Regressing onto these per-pair targets gives the same gradient in expectation as regressing onto the intractable marginal velocity.

  1. Draw a data sample x1 and a noise sample x0 from a standard Gaussian.
  2. Draw a time t, often from a uniform or logit-normal distribution.
  3. Form the interpolated point x_t = (1 - t) * x0 + t * x1.
  4. Train the network so that its output at x_t and t approximates the target velocity x1 – x0 under a mean squared error loss.

Because the training point is computed directly, no differential equation has to be simulated during training. This simulation-free objective is what separated flow matching from earlier continuous normalizing flows, which required expensive solver calls inside every training step.

Probability paths and main variants

The behavior of a flow matching model is largely decided by the choice of probability path and coupling. The path determines how intermediate samples look, while the coupling determines which noise sample is paired with which data sample.

VariantPath or couplingMain property
Rectified flowStraight line, independent pairsSimple target, widely used in image models
Optimal transport pathLinear path with shrinking Gaussian widthNearly straight trajectories
Variance-preserving pathDiffusion-style Gaussian scheduleRecovers a diffusion model as a special case
Minibatch OT couplingNoise and data paired by optimal transport within a batchStraighter flows, fewer sampling steps
ReflowRetraining on pairs produced by an earlier modelProgressively straighter, few-step generation
Common flow matching formulations

Straight paths matter because a numerical solver follows a straight trajectory almost exactly with large step sizes. Curved trajectories require many small steps; this is the main reason rectified flow models often produce acceptable images in 20 to 30 steps rather than the 50 or more that older diffusion samplers needed.

Flow matching and diffusion models are closely related rather than opposed. A Gaussian diffusion process defines one particular probability path, and its noise prediction, score and velocity parameterizations can be converted into one another. The practical differences lie in the path, the prediction target and the time weighting.

Model familyWhat the network learnsSampling procedureTypical trade-off
Flow matchingVelocity fieldDeterministic ODE solveFast, stable training; several steps
Diffusion model (DDPM)Noise or scoreStochastic or ODE samplerMature tooling; often more steps
Normalizing flowInvertible mappingSingle exact passExact likelihood; restricted architectures
GANGenerator against a discriminatorSingle passVery fast; unstable training, mode collapse
Consistency modelDirect map to the clean sampleOne to few stepsFast; usually distilled or harder to train
Flow matching and neighboring generative model families

Compared with a GAN, flow matching gives stable regression training and good mode coverage at the cost of iterative sampling. Compared with a normalizing flow, it allows any network architecture, such as a diffusion transformer, because the learned map does not have to be invertible layer by layer.

Where flow matching is used

Flow matching is used wherever a team needs a high-quality continuous generative model with predictable training. Most large deployments operate in a compressed latent space produced by a variational autoencoder, exactly as in latent diffusion.

  • Text-to-image generation with diffusion transformer backbones and classifier-free guidance.
  • Text-to-video and image-to-video models, where fewer solver steps reduce very high inference costs.
  • Speech and audio synthesis, including zero-shot voice and sound generation.
  • Scientific domains such as protein structure, molecule and material generation, often on non-Euclidean spaces.

Inference settings have a strong effect on output. The table below summarizes the parameters that practitioners adjust most often when sampling from a flow matching model.

SettingTypical rangeEffect
Solver steps4-50More steps improve detail up to a plateau
Solver typeEuler, Heun, higher-orderHigher order gives accuracy per step at more cost
Timestep shift1.0-3.0 or resolution-basedSpends more steps at high noise for large images
Guidance scaleAbout 3-7Stronger prompt adherence, less diversity
Random seedAny integerFixes the starting noise and the result
Sampling settings that shape flow matching output

Limitations and common misconceptions

Flow matching is not a one-step generator by default. A model trained with independent noise and data pairs still learns curved marginal trajectories, because many different data points share overlapping noise regions; few-step quality usually requires reflow or distillation.

Other recurring points of confusion are worth stating precisely. Straight conditional paths do not imply straight learned flows, the exact likelihood is available only through costly divergence integration, and quality differences between flow matching and diffusion models often come more from data, scale and timestep weighting than from the formulation itself.

  • Timestep sampling matters: uniform sampling can undertrain the hard middle region, which is why logit-normal schemes are popular.
  • Deterministic sampling reduces diversity for a fixed seed; stochastic samplers can restore some variation.
  • Guidance still adds cost, since classifier-free guidance typically doubles network evaluations per step.

In simple terms

Imagine a cloud of random static and a gallery of real photographs. Flow matching teaches a model which way to push each speck of static, little by little, so that the cloud gradually becomes a believable photograph.

During training, the model sees points partway between noise and real pictures and learns the arrow that leads toward the picture. Later it starts from fresh noise and simply follows those arrows. When the arrows point along nearly straight routes, the model needs only a few moves to arrive, which is why these systems can create images quickly.

A practical example

A design studio runs an open-weight rectified flow image model on a single workstation GPU to produce concept art for a client presentation. The default workflow uses 28 Euler steps at 1024 by 1024 pixels with a guidance scale of 3.5, and each image takes roughly fifteen to twenty seconds.

To review more ideas, the team switches to a distilled version of the same model that runs in 4 steps. Images appear in about three seconds, so an art director can explore around two hundred compositions in an afternoon. Fine texture and small text are noticeably weaker, so the studio keeps a simple rule: fast few-step drafts for exploration, then the full 28-step model with the same prompt and seed for the final selected frames. The result is a faster creative cycle without sacrificing the quality of delivered work.