Rectified Flows & Reflow

Straightening flow trajectories for one-step generation: the rectification procedure, reflow iterations, distillation to one step, consistency distillation connection, and achieving near-diffusion quality in a single forward pass.

Advanced

Table of Contents

  1. Learning Objectives
  2. Notation
  3. Core Intuition
  4. Why Straight Paths Matter
  5. Rectified Flow Definition
  6. The Reflow Procedure
  7. One-Step Distillation
  8. Analysis of Straightness
  9. Connection to Consistency Models
  10. Practical Results
  11. Common Pitfalls
  12. Summary
  13. Exercises

Learning Objectives

  1. Explain why straight trajectories enable few-step generation.
  2. Derive the rectified flow objective and its geometric interpretation.
  3. Describe the reflow procedure for iterative trajectory straightening.
  4. Connect rectified flows to consistency distillation.
  5. Analyze the quality-steps Pareto frontier.

Notation

  • (X0,X1)γ(\mathbf{X}_0, \mathbf{X}_1) \sim \gamma — coupling between noise and data
  • Xt=(1t)X0+tX1\mathbf{X}_t = (1-t)\mathbf{X}_0 + t\mathbf{X}_1 — linear interpolation
  • vθv_\theta — learned velocity field
  • Straightness(v)\text{Straightness}(v) — trajectory straightness metric

Core Intuition

A flow that follows straight lines from noise to data can be integrated in ONE Euler step: x1=x0+vθ(x0,0)\mathbf{x}_1 = \mathbf{x}_0 + v_\theta(\mathbf{x}_0, 0). But with random noise-data pairing, trajectories cross and the learned velocity must be curved to avoid collisions. Rectified flow iteratively improves the coupling (X0,X1)(\mathbf{X}_0, \mathbf{X}_1) so that trajectories become progressively straighter, approaching one-step generation.

Rectified Flows

Rectification iter: 0
Iterations
0
Original (curved)Rectified (straight)
Explore: Rectified flow iteratively straightens transport paths via distillation, enabling 1-step generation. Each iteration refits the velocity field to shorter paths.

Why Straight Paths Matter

Euler discretization error: For an ODE dx/dt=v(x,t)dx/dt = v(x, t) with step size hh:

error per step=O(h2v).(1)\text{error per step} = O(h^2 \cdot \|v''\|). \tag{1}

For straight paths: v(x,t)=constv(x, t) = \text{const} along each trajectory → v=0v'' = 0zero discretization error. One Euler step is exact.

For curved paths: Need many steps to follow the curvature. A path with curvature κ\kappa requires O(κ/ϵ)O(\kappa / \epsilon) steps for error ϵ\epsilon.

Goal: Make the velocity field as constant as possible along trajectories.


Rectified Flow Definition

Given coupling γ\gamma over (X0,X1)(\mathbf{X}_0, \mathbf{X}_1):

LRF=E(X0,X1)γ,tU[0,1][vθ(Xt,t)(X1X0)2].(2)\mathcal{L}_{\text{RF}} = \mathbb{E}_{(\mathbf{X}_0, \mathbf{X}_1) \sim \gamma, t \sim U[0,1]}\left[\|v_\theta(\mathbf{X}_t, t) - (\mathbf{X}_1 - \mathbf{X}_0)\|^2\right]. \tag{2}

Interpretation: Train the velocity field to predict the direction from noise to data along the linear interpolation. The target X1X0\mathbf{X}_1 - \mathbf{X}_0 is the straight-line velocity.

Initial coupling (Rectified Flow 1): γ0=p0p1\gamma_0 = p_0 \otimes p_1 (independent). Random pairing → crossing paths → curved learned velocity.


The Reflow Procedure

Key idea: Use the trained model to create a BETTER coupling, then retrain.

Algorithm:

  1. RF-1: Train vθ1v_{\theta_1} on random coupling γ0=p0p1\gamma_0 = p_0 \otimes p_1.
  2. Generate pairs: For each x0p0\mathbf{x}_0 \sim p_0, solve ODE to get x^1=ODE(vθ1,x0,01)\hat{\mathbf{x}}_1 = \text{ODE}(v_{\theta_1}, \mathbf{x}_0, 0 \to 1).
  3. New coupling: γ1={(x0,x^1)}\gamma_1 = \{(\mathbf{x}_0, \hat{\mathbf{x}}_1)\} — now the pairs are connected by the flow.
  4. RF-2: Train vθ2v_{\theta_2} on coupling γ1\gamma_1.
  5. Repeat: γ2RF-3\gamma_2 \to \text{RF-3}, etc.

Why it helps: After RF-1, the coupling γ1\gamma_1 has non-crossing paths (they were generated by an ODE). Training on non-crossing paths yields straighter velocity fields.

Convergence: 2-3 iterations typically sufficient. Diminishing returns after that.


