Skip to content
module

MeanFlow

14 members
lucid.models.generative.mean_flow

MeanFlow — one-step generation by modelling the average velocity.

Geng, Deng, Bai, Kolter and He, arXiv:2505.13447, 2025. The fifth step of the flow lineage and the one that removes the integral: where Flow Matching learns the instantaneous velocity and integrates it at sampling time, MeanFlow learns the average velocity over an interval, which is that integral, and reads a sample off a single evaluation.

Image Generation
Paper

Geng, Zhengyang, Mingyang Deng, Xingjian Bai, J. Zico Kolter, and Kaiming He. "Mean Flows for One-step Generative Modeling." arXiv preprint [arXiv:2505.13447](https://arxiv.org/abs/2505.13447), 2025.

Overview

Flow Matching models the instantaneous velocity v(zt,t)v(z_t, t) — the tangent of the path at one instant — and recovers a sample by integrating it. MeanFlow models the average velocity over an interval, defined as that integral divided by its width:

u(zt,r,t)≜1t−r∫rtv(zτ,τ) dτ.u(z_t, r, t) \triangleq \frac{1}{t - r}\int_r^t v(z_\tau, \tau)\,d\tau .

The two coincide only in the limit r→tr \to t. Away from it the average velocity points along the displacement between the two times rather than along the curve, which is exactly what a one-step sampler needs: with uu in hand the whole path is zr=zt−(t−r) u(zt,r,t)z_r = z_t - (t - r)\,u(z_t, r, t), and generation from noise is a single evaluation at (r,t)=(0,1)(r, t) = (0, 1).

Training on that definition directly would require the integral. The way through is to multiply it out and differentiate with respect to tt, holding rr fixed, which turns the integral into the MeanFlow Identity:

u(zt,r,t)=v(zt,t)−(t−r) ddtu(zt,r,t).u(z_t, r, t) = v(z_t, t) - (t - r)\,\frac{d}{dt}u(z_t, r, t).

Every term on the right is available. The instantaneous velocity is the closed-form conditional velocity Flow Matching already regresses onto, and the total derivative expands by the chain rule into

ddtu(zt,r,t)=v(zt,t) ∂zu+∂tu,\frac{d}{dt}u(z_t, r, t) = v(z_t, t)\,\partial_z u + \partial_t u,

which is one Jacobian-vector product of uθu_\theta along the tangent (v, 0, 1)(v,\, 0,\, 1) — a single extra forward-mode pass, not a second-order solve. The identity becomes a regression target,

utgt=vt−(t−r)(vt ∂zuθ+∂tuθ),u_{\mathrm{tgt}} = v_t - (t - r)\bigl(v_t\,\partial_z u_\theta + \partial_t u_\theta\bigr),

and the loss is ∥uθ−sg(utgt)∥2\lVert u_\theta - \mathrm{sg}(u_{\mathrm{tgt}}) \rVert^2. The stop-gradient is what keeps the cost at one extra pass: without it the Jacobian-vector product would itself need to be differentiated.

Setting r=tr = t collapses the second term and recovers Flow Matching exactly, so the method is Flow Matching with a modified target rather than a different framework. The paper draws r≠tr \neq t for only a quarter of samples; at 0% it is Flow Matching and one-step generation fails outright (FID 328.91 against 61.06).

Classes

Functions