Flow matching and rectified flow

Reading: 43 min, plus 17 in closed details. A flow-matching model regresses straight-line velocities from noise to data; this page shows what that regression really learns (computed exactly on a 2-D toy), why its paths bend and what each fix costs: solvers and step grids, paths, pairings, reflow, distillation, how training times are drawn, stochastic sampling, and what SD3, FLUX, Wan and HunyuanVideo ship. Runs on a live 2-D toy and the topic's 1M-parameter Fashion-MNIST model (Apple M1 Pro); published results kept apart. Child page of Topic: generative-and-multimodal. Data as of October 2026.

The idea in one screen

Flow matching trains a network to output the straight-line velocity from a noise sample to a data sample; because many such lines pass through every point, what it actually learns is their average, the marginal velocity field, whose paths bend, and every few-step method is a way to make that field easier to follow.

Fig. 1 is the page's 2-D toy in space-time: each upright glass plate is the same plane at one time, t = 0 (noise) on the left to t = 1 (data) on the right. Every point and path is computed in your browser by the page's own engine (the exact field and the trained networks' int8 weights).

  1. Two clouds. Noise x0 is easy to sample (a standard Gaussian, teal, on the t = 0 plate); data x1 is not (the toy's ring of 8 blobs, orange, at t = 1). Flow matching looks for a velocity that carries the first cloud onto the second.
  2. Train on one straight line per pair. Pair each noise with a random data point. Training picks a t, the point xt = (1 − t) x0 + t x1 on their line, and asks the network, given xt and t, for this line's constant velocity x1 − x0. One call, one squared error. The bold pair is section 1's illustrative example.
  3. Many lines cross at every point. Through one point x at t = 0.5 pass lines from many pairs, drawn as strong as their posterior weight (here mostly two neighbouring blobs). The network sees only xt and t, so a squared error makes it output their weighted average: the marginal field u (section 2).
  4. Sample by following u. Solving dx/dt = u from noise reaches the data: 40 paths of the exact field (48 Euler steps) land on the blobs, along bent paths, because each point's average direction turns as it commits to one blob.
  5. One big step lands on the mean. One Euler step follows the first arrow and lands on the average of the data, where there is none: at t = 0 the field is "the average data point minus where you are", so every point goes to the ring's empty centre (section 3; on images, the blur of section 1).
  6. Reflow makes the path straight enough for one step. Retraining on the flow's own (noise, output) pairs (section 8) gives the root's 2-RF network, whose paths are straight: one Euler step lands on a blob for 90% of 2,000 noises (and for the count shown of these 40).

You need

Regression with a squared error (it predicts the conditional mean of its target) and Gaussian noise; the page builds the rest. The diffusion side is on Diffusion from zero: the forward process (section 1), schedules (2), prediction targets and loss weighting (3), samplers (5) and guidance (6); the derivations (why the per-pair loss has the marginal loss's gradient, the probability-flow ODE) on Variational inference and generative-model maths, section 7, derivations D5 to D8; the transformers that production flow models train on Latent diffusion and diffusion transformers.

New terms

  • Velocity field v(x, t): an arrow for every point and time; sampling follows it from t = 0 (noise) to t = 1 (data).
  • Conditional / marginal field: one pair's line velocity / the average over every pair through x.
  • Path (at, bt): how a pair is mixed, xt = at x1 + bt x0.
  • Coupling: which noise is paired with which image in training.
  • k-RF, reflow: the k-th rectified flow, trained on the (k−1)-th flow's own (noise, output) pairs.
  • NFE: network evaluations per sample, the real cost. Straightness: straight-line distance over path length (1 = straight).
  • Shift: a warp of the time grid that moves steps towards the noise end.

Running example. The root topic's 2-D toy (noise in the plane; data a ring of 8 Gaussian blobs, radius 3, spread 0.25; small 3 → 48 → 48 → 48 → 2 networks, 4,994 parameters) and its Fashion-MNIST model (a 1,040,353-parameter U-Net trained 4,000 steps in 893.3 s on an Apple M1 Pro). Image scores are the root's: FD, the Fréchet distance between 1,000 samples and the test set in a Fashion-MNIST classifier's feature space (lower is better; 1,000 real images score 18.9); class accuracy; and diversity, the mean feature distance between same-class samples (real 28.9). On the toy, "on a blob" means within 0.75 (3 spreads) of a centre.

KnobWhat it changesMeasured herePublished
Solver and step grid (5)error per network evaluationEuler, Heun, midpoint at equal NFE, images and toyMovie Gen's linear-quadratic grid
Path (at, bt) (6)shape of the lines, and where a uniform grid landsexact field on 3 paths, toySiT Table 4: straight 34.8 against VP 39.8 FID
Coupling (7)how much lines cross, hence curvatureminibatch OT by batch size, toy and imagesTong et al. 2023; Pooladian et al. 2023
Reflow rounds (8)re-pairs noise with the model's own outputs1 to 4 rounds toy; 1 to 3 rounds imagesLiu et al. Table 1 (CIFAR-10)
Distillation (9)one network call replaces the ODE3 students toy; 2 students imagesInstaFlow, LADD, MeanFlow
Training t distribution (11)where the network's accuracy goes6 schemes, 3 seeds, 2 budgets, toySD3 Tables 1 and 2
ODE or SDE sampling (12)adds noise with the same marginals5 noise levels, exact field and imagesSiT Table 5

Labels: measured run on an Apple M1 Pro (CPU for the toy, MPS for the image model), 2026-10-17; published read from the source named; derived computed from other numbers with the formula shown. Convention throughout (Lipman et al.'s): t = 0 is noise, t = 1 is data, velocity v = x1 − x0. SD3, diffusers and the Math page count the other way (noise level σ = 1 − t); section 14 shows what mixing them does.

1. Training: regress the straight-line velocity

The problem. Noise is easy to sample; data is not. Flow matching looks for a velocity field v(x, t) that, followed for one unit of time, carries the whole cloud of noise onto the cloud of data. Sampling is then solving an ordinary differential equation (ODE): start at x(0) drawn from a standard Gaussian and move with dx/dt = vθ(x, t) until t = 1. Nothing is random after the start, so the same noise always gives the same output. Such a model is a continuous normalising flow; what 2022 added is a cheap way to train one.

One training example, in numbers (illustrative). Draw a noise x0 = (0.5, −1.2), a data point x1 = (3, 0) (a blob centre of the toy) and t = 0.3. The point on their straight line is xt = 0.7 x0 + 0.3 x1 = (1.25, −0.84), and the line's velocity, the same at every t, is x1 − x0 = (2.5, 1.2). A network that answers (2.0, 1.0) at that input pays (0.5² + 0.2²) = 0.29. That is the whole training step (step 2 of Fig. 1):

xt = (1 − t) x0 + t x1,   loss = ‖ vθ(xt, t) − (x1 − x0) ‖²,   t uniform in [0, 1]
x0
Gaussian noise, the same shape as a data point
x1
a training example (an image scaled to [−1, 1])
x1 − x0
the target: the constant velocity of the straight path between them

Liu, Gong and Liu (arXiv 2209.03003) call it rectified flow; Lipman et al. (arXiv 2210.02747) the conditional optimal-transport path; both 2022 published. It is simulation-free: older continuous flows solved the ODE and backpropagated through it at every training step, while here xt is built in closed form, so a step costs one network call and one squared error, exactly like a DDPM step. Training the topic’s flow model took 893.3 s (4.48 steps/s) against the DDPM’s 906.7 s measured: the objective costs nothing extra. The image model on this page trained with these lines (the topic's shared src/data/objectives.py, lines 90 to 97; the 10% label dropout is for guidance, section 10):

def cfm_loss(model, x1, y, p_uncond=0.1):
    """Conditional flow matching with straight paths (rectified flow / OT-CFM with sigma_min = 0)."""
    x0 = torch.randn_like(x1)
    t = torch.rand(x1.shape[0], device=x1.device)
    tt = t.view(-1, 1, 1, 1)
    pred = model((1 - tt) * x0 + tt * x1, t, drop_labels(y, p_uncond))
    loss = F.mse_loss(pred, x1 - x0)
    return loss, {"loss": loss.item()}
The same two lines in the reference libraries

Meta's facebookresearch/flow_matching (commit 11568d3): CondOTScheduler sets αt = t, σt = 1 − t (flow_matching/path/scheduler/scheduler.py lines 108 to 113), and the affine path builds x_t = sigma_t * x_0 + alpha_t * x_1 and dx_t = d_sigma_t * x_0 + d_alpha_t * x_1 (flow_matching/path/affine.py lines 89 to 90), which is x1 − x0. torchcfm (commit 7c65385): t * x1 + (1 - t) * x0 and x1 - x0 (torchcfm/conditional_flow_matching.py lines 83 and 154).

Every training line is straight, yet one Euler step gives a blur
Predict: sample the trained Fashion-MNIST model with one Euler step, x1 = x0 + vθ(x0, 0). What comes out?

2. What the network learns: the marginal field

The problem. The same point x at the same t lies on many lines, from different noises to different images (step 3 of Fig. 1). The network sees x and t only, so it cannot know which line it is on. A network trained with a squared error predicts the average of its targets given its inputs, so it learns the marginal vector field (averaged over all pairs, as opposed to the conditional field of one pair):

u(x, t) = E[ x1 − x0 | xt = x ] = Σpairs (posterior weight of the pair at x) × (its velocity)
weight
how likely it is that a line through x at time t came from that pair
u
what a perfectly trained network outputs; following it carries the whole noise cloud onto the data cloud (Lipman et al. 2023)

For the toy this average has a closed form (given which blob an example came from, xt is Gaussian), so the page can draw the exact u beside the trained network. Your browser runs a line-by-line port of the script that computed every exact number here. Fig. 2 draws it on five time slices:

  1. t = 0: every arrow points at the empty centre. At pure noise every data point is an equally likely end, so u = E[x1] − x: the average data point (the ring's centre, where there is no data) minus where you are. Each arrow is drawn 0.45 (1 − t) u, so it points towards the field's current guess of the final point, E[x1 | x] = x + (1 − t) u.
  2. t = 0.25: the arrows start to turn. A point away from the centre now says something about which side of the ring its line came from, so the posterior weights favour the nearer blobs.
  3. t = 0.5: eight basins. The weights have mostly collapsed onto one blob per region: the arrows point at blobs, and turn sharply along the borders between basins.
  4. t = 0.75 and 0.95: short arrows into the nearest blob. Near the data end every point has committed and the field is steep (each blob pulls hard towards its centre), so a small error in the network's output there matters most.
  5. The paths thread the plates. Following u from 16 noises gives paths that cross each plate along its arrows; they bend because the arrows turn between t = 0 and t = 0.5.
  6. The trained network at t = 0.1: on the exact field. The root's toy network (1-RF, green) is drawn over the exact arrows (blue) and covers them.
  7. At t = 0.95: off near the data. The same comparison with the arrows drawn four times longer: where the field is steep the network's arrows miss the exact ones (the lower chart further down measures it by t).

Average the lines yourself. The widget beside this puts one point on the plane at a time t of your choice and draws the lines through it from 80 sampled data points, each as strong as its weight, with their average and the exact field.

The exact field, as the script computes it (src/runs/fm_toy.py)

Any Gaussian path xt = at x1 + bt x0 on a mixture of Gaussians: posterior weights over blobs, then E[x1 | x] and E[x0 | x] in closed form, u = a′ E[x1 | x] + b′ E[x0 | x].

def coef(kind, t):
    """a_t, b_t and their t-derivatives. t = 0 noise, t = 1 data."""
    t = torch.as_tensor(t, dtype=torch.float64)
    if kind == "linear":
        return t, 1 - t, torch.ones_like(t), -torch.ones_like(t)
    if kind == "cos":
        h = math.pi / 2
        return torch.sin(h * t), torch.cos(h * t), h * torch.cos(h * t), -h * torch.sin(h * t)
    if kind == "vp":       # Song et al.'s VP SDE (beta_min 0.1, beta_max 20), the continuous DDPM schedule, run from s = 1 - t
        s = 1 - t
        ab = torch.exp(-(0.1 * s + 19.9 * s * s / 2)); beta = 0.1 + 19.9 * s
        a, b = ab.sqrt(), (1 - ab).sqrt()
        return a, b, beta * a / 2, -beta * ab / (2 * b)
    raise ValueError(kind)


def exact(x, t, kind="linear"):
    """Exact marginal velocity u, score, E[x1|x], E[x0|x] at (x, t) for the ring mixture. x: (N, 2) float64."""
    a, b, da, db = coef(kind, t)
    S = a * a * SD * SD + b * b
    d = x[:, None, :] - a * CEN[None]                      # N, K, 2
    w = torch.softmax(-(d * d).sum(-1) / (2 * S), 1)[..., None]
    E1 = (w * (CEN[None] + a * SD * SD / S * d)).sum(1)
    E0 = (w * (b / S * d)).sum(1)
    return da * E1 + db * E0, (w * (-d / S)).sum(1), E1, E0

Why training on single lines works. We never compute u while training. Lipman et al.'s Theorem 2: the per-pair loss and the loss against u differ by a constant independent of the network, so they have the same gradient (published; derived on the Math page, derivation D8). The constant is the spread of the lines around their average, and with the exact field it can be measured (the charts further down).

Average the lines: near noise the average points at the ring's empty centre; near data it commits to one blob

Predict, then drag: at t near 0, where will the thick arrow point? Click or drag to move the point. At t near 0 all 80 sampled data points are about equally likely ends, so the average (thick arrow) points at the ring's centre, where there is no data; slide t towards 1 and the weights collapse onto one blob. The 80-sample average, the exact field (dashed red) and the trained root toy model (green, optional) agree. Each arrow is drawn (1 − t) times the velocity, so it ends at the model's current guess of the final point, E[x1 | x].

Predict: the root's toy model ended training at a loss of 2.85 per coordinate. How much could more training remove?

What the network gets wrong. The lower chart is the honest measure of learning: within 0.006 of the exact field at t = 0.1 but 0.40 at t = 1, where the field is steep (each blob pulls hard towards its centre). That is where a sampler's last steps land, and why a solver that evaluates the network exactly at t = 1 is fragile (section 5). How to check on any Gaussian-mixture toy: compute u as above and plot |vθ − u|² by t.

Almost all of the loss is the spread of a random target; the network's own error is tiny except near the data end

2-D toy, per point, summed over 2 coordinates, 20,000 fresh pairs per t. Total: mean |x1 − x0|². Floor: |x1 − x0 − u|², what no network can remove. Lower chart: the root's trained toy model's distance from the exact field, |vθ − u|² (log). measured on CPU.

3. Few steps fail even for a perfect model

The problem. On the toy one Euler step puts no points on a blob; on images it gives the blur of section 1. Training failure, or would a perfect model do it too? Sample the exact field with the same solver and steps: what it gets wrong is the path's fault (discretisation error); the network's extra error is learning error. Fig. 3 runs both on 24 noises (the shares below are of 2,000):

  1. A fine solve reaches the blobs. 64 Euler steps of the exact field: curved paths, 99% on a blob (converged).
  2. One step: every point on the centre. At t = 0 the field is "the average data point minus where you are", so one Euler step of the exact field lands every point on the ring's centre (mean distance from it 0.0): no points on a blob.
  3. Two steps: between the blobs. The second evaluation, at t = 0.5, turns each path, but halfway is too late: 36% on a blob.
  4. Four steps: cutting the corners. Each straight step cuts across the bend of the curved path it should follow: 90% on a blob.
  5. The trained network misses the same way. The root's toy network (1-RF, green) at 4 steps runs on top of the exact field's 4-step polylines (purple): 82% on a blob against 90%, and at 2 steps 34% against 36%. The miss is the path's.

What it shows. The exact field misses about as much as the trained network at every step count (the chart beside this). The exact paths are as bent as the learned ones: straightness 0.864 against 0.865. Curvature belongs to the problem, not to the network. On two moons the learned flow paths even come out less straight than DDIM's (0.55 against 0.73 over 40 paths), measured in Diffusion from zero, section 5's closed two-moons block.

Predict: you train the same model 10 times longer. At 2 Euler steps, can it reach 90% on a blob?

How to check on real data: compare N-step samples with a many-step solve from the same noise; good many-step and blurry few-step samples mean the path, not the fit, is the problem.

The exact field misses about as much as the trained network at 2 and 4 steps: the error is the path's

Share of 2,000 toy samples on a blob, by Euler steps, the same 2,000 starting noises for every curve; real data score about 98 to 99%. measured on CPU with the int8 weights the page embeds.

4. The perfect model only copies its training set

The problem. A perfectly trained network outputs the exact marginal field. For real training data the distribution the loss sees is the training set itself: 55,000 Fashion-MNIST images, each a single point. Its exact field has a closed form too (xt given image j is Gaussian around t · imagej with spread 1 − t, the weights are a softmax over images, u = (E[x1 | x] − x)/(1 − t)). Where does that field take noise? Fig. 4 asks it first on the toy, with an illustrative training set of 16 points drawn from the ring:

  1. The ring's own field spreads the samples. The exact field of the whole ring (the distribution, not a sample of it) sends 60 noises onto the blobs, anywhere inside them: their ends sit a median 0.27 from the nearest of the 16 points of the next step.
  2. The loss only ever sees a training set. Training draws x1 from a finite set, here 16 points of the ring (seed 77; on images, the 55,000 training images).
  3. Its exact field lands every sample on a training point. The same 60 noises through the training set's exact field (50 Euler steps): all 60 end within 0.02 of one of the 16 points (the last step's discretisation), and all 16 are used.
  4. Many samples, one point. Up to 9 of the 60 samples stack on a single training point. The optimum of the loss is a lookup table of the training set, not a generator.

The same on images. The card beside this runs the training set's exact field on the root's noises and compares it with the root's trained network.

What it shows. At 50 steps 100% of the exact-field samples are training images to within 0.0008 RMS (rounding level); at 4 steps already 99%. The trained network's samples sit a median 0.269 from their nearest training image, about as far as held-out test images do (0.251), and only 15% share the exact sample's nearest image. The network did not reach the optimum of its own loss, and that failure is what lets it generate new garments.

Published: the same for diffusion, and where the novelty comes from

The same for diffusion: denoising score matching "has a closed-form optimal solution that can only generate training data replicating samples", and memorisation "tend[s] to occur on smaller-sized datasets" (Gu et al., arXiv 2310.02664, Oct 2023). Kamb and Ganguli (arXiv 2412.20292, Dec 2024) explain the novelty: convolutional networks are local and translation-equivariant, so they cannot implement the global optimum and instead stitch "local training set patches"; their patch-mosaic model predicts trained models' outputs with median r² 0.94 on Fashion-MNIST published.

When it matters. Memorisation and privacy (a model that fits a small fine-tuning set too well reproduces it), and evaluation: FID cannot see copying (metrics are on Evaluating generative models). How to check: nearest-training-neighbour distances of samples against those of held-out real images, as above.

Same noise: the loss's exact optimum returns training images; the trained network makes new ones
starting noise (one per class)
exact field of the training set
its nearest training image (50 steps)
trained network (the root's 1M-parameter U-Net)
its nearest training image (50 steps)

src/runs/fm_memo.py: the exact field, class-conditional (the 5,500 training images of the class), sampled from the root's noises beside the root's trained model; nearest training image by root-mean-square (RMS) pixel difference, pixels in [−1, 1]; 28 s on CPU measured.

5. Sampling is solving an ODE: solvers and step grids at equal cost

The problem. Turning the velocity into a sample means integrating dx/dt = vθ(x, t) from 0 to 1 in finite steps, and every step costs network evaluations (NFE, each a full forward pass: the real cost). Which solver gives the best sample per evaluation?

How it works. Euler: move along the current velocity for a step h; one evaluation; error shrinks in proportion to h (first order). Heun: take the Euler step as a guess, evaluate the velocity there too, step with the average of the two slopes. Midpoint: evaluate at the half step and use that slope. Both cost two evaluations a step and their error shrinks with h² (second order).

On samples. FD at 4 evaluations: midpoint 47.3, Euler 158.3, plain Heun 1,333.2; one midpoint step (2 evaluations) 146.1 against 489.3 for two Euler steps measured. The culprit is t = 1. Heun's last corrector evaluates the network on a clean image, whose source noise is independent of it, so the best squared-error answer is v = x1 − E[x0] = the input itself, not any path's slope: the network's output at t = 1 has cosine 0.968 with its input and 0.635 with the true x1 − x0 (0.935 at t = 0.9) measured on 1,000 validation images. Making the last step plain Euler, as diffusers' HeunDiscreteScheduler does (v0.41.0, scheduling_heun_discrete.py lines 364 and 367; n steps cost 2n − 1 evaluations), recovers it: 76.7 at 5 evaluations, 48.1 at 9.

The grid is half the solver. Where the steps go matters as much as how each is taken (section 6 shows DDIM is Euler on a warped grid). Production samplers keep Euler and move the grid: the resolution shift (section 11), and Movie Gen's linear-quadratic grid, which "follows the first 25 steps of an N-step linear schedule and then approximates the remaining N − 25 steps with 25 quadratically placed steps", 50 steps "emulating 250 linear steps" (arXiv 2410.13720, section 3.4.2) published. Multistep solvers reuse past evaluations, so they get second order at one evaluation per step: Wan 2.1's diffusers repository ships UniPCMultistepScheduler with prediction_type: flow_prediction, flow_shift: 3.0, order 2 (config at revision 0fad780a534b, read 2026-10-17), a diffusion solver reused on a flow model, as Sana does with DPM-Solver.

The solvers as the root ran them (src/flow/fm_samplers.py), the toy's ranking, and more grids
def vel(net, x, t, y, s=1.0):
    """One velocity evaluation (one batch of 2N when guidance mixes conditional and unconditional)."""
    tt = torch.full((x.shape[0],), float(t), device=x.device)
    if s == 1:
        return net(x, tt, y)
    if s == 0:
        return net(x, tt, None)
    out = net(torch.cat([x, x]), torch.cat([tt, tt]), torch.cat([y, torch.full_like(y, 10)]))
    c, u = out.chunk(2)
    return u + s * (c - u)


def grid(n, shift=1.0):
    """n + 1 times from 0 to 1. shift > 1 spends more steps near the noise end (SD3's shift, on sigma = 1 - t)."""
    sig = torch.linspace(1, 0, n + 1, dtype=torch.float64)
    sig = shift * sig / (1 + (shift - 1) * sig)
    return [float(1 - v) for v in sig]


@torch.no_grad()
def euler(net, x, y, n, s=1.0, shift=1.0, trace=None):
    ts = grid(n, shift)
    for t, t2 in zip(ts[:-1], ts[1:]):
        v = vel(net, x, t, y, s)
        if trace is not None:
            trace.append((t, x.clone(), (x + (1 - t) * v).clone()))     # where we are, and the straight-line guess of the end
        x = x + (t2 - t) * v
    return x


@torch.no_grad()
def heun(net, x, y, n, s=1.0):
    """Second order: an Euler predictor, then step with the average of the slopes at both ends (2 evaluations a step)."""
    ts = grid(n)
    for t, t2 in zip(ts[:-1], ts[1:]):
        h = t2 - t
        v1 = vel(net, x, t, y, s)
        v2 = vel(net, x + h * v1, t2, y, s)
        x = x + h * 0.5 * (v1 + v2)
    return x


@torch.no_grad()
def midpoint(net, x, y, n, s=1.0):
    """Second order: take the slope at the half step (2 evaluations a step)."""
    ts = grid(n)
    for t, t2 in zip(ts[:-1], ts[1:]):
        h = t2 - t
        v1 = vel(net, x, t, y, s)
        x = x + h * vel(net, x + 0.5 * h * v1, t + 0.5 * h, y, s)
    return x

Meta's library defaults to Euler and lists dopri5, midpoint and heun3 from torchdiffeq (flow_matching/solver/ode_solver.py lines 34 and 70). On the toy, whose blobs have width and so no sharp end, the ranking is the textbook one: at 4 evaluations Euler lands 82% on a blob, Heun 89%, midpoint 88%; at 2 evaluations one second-order step loses to two Euler steps (6% and 9% against 34%) measured.

Qwen-Image's and LTX-Video's shift_terminal stretches the shifted grid so that its last noise level before the final step to clean data is 0.02 or 0.1 (diffusers v0.41.0, stretch_shift_to_terminal, line 279). How many steps: the exact toy field puts 90% on a blob at 4 Euler steps (99% converged); the image model needs 10 to 20 Euler steps, midpoint 4 evaluations; released: FLUX.1 [schnell] "1 to 4 steps" (card), FLUX 3 Image Klein 50 steps for the base and 16 for the distilled variant (vendor statement, the root's Model map), Movie Gen 50.

At equal evaluations midpoint wins; plain Heun loses to Euler until its last step is made Euler

The trained image model: RMS pixel difference from a fine answer (midpoint, 500 steps, which never evaluates t = 1), 200 images, both axes logarithmic, so the slopes are the solvers' orders measured by the root on Apple M1 Pro (MPS). At 10 evaluations: Euler 0.078, plain Heun 0.126, midpoint 0.026, Heun with a last Euler step 0.062 (9 evaluations). Even midpoint's error stops falling past 50 evaluations (0.0049 at 50, 0.0065 at 100): finer steps evaluate closer to t = 1, where the learned field is rough.

6. Choosing the path: straight, cosine, or diffusion's (one family)

The problem. "Flow matching" usually means the straight path at = t, bt = 1 − t, but the loss works for any Gaussian path xt = at x1 + bt x0 (Lipman et al. 2023; Albergo and Vanden-Eijnden's stochastic interpolants). Diffusion's paths are variance preserving (VP: a² + b² = 1). Which path is best, and how different are flow and diffusion really?

One family. Both train on a scaled data point plus scaled noise, so any such model can be read as predicting the noise, the clean data or the velocity: given xt, each determines the others. On the straight path, x̂1 = xt + (1 − t) vθ and x̂0 = xt − t vθ derived. Every diffusion model also has a deterministic ODE with the same marginals, the probability-flow ODE (Song et al. 2021), which DDIM solves (Diffusion from zero, sections 4 and 5). So "flow against diffusion" is three separable choices: the path, what the network outputs (which sets how the loss weighs each noise level), and how t is drawn in training (section 11).

Three paths, all exact. Because the toy's field is exact for any path, this comparison has no learning error: straight; cosine VP (a = sin(πt/2), b = cos(πt/2), SiT's GVP); and the continuous DDPM schedule (Song et al.'s VP SDE, β from 0.1 to 20).

  1. The two VP schedules trace the same curves (straightness 0.916 and 0.916) and differ only in how fast they move along them. At 4 Euler steps the cosine schedule lands 91% on a blob and the DDPM schedule 52%, because evenly spaced steps waste most of DDPM's budget near pure noise (the clock above).
  2. DDIM is Euler on the straight path. DDIM with 4 steps on the cosine path and Euler on the straight path at times λ = 0.000, 0.293, 0.500, 0.707, 1.000 give the same samples to within 5 × 10−15 (float64 rounding) measured. The blog "Diffusion Meets Flow Matching" states it ("Diffusion with DDIM sampler == Flow matching sampler (Euler)"); here it is checked numerically. Choosing a path and choosing a step grid are largely the same decision.
  3. Straight is not the straightest. On this toy the cosine path's curves are straighter (0.916 against 0.864) and both do about equally well at 4 steps (91% against 90%). The straight path's advantage is simplicity: a constant target, no singular derivative at either end, and a uniform grid that already spends its steps sensibly.

Published, at ImageNet scale. SiT (Ma et al., arXiv 2401.08740, Jan 2024) kept DiT's architecture and changed one ingredient at a time (SiT-B, ImageNet 256, 400K steps, FID): DDPM-style noise prediction 44.2; continuous-time score 43.6; velocity on the VP path 39.8; on the straight path 34.8; on the cosine (GVP) path 34.6 (Tables 2 to 4) published. They credit shorter, less curved paths and note the VP path's σ̇ "becomes singular" near the data. The ranking matches the toy: cosine and straight close, the DDPM schedule well behind. When it matters: porting a sampler between models (its grid assumes a path) and reading ablations (a "flow against diffusion" result usually changes path, target and t sampling at once).

Four evenly spaced steps on each path, placed on the straight path's clock: DDPM's first three cover half the way, its last jumps the other half

Any Gaussian path is the straight path with space rescaled by 1/(a + b) and time warped to λ = a/(a + b). Dots: λ at t = 0, 0.25, 0.5, 0.75, 1 for each path, computed from the formulas above derived: straight 0, 0.25, 0.5, 0.75, 1; cosine 0, 0.29, 0.5, 0.71, 1; DDPM-style 0.01, 0.06, 0.23, 0.51, 1, so its last step jumps half the way.

Path (exact field)straightnesson a blob, Euler 2Euler 4Euler 8DDIM 4
straight (rectified flow)0.86436%90%96%= Euler
cosine VP (SiT's GVP)0.91649%91%98%89%
DDPM-style VP (beta 0.1 to 20)0.91620%52%90%62%

2,000 noises measured. DDIM here is "predict both ends, re-noise them at the next time", which works on any path.

7. Couplings: which noise is paired with which image

The problem. A coupling is the rule that pairs noises with images in training. Plain flow matching draws both at random; random pairs cross everywhere, and crossing lines are what the average bends around. Can a better pairing straighten the flow without a second training?

How it works. Minibatch optimal transport (OT; Tong et al., arXiv 2302.00482; Pooladian et al., "Multisample Flow Matching", arXiv 2304.14772; both 2023): inside each batch of B noises and B images, re-pair them to minimise the total squared distance (the Hungarian algorithm), then train as usual. The marginals are unchanged; only which line each point is on changes. Fig. 5 does it for one batch of 64 on the toy:

  1. Random pairs. Each noise is joined to a random point of the ring: 64 long lines that cross the whole box (mean squared length 9.66 for this batch; 10.95 over 4,096 random pairs).
  2. Where the lines pass, neighbours disagree. On the t = 0.5 plate every line's point carries its direction x1 − x0: points next to each other head in very different directions, so the field, which must give one arrow per point, averages them and bends.
  3. Minibatch OT pairs. The same 64 noises and 64 points, re-paired to minimise the total squared distance (the Hungarian algorithm): mean squared length 3.73 for this batch, under 40% of its random pairing (over 4,096 pairs in batches of 64, the chart below: 10.95 falls to 3.74).
  4. Neighbours agree. With OT pairs nearby points move in nearly the same direction, so there is little to average and the learned paths come out straighter: a toy trained with OT batches of 64 has straightness 0.997 and lands 76% on a blob in one Euler step (random pairs: 0.865 and 0%).

What it shows. In 2-D a batch of 256 removes 68% of the travel; on images even 4,096 removes only 5.1%. In 1,024 dimensions a random noise is almost equally far from every image (distances concentrate), so a few thousand candidates give the assignment little to choose from. Toy models trained with OT pairs:

Toy model, OT pairs in batches of BB = 1 (random)41664256
straightness of its paths0.8650.9820.9910.9970.998
on a blob after 1 Euler step0%3.0%41%76%83%
on a blob after a fine solve (256 Heun steps)97%98%98%97%96%

The root's recipe (12,000 Adam steps, batch 512); B = 1 and 256 are the root's random-pair and OT models, B = 4, 16, 64 trained here measured on CPU.

The cost. One assignment problem per batch, O(B³) on the CPU: the root's B = 256 toy trained in 173 s against 12 s for random pairs. A slight loss of many-step quality appears as B grows (97% to 96% after a fine solve; observed on this toy, not explained further). When it matters: low-dimensional or strongly clustered data. How to check: measure the coupling's distance against random pairing before spending a training run.

Pairing within a batch shortens the trip by two thirds in 2-D and by 5% on images

Mean squared distance between paired noise and data, relative to random pairing (= 1), by batch size B, 4,096 pairs each. 2-D toy: random 10.95, one batch of 4,096 3.39. Fashion-MNIST (1,024 pixels, per pixel): 1.754 against 1.664. measured on CPU (fm_toy.py, fm_ot_images.py).

8. Reflow: retrain on the flow's own pairs

The problem. Sections 3 and 7: the field of random pairs bends, and better pairing helps little on images. Reflow (Liu, Gong and Liu 2022) changes the pairing after training: push many noises z through the trained flow to get X1 = flow(z), then train again, same loss, on the fixed pairs (z, X1). Paths of an ODE "cannot cross each other" (their words), so the new pairs do not cross, and the field that averages them is close to each pair's straight line. Names: the first model is the 1-rectified flow (1-RF), the model trained on its pairs 2-RF, and so on. Fig. 6 runs it on the toy networks the page embeds, from the same 60 noises (every network and solver is in the 2-D flow playground tab):

  1. The first flow's paths are curved. The root's 1-RF network, trained on random pairs, carries the noises onto the blobs along bent paths (a fine solve, 24 midpoint steps).
  2. Its own pairs, joined by straight lines. Pair each noise z with where the flow takes it, X1 = flow(z). The ODE's paths cannot cross, so these pairs do not cross either: nearby noises go to nearby points.
  3. 2-RF learns from them and goes straight. Trained with the same loss on those fixed pairs, the root's 2-RF has nearly straight paths: straightness 0.9998 against 0.8652 for 1-RF.
  4. One Euler step: centre against blobs. With one step the 1-RF sends everything to the centre (0% on a blob) while the 2-RF lands 90% on a blob (of 2,000 noises; the counts on the stage are of these 60).
  5. Distil: one call per sample. The one-step student of 2-RF (section 9) maps z to its end point directly: 94% on a blob, with one network call.

Toy, round after round (the table beside this). Rounds 3 and 4 add a little at 1 step (91%, 92%) and lose a little at the fine solve (97%, 96%, 94%, 94%): each round fits the previous round's slightly wrong map, and errors add up. The first flow's own pairing already travels about as little as optimal transport (3.34 against 3.39): rectifying turns a random coupling into a deterministic one "with lower convex transport costs" (Liu et al.).

Toy: one reflow does almost everything; later rounds trade fine-solve quality for little
Roundstraightnesson a blob, 1 Euler stepfine solve (256 Heun)pair travel |X1 − z|²
1-RF (root)0.86520%97%3.34
2-RF (root)0.999890%96%3.34
3-RF (here)0.999991%94%3.32
4-RF (here)0.999992%94%3.25

Each round trained like the one before (12,000 steps on 20,000 pairs from a 256-step Heun solve). Pair travel: mean squared distance between each noise and where that round's flow takes it (random pairing 11.1; minibatch OT over 4,096 3.39). measured on CPU.

Images. One reflow turns a useless 1-step model (FD 1253.5) into a usable one (159.8). The second reflow (3-RF) helps only at 1 step (146.2) and is worse at every other budget: 108.7 against 99.5 at 2 steps, 96.6 against 83.1 at 4, 85.8 against 73.1 at 50 (48.9 for 1-RF). Diversity at 50 steps falls round by round (25.7, 25.0, 24.3; real 28.9): each round's pairs are a finite set of the previous model's samples, so lost variety cannot come back. The 2-RF paths were already nearly straight (0.999), leaving the next round only error to inherit. And the rectified coupling barely shortens the trip in 1,024 dimensions: the 1-RF's own pairs travel 12% less than random pairs, yet that was enough to make 1 step work.

Published (Liu et al., CIFAR-10, Table 1): one Euler step FID 378 (1-RF), 12.21 (2-RF), 8.15 (3-RF); with the adaptive RK45 solver 2.58, 3.36, 3.96: the same trade at scale published; "It is not recommended to apply too many reflow steps as it may accumulate estimation error". The cost: per round a pass that generates the pairs (30,000 pairs took 8.3 min on MPS here) plus a fine-tune (7.4 min). How to check: FD (or your metric) at 1, 2, 4 and 50 steps before and after each round, plus diversity.

Images: the second reflow helps only at exactly one step, and every round loses diversity
Model1 step2450diversity at 50straightness
1-RF (root)1253.5489.3158.348.925.70.9861
2-RF (root)159.899.583.173.125.00.9992
3-RF (here)146.2108.796.685.824.30.9995

FD by Euler steps, 1,000 samples from the root's noise seed. 1-RF and 2-RF are the root's runs (2-RF: 30,000 pairs from a 25-step midpoint solve in 503 s, then 2,000 steps from the 1-RF's weights in 443 s); 3-RF trained the same way here and scored by the same code measured on Apple M1 Pro (MPS). Re-scoring the root's 2-RF here gave 159.8 at 1 step (root: 159.8).

9. Distillation to one step

The problem. Even a rectified flow is integrated in steps. Distillation trains a student T(z) to output the teacher's ODE end point X1 = flow(z) directly, in one call. Which teacher should it copy? Liu et al.'s recipe regresses T(z) onto the k-RF's pairs (for one step they "replace the L2 loss function with the LPIPS similarity", a perceptual distance). Here the student is the teacher's own network evaluated at t = 0, initialised from the teacher, with a squared error: z + v(z, 0) → X1, on the pairs the next reflow round uses (step 5 of Fig. 6).

One-step student oftoy: on a blobtoy: W2 to dataimages: FDimages: class accuracyimages: diversity
1-RF94%0.315130.086%23.2
2-RF94%0.279121.686%23.4
3-RF94%0.265not run

W2: 2-Wasserstein distance between 2,000 samples and 2,000 data points (two sets of real data score about 0.31). Image students trained 1,500 steps (5.5 and 5.5 min on MPS) and scored like section 8 measured. A 3-RF image student would need a third pair pass; skipped (cheap-runs rule).

What it shows. The student of a straighter teacher matches the data better (toy W2 0.315, 0.279, 0.265; image FD 130.0 for the 1-RF's student, 121.6 for the 2-RF's): a straighter teacher's noise-to-data map is smoother, so easier to fit in one call. Both image students beat one Euler step of 2-RF (159.8) or 3-RF (146.2) at the same cost, so for one step, distilling beat a further reflow round measured. Liu et al.'s CIFAR-10 table orders them the same way: one-step FID 6.18 (1-RF + distill), 4.85 (2-RF + distill), 5.21 (3-RF + distill) published; one reflow before distilling is the sweet spot. None of the tiny students reaches the multi-step teachers (FD 48.9 for 1-RF at 50 steps): they had 1,500 steps of L2 where Liu et al. used LPIPS and far longer training. How to check: student against teacher at the teacher's best step count, plus diversity (distilled students often lose variety).

Published one-step and few-step methods for flows (dated)
  • InstaFlow (Liu et al., arXiv 2309.06380, Sep 2023): reflow then distillation on Stable Diffusion; one step, FID 23.3 on MS COCO 2017-5k, 0.09 s per image, 199 A100 GPU-days of training (abstract) published.
  • Latent adversarial diffusion distillation, LADD (Sauer et al., arXiv 2403.12015, Mar 2024): SD3 (8B) to SD3-Turbo, matching strong generators "using only four unguided sampling steps"; FLUX.1 [schnell] (12B rectified flow, "1 to 4 steps") is distilled with it per its model card published.
  • Shortcut models (Frans et al., arXiv 2410.12557, Oct 2024): one network conditioned on the step size as well as the time, trained in one phase, sampling in 1 or many steps published.
  • MeanFlow (Geng et al., arXiv 2505.13447, May 2025): learns the average velocity over an interval; "FID of 3.43 with a single function evaluation (1-NFE) on ImageNet 256x256 trained from scratch", with "no pre-training, distillation, or curriculum learning" published.
  • Guidance distillation: FLUX.1 [dev]'s transformer takes the guidance scale as an input (diffusers v0.41.0, pipelines/flux/pipeline_flux.py line 847, if self.transformer.config.guidance_embeds:), so one call replaces classifier-free guidance's two.
  • Consistency models, progressive and adversarial distillation of diffusion models: Latent diffusion and diffusion transformers, section 10.

10. Flow against diffusion, and every model at equal cost

The question. Same data, same 1,040,353-parameter U-Net, same scorer, same starting noise: the root's diffusion model with three samplers, the flow model (1-RF) with Euler and midpoint, its reflows and the one-step students. Which gives the best sample per network evaluation? (One evaluation is one forward pass of the same network, so equal NFE is equal time.)

What it shows. At 4 evaluations flow with Euler scores FD 158.3 against 478.9 for DDIM and 300.3 for DDPM; at 10, 64.4 against 181.3, 130.5 and DPM-Solver++'s 115.1; at 20, 49.8 against 130.9, 77.9 and 101.2. Midpoint does better still (47.3 at 4 evaluations). Few steps cost diversity, not recognisability: class accuracy is above 85% for every flow run from 2 Euler steps, while diversity is 15.3 at 2 steps and 25.7 at 50 (real 28.9) measured. Why flow needs fewer steps here: the DDPM path bends by construction (straightness 0.885 against 0.986 for flow, measured on 50-step image paths), its linear schedule is nearly pure noise for most of its range (section 6), and x̂0 from a noise prediction divides by a tiny √ā at the noisy end, while a velocity stays bounded.

Where diffusion still wins. With many steps the stochastic DDPM sampler reaches FD 34.9 at 1,000 steps (39.7 at 250), below every deterministic flow run (best 43.5, Heun with a last Euler step at 19 evaluations). Solving the flow ODE more exactly does not help (Euler at 250 steps 53.0, midpoint at 25 steps 53.1): fresh noise corrects an imperfect model, and section 12 gives the flow model that noise.

Flow with Euler beats every diffusion sampler at every budget from 1 to 50 evaluations; only DDPM with hundreds of steps wins

FD, 1,000 samples (100 per class), noise seed 11; real images 18.9. Diffusion rows: the root Diffusion lab's recorded runs; 1-RF and 2-RF: the root's; 3-RF, students and the SDE row: this page measured on Apple M1 Pro (MPS), 2026-10-17.

Same ten noises, two models, one evaluation budget at a time

Predict, then watch: at 4 evaluations, which side looks like clothing? The card beside this steps through 1, 2, 4, 10, 20 and 50 evaluations by itself; pick any two models. The FD numbers below are for its default pair, DDIM on the left and the flow with Euler on the right.

  1. 1 evaluation. Both are blurs: the flow's class averages (FD 1253.5) and DDIM's noisy first guess (1493.9).
  2. 2. The flow's garments take shape (489.3); DDIM was not run at 2 steps.
  3. 4. The flow's samples are recognisable clothing (158.3); DDIM's are still noisy (478.9).
  4. 10. 64.4 against 181.3: the flow is close to its best.
  5. 20. 49.8 against 130.9.
  6. 50. 48.9 against 112.7, and the two models turn the same noise into very similar garments although they were trained separately with different objectives (observed on these ten, not measured further): both learned a deterministic map from noise to data, and on the same data and network the maps come out close.
The same noise through every model, by class (a grid)

The root's strip noise (seed 5, one per class). Rows are models, columns network evaluations. Empty cells were not run (DDPM, DDIM and DPM-Solver++ have 1, 4, 10, 20, 50 steps; midpoint's NFE is twice its steps; a student has only NFE 1).

Guidance carries over unchanged. Trained with 10% of labels dropped, the model gives a conditional velocity vc and an unconditional vu, and the sampler uses vu + s (vc − vu): two evaluations per step. On the tiny flow model at 50 Euler steps, FD 48.9 unguided and 23.8 at s = 1.5, the best score of either model measured by the root. How guidance trades variety for adherence, and its fixes: Diffusion from zero, section 6.

The root's guidance sweep on the flow model

Flow, Euler 50 steps, 1,000 samples measured: FD 48.9 unguided (s = 1), 23.8 at s = 1.5 (class accuracy 94.6%; real images score 18.93), 54.6 at s = 2, 140.5 at s = 3 and 275.7 at s = 5, where accuracy is 99.7% and diversity has fallen from 25.7 to 20.4: guidance trades variety for recognisability, and past a small scale FD punishes the lost variety. s = 0, the unconditional model (it only trained on the 10% of examples whose label was dropped), scores 362.2. The Diffusion lab's DDIM-50 sweep peaked at s = 2 (FD 35.55; it did not try 1.5); the flow model's best is lower.

11. Which t to train on: timestep sampling and the resolution shift

The problem. Each training step draws one t per example. Uniform t spends equal effort on every noise level, but section 2 showed the levels differ: near pure noise the target is mostly unpredictable, near clean data the input gives the answer away, and the middle is where the network has the most to learn. Which distribution of t gives the best model for a fixed budget?

How it works. Draw u uniform in [0, 1] and map it. SD3 (Esser et al., arXiv 2403.03206, section 3.1) compared, in its own convention (σ = 1 − t: 0 data, 1 noise): logit-normal lognorm(m, s), the logistic of a normal with mean m and scale s (m > 0 leans towards noise); mode sampling fmode(u; s) = 1 − u − s (cos²(πu/2) − 1 + u), which keeps some weight at the ends; and CosMap 1 − 1/(tan(πu/2) + 1).

Logit-normal(0, 1) puts most training where the loss floor is falling: the middle of the path

Predict before moving m: which end does m = 1 starve? Densities from SD3's formulas: logit-normal analytically, mode sampling and CosMap by mapping 20,000 evenly spaced u derived. Dashed: the toy's irreducible loss floor by t (section 2), rescaled to fit.

Published. SD3 trained 61 variants on ImageNet and CC12M; ranked over two datasets, EMA and plain weights and several step counts, "rf/lognorm(0.00, 1.00) consistently achieves a good rank": first overall (rank 1.54), plain uniform rectified flow 5.67, classic eps/linear diffusion 2.88 (Table 1). At 25 steps on ImageNet, FID 45.78 for lognorm(0, 1) against 49.70 for uniform (Table 2) published. Logit-normal(0, 1) became the default: Movie Gen (arXiv 2410.13720: "zero mean and unit standard deviation"), HunyuanVideo (2412.03603) and Wan (2503.20314) all state logit-normal t published.

What it shows. At 12,000 steps logit-normal(0, 1) cuts the mid-path error (0.047 to 0.028) and multiplies the error near pure noise (0.019 to 0.400), because it almost never trains there. Sample quality after 64 steps is within the seed-to-seed spread for every scheme (W2 0.259 uniform, 0.245 logit-normal; real against real 0.31). At the short budget, schemes that concentrate on the middle land more points on a blob in 4 steps (70% uniform against 79% logit-normal). On a 2-D toy the choice is nearly free; its published value comes at image scale, where the middle of the path carries most of the perceptual work and budgets are never "converged".

Every scheme on the toy, as a table; SD3's ranking of 61 formulations

In SD3's Table 2, lognorm(0.5, 0.6), which leans hard to noise, had the best CLIP score (0.256) and a much worse FID (80.41): a scheme can buy prompt adherence at the cost of image statistics published.

Scheme (SD3's notation)error at t = 0.02error at t = 0.5on a blob, Euler 4W2, Euler 64 (± sd)
uniform0.0190.04781%0.259 ± 0.009
lognorm(0,1)0.4000.02882%0.245 ± 0.018
lognorm(0.5,0.6)0.8260.01378%0.241 ± 0.003
lognorm(-0.5,1)0.8240.03883%0.257 ± 0.038
mode(1.29)0.1080.02180%0.243 ± 0.018
cosmap0.0360.04081%0.264 ± 0.017

Error: |vθ − u|² against the exact field, 4,000 points per t; t = 0.02 is near pure noise in this page's convention. Means over 3 seeds measured.

Variant (SD3's notation)rank, allrank, 5 stepsrank, 50 stepsImageNet FID (25 steps)ImageNet CLIP
rf/lognorm(0.00, 1.00)1.541.251.5045.780.250
rf/lognorm(1.00, 0.60)2.083.502.00114.260.254
rf/lognorm(0.50, 0.60)2.718.501.0080.410.256
rf/mode(1.29)2.753.253.00
rf/lognorm(0.50, 1.00)2.831.502.50
eps/linear2.884.252.7548.420.245
rf/mode(1.75)3.332.752.7544.390.253
rf/cosmap4.133.754.00
edm(0.00, 0.60)5.6313.253.25
rf5.676.505.7549.700.247
v/linear6.835.757.7551.680.246
edm(0.60, 1.20)9.0013.009.00
v/cos9.1712.258.7550.740.244
edm/cos11.0414.2511.25
edm/rf13.0415.2513.25
edm(-1.20, 1.20)15.5820.2515.0063.120.236

Esser et al. 2024, Tables 1 and 2 published, read from arXiv HTML 2026-10-17. Rank: non-dominated sorting over CLIP and FID, averaged over EMA and plain weights, two datasets and sampler settings (lower is better). FID and CLIP from Table 2, which lists only some variants (blank where not listed). "rf" is rectified flow with uniform t; eps/linear is the LDM-style diffusion baseline.

On the toy, the distribution of t moves the network's accuracy to where t is drawn

The trained network's squared distance from the exact field by t (log), mean of 3 seeds, uniform always drawn measured on CPU (fm_toy.py, about 7 minutes for every toy experiment on this page). The chips are the six SD3 variants trained; the sliders above retrain nothing.

The resolution shift. A bigger image has more pixels to average over, so the same noise level destroys less of it: at a given t a 1024-pixel image is "less noisy" than a 256-pixel one. SD3 shifts the time to compensate, tm = √(m/n) tn / (1 + (√(m/n) − 1) tn) on the noise level (section 5.3.2, eq. 23), with "a shift value of α = 3.0 both during training and sampling at resolution 1024×1024" published. diffusers implements a fixed shift as sigmas = self.shift * sigmas / (1 + (self.shift - 1) * sigmas) (FlowMatchEulerDiscreteScheduler, v0.41.0, scheduling_flow_match_euler_discrete.py line 351) and, with use_dynamic_shifting, math.exp(mu) / (math.exp(mu) + (1 / t - 1) ** sigma) (lines 646 to 647) with μ linear in the number of image tokens (calculate_shift, pipelines/flux/pipeline_flux.py lines 73 to 83). With sigma = 1 the two are one formula with shift = eμ derived: FLUX's defaults (μ from 0.5 at 256 tokens to 1.15 at 4,096) give shift 1.65 at 512 × 512 and 3.16 at 1024 × 1024, beside SD3's 3.0.

When it matters: training from scratch (logit-normal(0, 1) unless you have a reason), fine-tuning at a new resolution (the shift should change with it), and sampling with few steps (HunyuanVideo: "we set a larger shifting factor s for a lower inference step"). On the 28 × 28 model no shift was best (the root measured FD 158.3 at 4 steps unshifted against 294.6 with shift 1/3 and 242.4 with shift 3): a small image has nothing to gain. How to check: per-t validation loss against a reference run, and samples at your production step count.

The shift pushes a few-step grid towards the noise end, more so at higher resolution

Predict, then drag: at 4 steps and 1024 px with the FLUX.1 defaults, how many evaluations fall in the noisier half? Then halve the resolution.

12. Adding noise back: stochastic sampling with the same marginals

The problem. The flow ODE is deterministic, and section 10 found the stochastic DDPM sampler beating every deterministic run at many steps. Can a flow model sample stochastically too, and should it?

How it works. A velocity also gives the score (the gradient of the log density, pointing to more likely data): on the straight path E[x0 | x] = x − t v, so score = −(x − t v)/(1 − t) derived. For any noise level ε ≥ 0 the stochastic differential equation dx = (v + ε/2 · score) dt + √ε dW has the same distribution at every t as the ODE (the extra drift cancels the spreading the noise causes). Albergo, Boffi and Vanden-Eijnden's "Stochastic Interpolants" (arXiv 2303.08797, Mar 2023) build flows and diffusions as one family "with an adjustable level of noise" published; the ODE is ε = 0, and the 2-D flow playground has an ε control. Fig. 7 runs both on the exact toy field from the same 150 noises:

  1. The ODE: one smooth path per noise. ε = 0 (64 Euler steps): the same noise always gives the same sample.
  2. The SDE: the same noises wander. ε = 1 adds fresh noise at every step and the score term pulls back towards likely data: each path jitters and may end on another blob.
  3. The same distribution at every time. On the t = 0.5 plate the ODE's 150 positions (blue) and the SDE's (purple) are different points with the same spread: the extra drift cancels the spreading the noise causes.
  4. Both end on the ring. With enough steps both reach the data: 99% and 99% on a blob at 256 steps, 98% and 98% at 16 (of 2,000 noises).
  5. With few steps, noise costs. At 4 steps the SDE cannot remove its own noise in time: 50% on a blob against 90% for the ODE.
Exact field, straight path: noise ε4 steps16 steps256 steps
0 (ODE)90%98%99%
150%98%99%
49.3%32%98%

Share on a blob, Euler-Maruyama, the same 2,000 noises measured on CPU.

With a perfect field, noise only costs steps: every ε reaches the data with enough steps, and more noise needs more. Noise helps when the field is imperfect: each injection lets the sampler forget part of the error it accumulated. SiT measured that on ImageNet: SDE sampling beats the ODE for every path (FID 39.8 to 37.8 on VP, 34.8 to 33.6 on the straight path, 34.6 to 32.9 on GVP; Table 5, many steps) published, and their best SiT-XL result (2.06) uses an SDE sampler.

What it shows. Constant noise to the data end destroys the samples (FD 488.5 at ε = 0.5, 50 steps, against 48.9 for the ODE): the score divides by 1 − t, so near the data end the network's small errors are multiplied by 1/(1 − t), 25 at the last noisy step of 50, and the fresh noise must be removed by exactly that score. Let the noise fade and the picture flips with the step count: at 50 steps every noise level is still worse than the ODE (56.5, 70.8, 86.5), but at 250 steps better, and more so with more noise: 47.8, 43.0, 35.7 against 53.0 for the ODE at 250 and 48.9 at its best. That is SiT's result on a 1M-parameter model, and DDPM's win in section 10 seen from the flow side. How to check: sweep ε at your step budget; expect the best ε to rise with the number of steps.

On the tiny image model, noise that fades out at the data end beats the ODE once there are enough steps
noise10 steps50 steps250 steps
ε = 0 (ODE)64.448.953.0
constant ε = 0.5492.1488.5459.7
constant ε = 11090.71143.8964.0
decaying ε = 0.5 (1 − t)not run56.547.8
decaying ε = 1 (1 − t)not run70.843.0
decaying ε = 2 (1 − t)not run86.535.7
50 steps, ODE (ε = 0)
50 steps, constant ε = 0.5 up to the data end

The root's 1-RF, FD as in section 8 (real images 18.9). The score comes from the same velocity network; the last step is plain Euler; ε = 0 reproduces the root's Euler numbers exactly. "Decaying": εt = ε (1 − t), no noise near the data measured on Apple M1 Pro (MPS).

13. Flow matching in production

The pattern. Since SD3 the major open image and video generators train a transformer with flow matching on the straight path and logit-normal t, then sample with Euler (or a multistep solver) on a shifted grid whose shift grows with resolution or with fewer steps: SD3 a fixed 3.0 at 1024 px; FLUX a dynamic eμ from 1.65 to 3.16; Z-Image-Turbo a fixed 3.0; HunyuanVideo a fixed 7.0. What differs is the shift rule (fixed, or linear in token count), whether the grid stops short of the data end (shift_terminal), and the distillation behind few-step variants (LADD for FLUX.1 [schnell] and SD3-Turbo, guidance distillation for FLUX.1 [dev]). The networks themselves are on Latent diffusion and diffusion transformers; video systems on Video and audio generation.

Model by model: what the paper says about training and what the released scheduler config says about sampling

Training from the paper or card (published, dated); sampling from the scheduler configuration in the repository at the revision shown (read 2026-10-17). Gated repositories (SD 3.5, FLUX.1) were not read; their rows come from the paper, the card or the diffusers pipeline defaults.

Model (date)Training: path, tReleased sampler configNotes
Stable Diffusion 3 (paper, Mar 2024)straight path (rectified flow), logit-normal(0, 1) chosen from 61 formulationsnot read (gated); paper: shift 3.0 at 1024 pxMMDiT; LADD distils it to SD3-Turbo, 4 steps
FLUX.1 [dev], [schnell] (2024-07-31)"rectified flow transformer", 12B (card)not read (gated); FLUX pipeline defaults: dynamic shift, μ 0.5 to 1.15 (shift 1.65 to 3.16)schnell: LADD, 1 to 4 steps; dev: guidance as an input
FLUX.2 [klein] 4B (repo 2026-01-14)flow matching (Model map)FlowMatchEuler, dynamic shift, μ 0.5 at 256 to 1.15 at 4096 tokens (shift eμ = 1.65 to 3.16); rev e7b7dc27f91dApache 2.0
Qwen-Image (2025-08-02)flow matching (Model map)FlowMatchEuler, dynamic shift, μ 0.5 at 256 to 0.9 at 8192 tokens (shift eμ = 1.65 to 2.46), shift_terminal 0.02; rev 75e0b4be04f6MMDiT 20.43B
Z-Image-Turbo (repo 2025-11-25)flow matching (Model map)FlowMatchEuler, fixed shift 3; rev f332072aa78b6.155B
Wan 2.1 (paper Mar 2025; 1.3B shown)"x_t = t x_1 + (1 - t) x_0", logit-normal tUniPC multistep, flow_prediction, flow_shift 3; rev 0fad780a534bvideo; 1.3B and 14B
HunyuanVideo (paper Dec 2024)Flow Matching, logit-normal tFlowMatchEuler, fixed shift 7 (community diffusers repo, rev e8c2aaa66fe3)video, 13B; larger shift for fewer steps
LTX-Video (repo read 2026-10-17)flow matching (config)FlowMatchEuler, dynamic shift, μ 0.95 at 1024 to 2.05 at 4096 tokens (shift eμ = 2.59 to 7.77), shift_terminal 0.1; rev 8984fa25007fvideo
Movie Gen (paper Oct 2024; not released)Flow Matching, logit-normal(0, 1), 30Blinear-quadratic grid, 50 steps "emulating 250 linear steps"video and audio

FLUX.1 shift from the FLUX pipeline's calculate_shift defaults (base_shift 0.5 at 256 tokens to max_shift 1.15 at 4,096), shift = eμ derived. Token counts: a 1024 × 1024 image through an 8× VAE and 2 × 2 patches gives 64 × 64 = 4,096 tokens derived. Licences and release dates are in the root's Model map tab.

14. When it goes wrong (optional)

Each is closed; open the ones you need. Real outputs and errors from the runs on this page and the root's.

Mixing conventions: time direction, t × 1000, the sign of v
diffusers' flow scheduler counts the other way. FlowMatchEulerDiscreteScheduler (v0.41.0, schedulers/scheduling_flow_match_euler_discrete.py) noises with sample = sigma * noise + (1.0 - sigma) * sample (line 234), so its model output is noise − data, the negative of this page's v; it steps with dt = sigma_next - sigma (line 504, negative) and prev_sample = sample + dt * model_output (line 511), and passes the network sigmas * num_train_timesteps, σ × 1000 (line 367). Same maths, opposite sign and a factor of 1,000 on t. What each mix-up does to the tiny model (Euler, 50 steps, same noise):
correct
time reversed (integrating from t = 1 down to 0)
t × 1000 passed to a net trained on t in [0, 1]

Correct sampling: FD 48.9. Integrating from t = 1 down to 0 (diffusers' direction) with this t = 0-is-noise model: FD 1,867.8, class accuracy 10.7% (chance is 10%). Passing t × 1000 (what diffusers' pipelines give a transformer) to a net trained on t in [0, 1]: FD 1,229.3, accuracy 21.3%. Neither raises an error. measured

Porting a checkpoint between the conventions needs both the time flip and the sign flip. A quick test: the 1-step output should be a recognisable blur of the class; if it is not, the convention is wrong, not the model.
Reading the training loss as progress
On the toy 99% of the converged loss is the irreducible spread of the targets (section 2). A flat loss says nothing about samples, and objectives with different paths, couplings or t distributions have different floors, so their losses cannot be compared. Score samples (FD at a fixed sample size, accuracy, diversity) at several step counts.
"Train longer" to fix blurry few-step samples
The exact field itself scores 36% at 2 steps (section 3). Change the pairing (reflow), the grid (shift) or distil.
Comparing solvers at equal steps, or evaluating the net at t = 1
Heun and midpoint cost two evaluations per step: compare at equal NFE. A solver that evaluates the network exactly at t = 1 (plain Heun's last corrector) uses a slope the model cannot know; on the image model that made Heun worse than Euler (section 5). End with an Euler step, or use a solver that never touches the end point (midpoint). With guidance each evaluation is already two forward passes, so a second-order step with CFG costs four.
Calling set_timesteps(n) yourself instead of passing the pipeline's grid
diffusers' flow scheduler, given only a step count, spaces its grid down to the smallest training noise level, so with 4 steps the last step starts at noise level about 0.003 and does nothing; the FLUX, FLUX.2 and Qwen-Image pipelines pass sigmas = np.linspace(1.0, 1 / num_inference_steps, num_inference_steps) instead (pipeline_flux.py line 823). Measured with FLUX.2 [klein]'s real config at 1024 px (src/runs/fm_sched_demo.py, diffusers 0.41.0):
1024 px: 4096 tokens, mu = 1.150, shift e^mu = 3.158
  dynamic sigmas: [1.0, 0.8635, 0.613, 0.0032, 0.0]
  fixed-shift sigmas: [1.0, 0.8639, 0.6145, 0.0099, 0.0]
  pipeline grid, dynamic: [1.0, 0.9045, 0.7595, 0.5128, 0.0]
ValueError: `mu` must be passed when `use_dynamic_shifting` is set to be `True`
The scheduler's own grid gives three useful steps; the pipeline's gives four. The fixed and dynamic forms of the shift agree inside the grid (0.8635 against 0.8639) and differ only in where they put the smallest level.
A dynamic-shift scheduler without μ
Using a FLUX.2, Qwen-Image or LTX-Video scheduler config in your own loop: ValueError: `mu` must be passed when `use_dynamic_shifting` is set to be `True` (line 310, the real message above). Compute μ from your image's token count with calculate_shift and the config's base and max values; a fixed shift of eμ is equivalent inside the grid.
Copying a shift or a guidance scale across resolutions, models or step counts
SD3's 3.0 is for 1024 × 1024; FLUX's rule gives 1.65 at 256 tokens and 3.16 at 4,096; HunyuanVideo raises the shift when it lowers the step count; on the 28 × 28 model no shift was best. Guidance scales differ the same way (best s = 1.5 on the tiny flow model, section 10). Recompute the shift for your resolution (section 11) and sweep both at your step budget on a few hundred samples.
Expecting minibatch OT to straighten an image model like a toy
One batch of 4,096 removes 69% of the 2-D travel but only 5.1% on Fashion-MNIST pixels (section 7). Check the coupling's distance reduction before paying the CPU cost.
One more reflow round "to be safe"
Each round fits the last round's errors: the toy's fine-solve quality and the images' 50-step FD and diversity drop round by round (section 8). Liu et al.: "It is not recommended to apply too many reflow steps". Stop when few-step quality stops improving, then distil.
Logit-normal t, then sampling from the least trained point
Every sampler's first evaluation is at pure noise, which logit-normal(0, 1) almost never trains: the toy's error there rose from 0.019 to 0.400 (section 11). SD3 still ranked it first at 5 steps, so this is usually harmless, but it is the first suspect if 1- or 2-step samples get worse after switching to logit-normal.
Reading DDIM-against-flow results as path-against-path
A VP schedule with a uniform grid and the cosine schedule trace the same curves but score 52% against 91% at 4 steps (section 6). Before crediting the path, check the grid.
Stochastic sampling with constant noise to the very end
The score of a flow model is −(x − t v)/(1 − t): near the data end it multiplies the network's errors. Constant ε = 0.5 turned FD 48.9 into 488.5 at 50 steps (section 12). Let the noise go to zero at the data end, and use enough steps.
Expecting reflow to be free
The pairs inherit the first model's mistakes, so full-solve quality drops (Liu et al.'s CIFAR-10 RK45 FID 2.58 to 3.36; the toy and the images in section 8). Measure both ends: few-step and many-step.
Trusting a model whose samples are suspiciously sharp
The exact optimum of the loss copies the training set (section 4). On a small fine-tuning set, check nearest-training-neighbour distances against held-out images before trusting a low FID.

Interview rehearsal (optional)

What does a flow-matching model predict, what is its loss, and why is it called simulation-free?
A velocity vθ(xt, t). Training: xt = (1 − t) noise + t data, loss ‖vθ − (data − noise)‖², t uniform or logit-normal. Sampling: integrate dx/dt = v from noise to data. Simulation-free: training never solves the ODE; each step builds xt in closed form and does one regression, where older continuous normalising flows simulated and backpropagated through the ODE.
What does a perfectly trained flow-matching network output, and why can we train on single pairs?
The marginal velocity u(x, t) = E[x1 − x0 | xt = x], the posterior-weighted average of the line velocities through x. The per-pair and marginal losses differ by a network-independent constant (Lipman et al., Theorem 2), so their gradients are equal; the constant is the targets' spread, about 99% of the converged loss on the toy.
Each training path is straight; why does one Euler step give a blur, and what would the exact optimum generate?
At t = 0 the field averages over every possible end point, so one step lands on the data mean (the centre of the toy's ring; a class-average blur on images): a property of the exact field, not a training failure. On a finite training set the exact optimum generates only copies of training images (100% at 50 steps here); networks generalise because their inductive biases stop them reaching it.
Path, coupling, time distribution: what is each, and how do flow matching and diffusion differ?
Path: how a pair is interpolated (at, bt). Coupling: which noise is paired with which data point (independent, minibatch OT, reflow pairs). Time distribution: which t the loss is evaluated at. Diffusion and flow matching are one family (Gaussian paths, a network readable as noise, data or velocity prediction, a deterministic ODE); they differ in path, output parameterisation (hence loss weighting) and t distribution by default.
Why does reflow straighten paths, what does it cost, and why does minibatch OT help a toy far more than images?
Reflow's pairs come from an ODE, whose paths cannot cross, so the averaged field is close to each pair's straight line. Cost: a pair-generation pass and a second training; each round inherits the previous model's errors (many-step quality and diversity fall). Minibatch OT: in high dimensions distances between random noise and images concentrate, so re-pairing a few thousand candidates barely shortens the trip (5% here against 69% in 2-D).
Euler or Heun? ODE or SDE?
Compare at equal evaluations. Second-order error falls with h², but the treatment of the data end matters as much: on the image model midpoint won at every budget while plain Heun lost to Euler until its last step was made Euler. SDE: same marginals for any ε; with a perfect field noise only costs steps, with an imperfect one it corrects accumulated error given enough steps and noise that fades at the data end (FD 35.7 at 250 steps against 53.0 for the ODE here). Few steps: ODE.
Why logit-normal t, and why a resolution shift?
Logit-normal spends training on the middle noise levels, where there is the most to learn; SD3's 61-variant study ranked lognorm(0, 1) first. The shift moves noise levels towards noise for bigger images, which need more noise to lose the same structure (SD3 eq. 23; 3.0 at 1024 px; FLUX's eμ rule).
Design: a text-to-image model served at 4 steps, 1024 px. Plan the generative side.
Latent space from an existing VAE; a transformer trained with flow matching on the straight path, logit-normal(0, 1) t, the resolution shift at 1024 px (about 3), 10% caption dropout for guidance; a 50-step teacher with Euler or a multistep solver on the pipeline grid. For 4 steps: reflow once and distil (InstaFlow route), adversarial distillation (LADD, as FLUX.1 [schnell]), or a step-conditioned model (shortcut, MeanFlow); distil guidance in (FLUX.1 [dev]) so each step is one call. Evaluate at 4 steps against the teacher at 50 on FID with large N, a text-alignment score and diversity, and check nearest-neighbour copies. Cost to watch: the pair pass or adversarial training, and the VAE decode once denoising is 4 calls.

What ran, and sources

Sources, runs, and what was not run

Published, read on 2026-10-17 from arXiv abstract and HTML pages (quotes and table numbers transcribed in src/inputs/published.md): Lipman et al. 2210.02747 (Theorem 2); Liu, Gong, Liu 2209.03003 (non-crossing, transport cost, reflow warning, LPIPS distillation, Table 1); Albergo, Boffi, Vanden-Eijnden 2303.08797; Tong et al. 2302.00482; Pooladian et al. 2304.14772; Gu et al. 2310.02664; Kamb and Ganguli 2412.20292; SiT 2401.08740 (Tables 1 to 5); SD3 2403.03206 (section 3.1, Tables 1 and 2, section 5.3.2); Movie Gen 2410.13720; HunyuanVideo 2412.03603; Wan 2503.20314; LADD 2403.12015; InstaFlow 2309.06380; Shortcut models 2410.12557; MeanFlow 2505.13447; Song et al. 2011.13456 (the probability-flow ODE); the blog "Diffusion Meets Flow Matching: Two Sides of the Same Coin" (authors and date not shown on the page, read 2026-10-17). Scheduler configs from the Hub at the revisions in src/inputs/scheduler_configs.json. diffusers v0.41.0 (commit 086bf9578c0f) source lines located by pattern; facebookresearch/flow_matching at commit 11568d3; torchcfm at commit 7c65385.

Measured here (Apple M1 Pro, 2026-10-17): the toy experiments on CPU (src/runs/fm_toy.py), the exact empirical field and copies (fm_memo.py, CPU), coupling distances on images (fm_ot_images.py, CPU), the scheduler demo (fm_sched_demo.py, CPU), and on MPS: reflow pairs (fm_pairs.py), 3-RF and the two one-step students (fm_train.py), scoring and SDE sampling (fm_score.py). The objective's code, the 1-RF and 2-RF models, the solver comparison, the t = 1 measurement, the convention bugs and the guidance sweep are the root topic's Flow lab runs (src/flow/ in the root), read from its recordings by src/make_data_more.py; the diffusion rows are the root Diffusion lab's. What transfers to a datacenter GPU: everything counted in network evaluations, rounds and steps; what does not: seconds.

Not run here: training at SD3 or FLUX scale (published numbers instead); logit-normal training of the image model (a 15-minute run whose difference would sit below the noise of a 1,000-sample FD; the toy shows the mechanism); LPIPS distillation (L2 used); a 3-RF image student (a third pair pass); adaptive ODE solvers (torchdiffeq is not in the shared environment); consistency, shortcut and MeanFlow training (published only).