TL;DR
Liu, Gong and Liu (2022) propose rectified flow, a way to learn a transport map between two sets of samples, such as random noise and images. The learning step is an ordinary least-squares regression: a network learns the direction from a point on a straight line to that line's endpoints. Reflow repeats the procedure on the model's own outputs, which straightens the paths, and the authors report that nearly straight flows give good images with a single Euler step.
Builds on: Ordinary Differential Equation, Optimal Transport · Leads to: Rectified Flow, the method in short form
Why it mattered
Text-to-image models. The training objective of rectified flow, regressing a velocity along straight paths, was adopted by later large text-to-image systems, including Stable Diffusion 3 in 2024. It gave a simple regression target in place of the curved-path objectives used by earlier diffusion models.
Fewer network calls. Diffusion-style samplers solve an ODE or SDE with many steps, and each step is a network call. The paper's central practical claim is that a straight-path flow needs very few. Its Table 1 lists 127 network evaluations for a high-accuracy adaptive solve of the 1-rectified flow on CIFAR-10, a standard benchmark of 60,000 small 32-by-32 colour images. After distillation into a one-step network, the authors report an FID of 4.85 for the 2-rectified flow. FID (Fréchet Inception Distance) compares the statistics of generated images with real ones, so lower is better. That beat the best one-step U-Net result they compared against.
One method for many transfers. The same construction works for any two empirical distributions. The paper applies it to image-to-image translation and to domain adaptation, where a shifted domain is mapped to the training domain before classification.
The problem
Suppose we have samples from a distribution , usually noise, and samples from , usually images. We want an ODE that carries samples from at time to samples from at time . Here the velocity is a neural network, which makes this a Neural Ordinary Differential Equation.
The obvious choice is the straight line . It has the right endpoints, but it cannot be used as a sampler. To move along it you must already know , which is the thing you are trying to generate. The line is non-causal.
Fixing the paths is harder than it looks. Two straight lines from different pairs can cross. An ODE gives each point in space one velocity, so two trajectories that meet at a point must have the same velocity from then on. Straight lines that cross have different velocities, so no flow can follow both lines exactly. The fix has to change the paths at the crossings.
Third, the paths of existing diffusion models are curved. A curved path needs many small steps for an ODE solver to follow it, and each step is a network call. The paper's goal is to remove the curvature, so that a coarse solver is accurate.
How it works
Rectified flow has a short pipeline. Its training step is a regression, and its sampling step is an ODE solve.
- Draw a pair , one sample from each distribution. In generation these are drawn independently.
- Draw a time uniformly between 0 and 1, and place the point on the straight line between and .
- Train a network to output the direction at that point, by least squares.
- To sample, draw from and follow the learned field with an ODE solver. The paper's Euler steps are the simplest choice.
- Reflow: run the sampler to produce pairs and train a new rectified flow on those pairs, exactly as in steps 1 to 3.
flowchart LR A["Draw independent pair X0, X1"] --> B["Point on the straight line at a random time t"] B --> C["Regress velocity v(x, t) onto X1 minus X0"] C --> D["Sample by solving dZ/dt = v with Euler steps"] D --> E["Reflow: new pairs (Z0, Z1) from the sampler"] E --> B
Trace one tiny case in one dimension. Take the pair and , and a random time .
- The point on the straight line is . Check: is halfway between and .
- The regression target is the direction of the line, . It is the same at every time, because the line has constant speed. Check: moving from to is a distance of .
- If the network outputs at , the squared error is . Training lowers it. Check: a perfect network outputs there.
- To sample, start at and take one Euler step of size with the learned velocity . The result is . Check: the path is straight, so one step lands exactly on the data.
The crossing problem is shown in the plot. Two pairs, and , have straight paths that cross at when . Their velocities there are and . The regression gives the average, , and that single velocity is what lets the flow avoid crossing.
- pair (0, 2)
- pair (2, 0)
The math
Given samples and , the rectified flow induced by the pair is the ODE whose velocity is the least-squares fit of the direction along the straight interpolation , for .
Write for the Expected Value over the random pair and time, and for the uniform distribution on the time interval.
Step 1 in symbols: the straight interpolation
At this is and at it is . Each term is linear in , so the derivative does not depend on .
Step 2 in symbols: the regression
The velocity is chosen to solve
This is a Mean Squared Error regression with a random time, so it can be trained with ordinary stochastic gradient descent on sampled pairs, as Algorithm 1 in the paper does. The loss is the same kind used in supervised learning, which is why the method scales without extra machinery.
Step 3 in symbols: the minimiser
Because the squared-error minimiser is a conditional mean, the best possible velocity at a point and time is
This is the average direction of all straight lines that pass through at time . Where several lines cross, the velocity is their average, as in the plot. This averaging is what makes the ODE causal: it depends only on and , never on the unseen endpoint.
Step 4 in symbols: Euler sampling
With steps of size , start from and update
For the one-dimensional trace, , and give . If the path is straight, the error of this step is zero for any , because the velocity is constant along the path.
Step 5 in symbols: reflow
Write for the flow learned from the pair. Reflow sets
A coupling is a joint pair whose two parts have the distributions and ; it says which start goes with which end. A transport cost is for a function that measures the cost of one move. The function is convex when it is bowl-shaped, so that long moves cost disproportionately more. The paper proves that the rectified coupling has no larger convex transport cost than the input coupling (its Theorem 3.5), so each round moves the coupling towards cheaper transport. It also observes that reflow straightens the paths, which is what makes few-step sampling accurate.
Results
Full solves on CIFAR-10. With the DDPM++ U-Net architecture, the 1-rectified flow solved with the RK45 adaptive solver reached an FID of and a recall of , the best of the ODE methods in the paper's table. It used about 127 network evaluations, against 140 for the VP ODE and 146 for the sub-VP ODE of the earlier work. A 2000-step SDE reached an FID of , so the flow matched a far more expensive sampler.
Few steps. The paper reports that reflow substantially improves FID and recall when the number of steps is small, roughly 80 or fewer. For large step counts, reflow makes results worse, because errors in the learned velocity accumulate over many rounds.
One step. After distillation into a one-step network, the 2-rectified flow reached an FID of and a recall of . The paper's text says this beats the best one-step U-Net model it compares against, with an FID of , and that its recall of and the 3-rectified flow's exceed the best GAN recall it lists, .
Transfers. The paper also reports image-to-image translation and domain-adaptation experiments in Sections 5.3 and 5.4. This lesson does not quote their numbers. The authors describe the translation results as visually good rather than as exact transfers of one distribution onto another.
Limits. The main results are for CIFAR-10 and for unconditional generation. Reflow needs a fresh training round and a set of generated pairs for each step, so it adds training cost. Distillation is needed for a true one-step model, and the one-step results depend on it. The FID and recall numbers are the paper's own, computed with its evaluation protocol.
Reading guide
- Abstract and Section 1. The motivation: paired data is missing, and sampling is expensive. Needs Gaussian (Normal) Distribution for the noise distribution.
- Section 2.1. The method, Algorithm 1, and the non-crossing argument. Needs Ordinary Differential Equation and Vector Field. The rewiring picture in Figure 2 is the key intuition.
- Section 2.2. The marginal-preserving property and the transport-cost claim. Needs Optimal Transport and Convex Function.
- Section 2.3 and Section 3.5. The connection to probability flow ODEs and to DDIM. Needs Denoising Diffusion Implicit Models (DDIM) and Diffusion Model. Read these after the main method.
- Sections 3.3 and 3.4. Why reflow straightens paths and how straight and optimal couplings differ. These are the most technical parts. Start with the statements, then the proofs if you need them.
- Section 5.2. The CIFAR-10 table and the figure with the number of Euler steps. Needs Euler Method and Knowledge Distillation for the one-step model.
- Sections 5.3 and 5.4. Translation and domain adaptation, which use the same construction on images and on features. The adversarial method it compares against is a Generative Adversarial Network style of training.
Check yourself
QuestionRecall: why does rectified flow fit the velocity to instead of following the straight line directly during sampling?Show answer
The straight line depends on , which is the unknown output. Fitting a velocity by least squares gives an ODE that uses only the current point and time, so it can be solved without knowing the endpoint in advance. The fitted field is the conditional average of the line directions through each point.
QuestionComputation: take the pair and . Find the point on the straight line at and the regression target.Show answer
The point is . The target is , which is the same at every time. So the network is asked to output at .
QuestionWhy: explain why a flow whose paths are exactly straight can be sampled with one Euler step without any error.Show answer
An Euler step adds the velocity times the step size to the current point. On a straight path the velocity is constant along the path, so with a single step of size the point moves by exactly . The result lands on the endpoint with no discretisation error. This is why the paper ties straightness to few-step sampling.
QuestionApplied: a team trains a rectified flow and samples it with 100 Euler steps. They reflow once and find the FID improves at 10 steps but gets worse at 100 steps. What does the paper suggest is happening, and what should they do if they want a cheap sampler?Show answer
Reflow straightens the paths, which helps when the number of steps is small. At large step counts the errors in the learned velocity build up over the rounds of reflow, so accuracy can fall. For a cheap sampler the team should keep the reflowed model and use few steps, or distil it into a one-step network, which is the route the paper uses for its best one-step result.