Generative Models · 5 Interactives

The Straight-Line Shortcut from Noise to Image

Diffusion models carry random noise onto real images along a long, curved road — dozens of denoising steps. Flow matching asks the cheeky question: why not learn the straight line between the same two points? Race both roads below, measure the detour, break the straight-line dream with crossing paths — then repair it with reflow.

The transport race Step budget Straightness meter Crossing paths Reflow
EP 01

Two roads out of noise — the transport race

Every modern image generator solves the same job: move a cloud of random noise onto the shape of real data. Diffusion ends up with a wiggly, detour-filled road it must crawl along in many small steps. Flow matching (rectified flow) trains on the straight line between each noise point and its data point. Same start, same destination — very different roads. Press play.

Conceptual simulation: the grey trajectories mimic a diffusion sampler's meandering probability-flow paths; the gold ones are exactly the straight interpolations flow matching trains on. Both particle clouds reach the identical target points.

Why it matters: Stable Diffusion 3 and Flux moved from classic diffusion to rectified flow largely for this reason — the straighter the learned road, the fewer steps you need to drive it at generation time. Watch the step counters under each panel: same trip, wildly different number of stops.
EP 02

Same budget, different bill — quality per sampling step

Samplers integrate a velocity field with Euler steps: “move in the current direction for 1/N of the trip, re-check, repeat.” On a curved road, few big steps means you overshoot every bend. On a straight road, the direction never changes — so one step is already exact. Drag the step budget down and watch who survives.

Green dot = landed within 0.10 of its true target, red = missed. The straight side assumes perfectly straight learned paths — EP 04 shows when that assumption breaks.

The whole sales pitch of flow matching in one slider: a straight path has constant velocity, so a 4-step (even 1-step) sample can match what curved dynamics needs ~50 steps to achieve. Curved samplers buy accuracy with steps — that is why classic diffusion shipped with 50–1000 of them.
EP 03

The straightness meter — measure the detour

Pick one particle and put it under the microscope. Straightness = displacement ÷ distance actually walked (1.00 is a perfect straight line). Scrub time and watch the curved path's velocity arrow point away from the destination — every degree of that angle is error a coarse sampler will pay for.

The arrow is the instantaneous velocity on the curved road; the faint gold arrow points straight at the destination. Green arrow = aligned (harmless), red = misaligned (a big Euler step here lands off-road).

Papers literally report this number. Rectification pushes straightness toward 1.0, which is what makes “4-step” and even “1-step” checkpoints (InstaFlow, SD3-Turbo-style distillations) possible: when the velocity never turns, one giant step is exact.
EP 04

The crossing problem — straight lines that collide learn to average

Here is the catch. Training pairs noise with data at random, so the straight training lines cross each other. The network can only learn ONE velocity per location — at a crossing it learns the average of the lines passing through. Generate with 1 step and every sample gets shoved into the compromise zone between the two data modes. Try it.

The field you are sampling is the kernel-averaged velocity of all training lines — exactly what a regression-trained network converges to. Give it more steps and the ODE can still bend around the ambiguity; give it 1 and it can't.

This is the mode-averaging artifact: with random couplings, the marginal velocity at a crossing is a compromise between two destinations. Many-step sampling hides it; few-step sampling exposes it as blurry in-between garbage. Straight training lines alone do NOT give you straight learned paths.
EP 05

Reflow — untangle the pairs, then one step is enough

The fix is beautifully simple. Reflow: run the current model, see which data point each noise point actually flows to, and re-pair them that way — then retrain on the new couplings. Re-paired lines no longer cross, so the average velocity stops being a compromise. Compare both pairings at the same 1-step budget.

Run both buttons at 1 step and compare the hit rates above — same network capacity, same step budget, only the pairing changed.

This is the trick behind one-step Stable Diffusion (InstaFlow) and the reason “rectified” flow is called rectified: each round of reflow straightens the couplings a little more, until few-step — even single-step — generation stops averaging modes and starts hitting them.
Keep playing
Generative Models
ControlNet
Draw a skeleton the image must obey
Generative Models
Autoregressive vs Diffusion
Pixel by pixel, or all at once?