This repo will contain the official pytorch code for "AlphaFlow: Understanding and Improving MeanFlow models". Our proposed method for understanding and improving MeanFlow models.
Uncurated samples (seeds 1-8) from the DiT-XL model for MeanFlow [1] and
Clone the repo, install the conda environment and the packages in environment.yml:
git clone git@github.com:snap-research/alphaflow.git
cd alphaflow
conda env create -f environment.yml -p ./env
conda activate ./envCopy an example of user settings:
cp configs/env/user-example.yaml configs/env/user.yamlNow, edit configs/env/user.yaml to set the correct paths to the data, the environment and Wandb config (if required). You need to at least define project_path and conda_init_bin_path in this file.
| Model | FID-NFE-1 | FDD-NFE-1 | FID-NFE-2 | FDD-NFE-2 |
|---|---|---|---|---|
| MeanFlow-B/2 | 43.1 | 819.2 | 38.5 | 787.6 |
| α-Flow-B/2 | 40.2 | 781.0 | 37.1 | 775.0 |
| MeanFlow-B/2-cfg | 6.04 | 312.3 | 5.17 | 232.1 |
| α-Flow-B/2-cfg | 5.40 | 287.1 | 5.01 | 231.8 |
| MeanFlow-XL/2-cfg | 3.47 | 185.8 | 2.46 | 108.7 |
| α-Flow-XL/2-cfg | 2.95 | 164.6 | 2.34 | 105.7 |
| α-Flow-XL/2+-cfg | 2.58 | 148.4 | 2.15 | 96.8 |
Download the checkpoints and VAE encoder checkpoint sd_vae_ft_ema.pt from our Hugging Face repository into the ./snapshots folder.
mkdir snapshotsUse the following commands to generate samples.
# AlphaFlow-B/2 NFE-1
torchrun --max-restarts=0 --standalone --nproc-per-node=8 scripts/generate.py ckpt.snapshot_path=./snapshots/alphaflow-B-2.pt output_dir=data/generate/alphaflow-B-2-1-NFE/ seeds=0-49999 batch_size=32 sampling=recflow sampling.sigma_noise=1 sampling.num_steps=1 sampling.enable_trajectory_sampling=true
# AlphaFlow-XL-2-plus-cfg NFE-2
torchrun --max-restarts=0 --standalone --nproc-per-node=8 scripts/generate.py ckpt.snapshot_path=./snapshots/alphaflow-XL-2-plus-cfg.pt output_dir=data/generate/alphaflow-XL-2-plus-cfg-2-NFE/ seeds=0-49999 batch_size=32 sampling=recflow sampling.sigma_noise=1 sampling.num_steps=2 sampling.enable_trajectory_sampling=true sampling.enable_consistency_sampling=trueWe provide a script ./scripts/evaluate.sh to generate samples and compute metrics for all released models.
To evaluate a specific directory of generated samples (for FID, FDD, FCD):
# AlphaFlow-B/2 NFE-1
torchrun --max-restarts=0 --standalone --nproc-per-node=8 scripts/evaluate.py dataset.resolution=\[1,256,256\] gen_dataset.src=data/generate/alphaflow-B-2-1-NFE/ gen_dataset.resolution=\[1,256,256\] gen_dataset.label_shape=\[\]Download and reorganize the ImageNet dataset using the provided script. This script prepares the data structure required by our custom dataloader.
python scripts/data_scripts/prepare_imagenet.py --target_directory ./data/imagenetWe use hydra for experiment configuration. All primary experiment settings are stored in ./infra/experiments/experiments-alphaflow.yaml.
You can launch experiments in two ways:
Run the experiment directly without cloning the repository internally.
torchrun --max-restarts=0 --standalone --nproc-per-node=8 infra/launch.py alphaflow-sigmoid-latentspace-B-2 direct_launch=true wandb.enabled=falseClone the repository into an ./experiments directory first, then run the experiment from the cloned version.
mkdir experiments
python infra/launch.py alphaflow-sigmoid-latentspace-B-2 wandb.enabled=falseA full list of possible arguments for the launch script can be found in ./configs/infra.yaml.
bibtex
@article{zhang2025alphaflow,
title={AlphaFlow: Understanding and Improving MeanFlow Models},
author={Zhang, Huijie and Siarohin, Aliaksandr and Menapace, Willi and Vasilkovsky, Michael and Tulyakov, Sergey and Qu, Qing and Skorokhodov, Ivan},
journal={arXiv preprint arXiv:2510.20771},
year={2025}
}