One-Step Distillation

After reflow, the flow is nearly straight. Distill to exactly one step:

Ldistill=Ex0p0[vθ(x0,0)(x^1x0)2],(3)\mathcal{L}_{\text{distill}} = \mathbb{E}_{\mathbf{x}_0 \sim p_0}\left[\|v_\theta(\mathbf{x}_0, 0) - (\hat{\mathbf{x}}_1 - \mathbf{x}_0)\|^2\right], \tag{3}

where x^1\hat{\mathbf{x}}_1 is generated by the multi-step teacher.

Alternative: self-consistency loss. Enforce that the one-step prediction equals the multi-step result:

L=E[x0+vθ(x0,0)ODESolve(vθ,x0)2].(4)\mathcal{L} = \mathbb{E}\left[\|\mathbf{x}_0 + v_\theta(\mathbf{x}_0, 0) - \text{ODESolve}(v_\theta, \mathbf{x}_0)\|^2\right]. \tag{4}

Analysis of Straightness

Straightness metric: For a trajectory {xt}t=01\{\mathbf{x}_t\}_{t=0}^1:

Straightness=x1x0201v(xt,t)2dt.(5)\text{Straightness} = \frac{\|\mathbf{x}_1 - \mathbf{x}_0\|^2}{\int_0^1 \|v(\mathbf{x}_t, t)\|^2 dt}. \tag{5}
  • Straightness = 1: perfectly straight (constant-speed straight line).
  • Straightness less than 1: curved path (longer than straight-line distance).

After each reflow:

  • RF-1: Straightness 0.7\approx 0.70.80.8 (significant curvature).
  • RF-2: Straightness 0.9\approx 0.90.950.95.
  • RF-3: Straightness 0.95\approx 0.950.990.99.

Connection to Consistency Models

Consistency models (Song et al., 2023): Train a model fθ(xt,t)f_\theta(\mathbf{x}_t, t) that maps ANY point on a trajectory to the endpoint:

fθ(xt,t)=x1t[0,1].(6)f_\theta(\mathbf{x}_t, t) = \mathbf{x}_1 \quad \forall t \in [0, 1]. \tag{6}

Connection: A perfectly straight rectified flow satisfies:

x0+vθ(x0,0)=x1=xt+(1t)vθ(xt,t).(7)\mathbf{x}_0 + v_\theta(\mathbf{x}_0, 0) = \mathbf{x}_1 = \mathbf{x}_t + (1-t) \cdot v_\theta(\mathbf{x}_t, t). \tag{7}

So the one-step prediction from ANY time tt equals x1\mathbf{x}_1. Straight rectified flows ARE consistency models.

Difference: Consistency models enforce this property directly; rectified flows achieve it by straightening trajectories.


Practical Results

Image generation (CIFAR-10, ImageNet):

  • 1-step rectified flow (after reflow): FID \approx 4-6.
  • 2-step: FID \approx 2-3.
  • 50-step diffusion: FID \approx 2.

Used in production:

  • Stable Diffusion 3: Flow matching + reflow-style distillation.
  • SDXL Turbo: Adversarial distillation of flow to 1-4 steps.

Speed: 1-step generation is 25-50x faster than 50-step diffusion. Real-time generation on consumer GPUs.


Common Pitfalls

Pitfall 1. Expecting RF-1 to produce one-step quality. The first rectified flow still has significant curvature; reflow is essential for few-step generation.

Pitfall 2. Generating too few coupling pairs for reflow. Need diverse pairs (100K+) covering the full distribution. Undercoverage leads to mode collapse.

Pitfall 3. Using high-order ODE solvers during reflow generation. This is correct but expensive. The whole point of reflow is to eventually avoid ODE solving — but the reflow process itself requires it.


Summary

  • Straight paths → zero Euler discretization error → one-step generation.
  • Rectified flow: Linear interpolation objective with noise-data coupling.
  • Reflow: Iteratively improve coupling using trained model; 2-3 iterations for near-straight paths.
  • Straightness converges: 0.7 → 0.9 → 0.95+ across reflow iterations.
  • Equivalent to consistency models when perfectly straight.
  • Enables real-time generation (1-4 steps) with near-diffusion quality.

Exercises

Exercise 1. Prove that non-crossing paths must exist for an ODE-generated coupling (hint: uniqueness of ODE solutions).

Exercise 2. Compute the Euler discretization error for a circular trajectory vs a straight trajectory with the same endpoints.

Exercise 3. For a 2D Gaussian mixture: visualize the trajectories of RF-1 vs RF-2 and measure straightness.

Exercise 4. Derive the relationship between the number of Euler steps and FID for a flow with straightness SS (estimate error scaling).

Exercise 5. Compare the training cost of 3 rounds of reflow vs consistency distillation for achieving 1-step generation.