File size: 6,695 Bytes
3970d4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e284498
3970d4f
 
f9395bb
3970d4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e284498
3970d4f
 
e284498
 
 
 
 
3970d4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
license: apache-2.0
base_model: stabilityai/stable-diffusion-3.5-medium
library_name: diffusers
pipeline_tag: text-to-image
tags:
- text-to-image
- diffusion
- flow-matching
- meanflow
- reinforcement-learning
- lora
---

<!-- markdownlint-disable MD028 MD033 MD041 -->
<div align="center">

<img src="assets/meanflownft_logo.jpg" width="48%" alt="MeanFlowNFT logo">

<h2>Bringing Forward-Process RL to Average-Velocity Generators</h2>

[Yushi Huang](https://harahan.github.io/)<sup>1,2</sup>\* Β·
[Xiangxin Zhou](https://zhouxiangxin1998.github.io/)<sup>1</sup>\*<sup>βœ‰</sup> Β·
[Jun Zhang](https://eejzhang.people.ust.hk/)<sup>2</sup> Β·
[Liefeng Bo](https://research.cs.washington.edu/istc/lfb/)<sup>1</sup> Β·
[Tianyu Pang](https://p2333.github.io/)<sup>1,βœ‰</sup>

<sup>1</sup>Tencent Hunyuan &nbsp;&nbsp; <sup>2</sup>The Hong Kong University of Science and Technology

\* Equal contribution &nbsp;&nbsp; <sup>βœ‰</sup>Corresponding authors

[![arXiv](https://img.shields.io/badge/arXiv-2607.15273-A42C25?style=for-the-badge&logo=arxiv&logoColor=white)](https://arxiv.org/abs/2607.15273)
[![Project Page](https://img.shields.io/badge/Project-Page-0F9D8A?style=for-the-badge&logo=googlechrome&logoColor=white)](https://harahan.github.io/meanflownft-project-page/)
[![Code](https://img.shields.io/badge/GitHub-MeanFlowNFT-181717?style=for-the-badge&logo=github)](https://github.com/Harahan/MeanFlowNFT)
[![Demo](https://img.shields.io/badge/πŸ€—-Interactive_Demo-FF4B4B?style=for-the-badge)](https://huggingface.co/spaces/Harahan/meanflownft-fewstep-generation)

</div>

MeanFlowNFT optimizes reward in induced instantaneous-velocity space while
retaining the average-velocity parameterization and native any-step MeanFlow
sampler. Training uses only forward-noised clean samples, without
reverse-trajectory likelihood estimation.

<p align="center">
  <a href="https://harahan.github.io/meanflownft-project-page/"><img src="assets/teaser.webp" width="100%" alt="Selected MeanFlowNFT generations"></a>
</p>

## 🍭 Overview

<table align="center">
  <tr>
    <td align="center" width="58%" valign="middle">
      <img src="assets/overview.webp" width="100%" alt="MeanFlowNFT method overview">
      <br><sub>Optimize in instantaneous-velocity space while preserving MeanFlow sampling.</sub>
    </td>
    <td align="center" width="42%" valign="middle">
      <img src="assets/algorithm.jpg" width="100%" alt="MeanFlowNFT update algorithm">
      <br><sub>One practical MeanFlowNFT update.</sub>
    </td>
  </tr>
</table>

## πŸ“¦ Contents

This repository contains the three ordered adapter components required to
reconstruct the final policy:

```text
.
β”œβ”€β”€ anyflow_pretrain/
β”‚   └── generator_ema.pt
β”œβ”€β”€ anyflow_onpolicy/
β”‚   └── generator_ema.pt
└── meanflownft/
    └── generator_ema.pt
```

The loading contract is strict:

1. Merge `anyflow_pretrain/generator_ema.pt` into the base transformer.
2. Merge `anyflow_onpolicy/generator_ema.pt` on top of that result.
3. Keep `meanflownft/generator_ema.pt` as the active final adapter.
4. Load the complete `delta_embedder` state from the final checkpoint.

The adapter checkpoints use LoRA rank **32**, alpha **64**, and attention
projections matching the released code. They also contain the trainable
flow-map `delta_embedder`, so they are not conventional LoRA-only files.
`SHA256SUMS` records the checksum of every checkpoint.

## πŸ“Š Results

<p align="center">
  <a href="assets/results_sd35.png"><img src="assets/results_sd35.png" width="100%" alt="MeanFlowNFT image-generation results"></a>
</p>

<p align="center">
  <a href="assets/results_wan.png"><img src="assets/results_wan.png" width="100%" alt="MeanFlowNFT video-generation results"></a>
</p>

MeanFlowNFT is best on **6 of 8** image metrics among the evaluated few-step
models, while 4-step Wan2.1 reaches **84.33 VBench**, surpassing 50-step
LongCat-Video RL. See the
[project page](https://harahan.github.io/meanflownft-project-page/) for full
comparisons, scaling curves, and qualitative results.

## πŸš€ Usage

Use the [MeanFlowNFT codebase](https://github.com/Harahan/MeanFlowNFT), whose
inference loader preserves the ordered adapter composition and full
`delta_embedder` state.

```bash
git clone https://github.com/Harahan/MeanFlowNFT.git
cd MeanFlowNFT
pip install -r requirements.txt
pip install -e .

export HF_REPO_ID=Harahan/MeanFlowNFT
hf download "${HF_REPO_ID}" --local-dir ./checkpoints/meanflownft

hf auth login
hf download stabilityai/stable-diffusion-3.5-medium \
    --local-dir ./models/stable-diffusion-3.5-medium
```

Run the final 4-step policy:

```bash
python inference.py configs/inference/sd35m_meanflow_nft.yaml \
    --override \
    pretrained_path=./models/stable-diffusion-3.5-medium \
    num_stages=3 \
    stage1_lora_path=./checkpoints/meanflownft/anyflow_pretrain/generator_ema.pt \
    stage2_lora_path=./checkpoints/meanflownft/anyflow_onpolicy/generator_ema.pt \
    stage3_lora_path=./checkpoints/meanflownft/meanflownft/generator_ema.pt \
    num_steps=4 \
    eval_reward=false \
    --prompt "a cinematic photo of a red panda"
```

The first two adapters are merged in order. The final MeanFlowNFT adapter stays
active and supplies `delta_embedder`, matching training-time evaluation. The
released inference config generates 1024Γ—1024 images with CFG-free flow-map
sampling.

> [!IMPORTANT]
> Do not load only the final checkpoint and do not use a generic LoRA loader
> that discards non-LoRA tensors. Either mistake drops part of the trained
> policy.

<!-- -->

> [!WARNING]
> These `.pt` files use PyTorch serialization. Load checkpoints only from a
> trusted source.

## πŸ“„ Citation

```bibtex
@misc{huang2026meanflownftbringingforwardprocessrl,
  title  = {MeanFlowNFT: Bringing Forward-Process RL to Average-Velocity Generators},
  author = {Huang, Yushi and Zhou, Xiangxin and Zhang, Jun and Bo, Liefeng and Pang, Tianyu},
  year={2026},
  eprint={2607.15273},
  archivePrefix={arXiv},
  primaryClass={cs.CV},
  url={https://arxiv.org/abs/2607.15273}, 
}
```

## πŸ™Œ Acknowledgements

This work builds on
[MeanFlow](https://github.com/Gsunshine/meanflow),
[AnyFlow](https://github.com/NVlabs/AnyFlow),
[DiffusionNFT](https://github.com/NVlabs/DiffusionNFT),
[Diffusers](https://github.com/huggingface/diffusers),
[Transformers](https://github.com/huggingface/transformers), and
[PEFT](https://github.com/huggingface/peft).

## βš–οΈ License

The repository metadata and accompanying code are released under Apache 2.0.
The base model and all derivative weights remain subject to the base model's
license and usage terms; review them before use or redistribution.