MeanFlow Denoising: Clean Images in a Single Step
The Idea
Flow matching learns an instantaneous velocity field \(v(z_t, t)\) that carries one distribution into another; sampling integrates it with many small steps. MeanFlow [1] learns the average velocity over an interval instead,
\[ u(z_t, r, t) \triangleq \frac{1}{t-r}\int_r^t v(z_\tau, \tau)\,d\tau , \] so one evaluation jumps across the whole interval. Training never integrates anything: differentiating the definition gives the MeanFlow identity, whose right-hand side is the regression target (the total derivative is one Jacobian-vector product, torch.func.jvp):
Our change: MeanFlow usually starts from Gaussian noise and generates images. We start the flow from noisy images \(z_1\) and end it at clean ones, so the same one-step jump becomes a denoiser:
\[ \hat{x} = z_1 - u_\theta(z_1, 0, 1). \]The theory, from flow matching to MeanFlow, is written up step by step in my blog post From Flow Matching to MeanFlow; the full derivations are in the report.
Setup
- Data: MNIST, noisy input = clean image + \(\sigma\epsilon\) with \(\sigma \sim \mathcal{U}(0.3, 0.8)\).
- Model: a Diffusion Transformer (DiT): 32×32 input, 2×2 patches, width 144, 6 blocks, 3 heads; \(r\), \(t\) and the class label enter through adaLN.
- Training: MeanFlow loss with classifier-free guidance and the adaptive L2 loss of [1], \((r, t)\) from a logit-normal distribution, AdamW (lr \(10^{-4}\), batch 128), cosine annealing with warm restarts, 300k steps in FP16.
- Metric: PSNR on the test set.
Results
| Output | PSNR [dB] |
|---|---|
| Noisy input | 6.04 |
| 1 NFE | 22.65 |
| 2 NFE | 24.07 |
| 3 NFE | 24.08 |
| 4 NFE | 24.07 |
| 5 NFE | 24.06 |
What we learned
- The noise has to be smooth. With Gaussian noise the noisy-image distribution stays smooth, as the continuity equation behind flow matching needs. Clipping the noisy pixels to [0, 1] piles probability mass up at the bounds, and training failed.
- Cheap to sample, costly to train. Sampling takes one or two steps, but the JVP in every training step is expensive, and the fixed guidance scale limits flexibility.
- Next steps. Harder datasets (CIFAR-10), non-Gaussian noise, and a comparison with other denoisers.
References
- Z. Geng, M. Deng, X. Bai, J. Z. Kolter, K. He. Mean Flows for One-step Generative Modeling. arXiv:2505.13447, 2025.
- Y. Lipman, R. T. Q. Chen, H. Ben-Hamu, M. Nickel, M. Le. Flow Matching for Generative Modeling. ICLR, 2023.
- W. Peebles, S. Xie. Scalable Diffusion Models with Transformers. ICCV, 2023.
- Our code starts from the PyTorch MeanFlow implementation haidog-yaqub/MeanFlow.