Rectified Flow
13 memberslucid.models.generative.rectified_flowRectified Flow family — Liu, Gong & Liu, 2023 (straight paths, reflow).
Liu, Xingchao, Chengyue Gong, and Qiang Liu. "Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow." International Conference on Learning Representations, 2023.
Given any coupling of two distributions — in the generative case noise and data, drawn independently — the rectified flow induced by that pair is the ODE
whose field is fitted along the straight line between the endpoints,
This is the paper's eq. (1), and its minimiser is the conditional expectation .
Relation to what came before. The objective is exactly Flow Matching's optimal-transport path at : the interpolation is the same, and the regression target is the same and equally independent of . What Rectified Flow adds is not a different loss but what is done with the trained model.
Marginal preservation (Theorem 3.3). The solve is not merely a sampler that happens to work — at every , so is distributed as the data while is a different, non-independent coupling of the same two marginals. That is what makes the next step legitimate.
Reflow. Because the endpoints of the solve are themselves a valid coupling, the whole procedure can be applied to its own output:
Each round trains on the previous model's (noise, sample) pairs instead of independent draws. The marginals never move — every generates the same data distribution — but the transport cost never increases and the paths get straighter.
Straightness is what improves, and it is measurable:
zero exactly when every trajectory is a straight line traversed at constant speed. A straight flow is one the forward Euler method integrates without discretisation error, so is precisely the statement that one step suffices — which is why the paper reports a state-of-the-art one-step FID of 4.85 on CIFAR-10.
Distillation is the same loss with pinned rather than drawn: regressing onto over the reflow pairs makes a direct one-step map. Reflow is what makes that regression easy — it is fitting an already nearly-straight path, not shortcutting a curved one.
Time runs from noise to data: is and is .
Classes
Functions
rectified_flow_afhq_cat→ RectifiedFlowModelRectified Flow velocity field for AFHQ-Cat 256 x 256.
rectified_flow_afhq_cat_gen→ RectifiedFlowForImageGenerationRectified Flow generator for AFHQ-Cat 256 x 256.
rectified_flow_bedroom→ RectifiedFlowModelRectified Flow velocity field for LSUN Bedroom 256 x 256.
rectified_flow_bedroom_gen→ RectifiedFlowForImageGenerationRectified Flow generator for LSUN Bedroom 256 x 256.
rectified_flow_celeba_hq→ RectifiedFlowModelRectified Flow velocity field for CelebA-HQ 256 x 256.
rectified_flow_celeba_hq_gen→ RectifiedFlowForImageGenerationRectified Flow generator for CelebA-HQ 256 x 256.
rectified_flow_church→ RectifiedFlowModelRectified Flow velocity field for LSUN Church 256 x 256.
rectified_flow_church_gen→ RectifiedFlowForImageGenerationRectified Flow generator for LSUN Church 256 x 256.
rectified_flow_cifar→ RectifiedFlowModelRectified Flow velocity field for the CIFAR-10 setup.
rectified_flow_cifar_gen→ RectifiedFlowForImageGenerationRectified Flow generator for CIFAR-10 32 x 32.