# What one sampling step measures in the MeanFlow PyTorch reproduction

> This MeanFlow implementation reports ImageNet results for several SiT checkpoints. The latent cache, the guidance used during training and the sampler settings all affect which result a reader can reproduce.

**zhuyu-cs/MeanFlow** — Pytorch implementation of MeanFlow on ImageNet and CIFAR10

- Repository: https://github.com/zhuyu-cs/MeanFlow
- Stars: 521 · Forks: 39
- Language: Python
- License: MIT
- Published: 2026-11-24 · Updated: 2026-11-24 · Language: en
- Canonical page: https://hysenlabs.com/projects/zhuyu-cs-meanflow

## One model step starts from a latent

In the one-step branch of meanflow_sampler.py, the sampler creates a batch of start and end times and asks the model for a displacement. It subtracts the result from the input latent. That is the operation behind the one-step label in the repository's ImageNet table. The output of this sampler is still a latent. The evaluation program also loads a variational autoencoder to decode samples, then compares statistics from generated images with reference statistics. None of that surrounding work disappears when the number of sampling steps is one.

The same sampler implements a multi-step path. It divides the interval from one to zero into shorter intervals and updates its working latent at each step. This gives a researcher a meaningful comparison using the same family of models. It also makes step count an essential part of the result. A lower score from two steps answers a different question from a score measured at one. Neither figure by itself establishes the time an application will take to generate and decode an image on its own hardware.

## The ImageNet pipeline writes two databases

The ImageNet 256 instructions expect ILSVRC2012 training images laid out in class directories. The first preprocessing script sorts the class directory names before mapping each directory to an integer label. It collects image files and writes an LMDB. The README asks the user to edit the source paths before running that converter. Run the following lines from the checkout after configuring those paths.

```bash
cd ./preprocess_imagenet
python image2lmdb.py
```

This first database holds the input to a second pass. The cache program reads the source LMDB and writes a separate target LMDB. Its output records contain the label and filename together with the encoder distribution parameters for an image and its horizontal flip. That is more specific than the shorthand “cached latents” suggests. A directory of JPEGs, the converted image database and the database of encoded records correspond to three different points in the workflow. Passing the image database as a training latent cache would give the reader the wrong record structure.

## Which autoencoder produced those records?

The README contains a link whose text names the EMA variant of the Stable Diffusion VAE while its URL points to the MSE variant. The preprocessing and evaluation code settle what this particular checkout requests. Both load the model identified as stabilityai/sd-vae-ft-ema. When comparing an existing cache with a published result, record the identifier used when the cache was created. A link caption alone leaves room for two quite different interpretations.

The authors suggest that changing the tokenizer might improve results. They do not present a controlled comparison of the two VAEs in the reported ImageNet table. Replacing the encoder changes training inputs, and replacing the decoder also changes the images evaluated at the end. A useful comparison would identify both choices as well as the checkpoint held fixed. The dependency installation command from the README is short.

```bash
pip install -r requirements.txt
```

The requirements file lists torch, torchvision, diffusers and accelerate without fixed versions. It requests a fork of torch-fidelity from its master branch. For comparisons across installations, retaining the resolved package versions and evaluator revision is more informative than recording only that this command completed.

## Guidance during training changes the evaluation setting

The sampler accepts a guidance scale. When labels are supplied and the scale exceeds one, the implementation concatenates labelled and unlabelled inputs, sends the larger batch through the model and combines the predictions. With scale one it does not take this extra guidance branch. The distinction matters even if the requested number of time steps stays the same, because the amount of model input passed through that step can differ.

For checkpoints the authors trained with classifier-free guidance incorporated into the model, the README explicitly calls for a sampling scale of 1.0. The argument parser in evaluate.py defaults to 1.5. Omitting the option in that case would quietly select a different evaluation from the one described. The example evaluation command sets the scale explicitly and also identifies the checkpoint and the number of sampling steps. In a result log, those settings belong alongside the architecture name. An architecture name alone cannot distinguish the two guidance paths.

## Comparing like rows in the FID table

The reproduction table includes two SiT-B/4 rows trained for 80 epochs. At one evaluation step, the authors report a Fréchet Inception Distance of 58.74 for the row without classifier-free guidance and 15.43 for the other row. The corresponding figures they attribute to the paper are 61.06 and 15.53. Those four values identify a specific comparison. They are measurements reported by the authors, and they are statistics for populations of images. They do not describe the correctness or visual quality of any single generated picture.

The fine-tuning table asks a different question. It begins with a pretrained model and reports separate one-step and two-step values. Its first row gives 4.52 and 2.81 respectively. The authors describe a period of fine-tuning without classifier-free guidance before enabling it. An account of the training budget should therefore include the pretrained starting point as well as the subsequent stages. Comparing only the last fine-tuning epoch count with a model trained from scratch would conceal much of the work behind that row.

## Choose the checkpoint and branch before allocating compute

The ImageNet evaluation example uses distributed sampling to produce 50,000 images. The evaluation script loads the EMA entry from the checkpoint. Its command-line interface also accepts a path for the reference statistics. This makes the checkpoint format, step count and identity of the reference distribution concrete items to check before running a large sampling job. A matching model name on two result sheets leaves all three open.

CIFAR-10 has its own instructions. The README directs users to the cifar10 experimental branch for that path, while the main checkout discussed here contains the ImageNet preprocessing and sampling files. Someone comparing this reproduction with the original research also has a choice of codebases. The README links the authors' official MeanFlow repositories separately from this implementation. For questions about the results in this repository, follow its own cache, checkpoint and evaluator together. For questions about the paper's reported setup, start with the corresponding paper row and its official implementation.

## Conclusion

Use this implementation to study the link between an ImageNet checkpoint and its sampler. For a reproduction, record the VAE, guidance scale and evaluation step count alongside the score. For CIFAR-10, start with the separate branch the authors identify.

## FAQ

### Which VAE does this MeanFlow checkout use for ImageNet?

The cache builder and evaluation program both request stabilityai/sd-vae-ft-ema. A README link points to an MSE model despite its EMA caption.

### What guidance scale is documented for checkpoints trained with guidance?

The authors say to use 1.0 at inference when guidance was incorporated during training. The evaluation parser defaults to 1.5, so specify the intended setting explicitly.

### Does one-step sampling remove the need for VAE decoding?

The one-step sampler returns a latent. The ImageNet evaluation still decodes generated latents and compares the resulting image distribution with reference statistics.

## Sources

- [evaluate.py](https://github.com/zhuyu-cs/MeanFlow/blob/40a766689c8bccad61f2993ee6905630ac030ff3/evaluate.py)
- [LICENSE](https://github.com/zhuyu-cs/MeanFlow/blob/40a766689c8bccad61f2993ee6905630ac030ff3/LICENSE)
- [meanflow_sampler.py](https://github.com/zhuyu-cs/MeanFlow/blob/40a766689c8bccad61f2993ee6905630ac030ff3/meanflow_sampler.py)
- [Official README](https://github.com/zhuyu-cs/MeanFlow#readme)
- [preprocess_imagenet/image2lmdb.py](https://github.com/zhuyu-cs/MeanFlow/blob/40a766689c8bccad61f2993ee6905630ac030ff3/preprocess_imagenet/image2lmdb.py)
- [preprocess_imagenet/main_cache.py](https://github.com/zhuyu-cs/MeanFlow/blob/40a766689c8bccad61f2993ee6905630ac030ff3/preprocess_imagenet/main_cache.py)
- [Project repository](https://github.com/zhuyu-cs/MeanFlow)
- [README.md](https://github.com/zhuyu-cs/MeanFlow/blob/40a766689c8bccad61f2993ee6905630ac030ff3/README.md)
- [requirements.txt](https://github.com/zhuyu-cs/MeanFlow/blob/40a766689c8bccad61f2993ee6905630ac030ff3/requirements.txt)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/zhuyu-cs-meanflow
