This repository contains the official implementation of the paper “Distribution Matching Variational AutoEncoder”.
Distribution Matching Variational AutoEncoder
Sen Ye, Jianning Pei, Mengde Xu, Shuyang Gu, Chunyu Wang, Liwei Wang, Han Hu
PKU, UCAS, Tencent
conda create -n dmvae python=3.10 -y
conda activate dmvae
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1
pip install -r requirements.txt- DMVAE:
vae.pt,latent_mean=0.0685, latent_scale=0.1763 - DiT checkpoint at epoch 64:
ep64.pt - DiT checkpoint at epoch 400:
ep400.pt - DiT checkpoint at epoch 800:
ep800.pt
By default, all training scripts assume ImageNet data under: ./data/ImageNet
You can change this path via the --dataset_path argument in each script.
We provide a toy example for probing the effect of different distribution matching loss in toy_example_2d/.
-
sshape.pyis used to generate a 2D reference distribution. -
train_diffusion.pyis used to train$s_{\text{real}} (v_{\text{real}})$ modelling the reference distribution. -
dmd.pyis used to align a uniform distribution to the reference distribution by different losses.
Train a LightningDiT-Mini to model the reference distribution:
torchrun --nproc_per_node=1 toy_example_2d/train_diffusion.py --base_dir "your_exp_dir"Then run distribution matching:
torchrun --nproc_per_node=1 toy_example_2d/dmd.py --log_dir "your_exp_dir" --real_model_ckpt_path "s_real_path" --fake_model_ckpt_path "s_real_path" --dmd_loss_type "dmd"bash scripts/train_tokenizer.shbash scripts/train_diffusion.shbash scripts/train_dmd.shSet vae_ckpt_path of the tokenizer after DMD training and run bash scripts/train_diffusion.sh .
To reproduce the paper results:
- Download pretrained VAE and pretrained DiT checkpoints.
- Set
vae_ckpt_path,ckptaccordingly. - Run:
bash scripts/sample50k.shIf you find this repository useful in your research or applications, please consider citing:
@misc{dmvae,
title={Distribution Matching Variational AutoEncoder},
author={Sen Ye and Jianning Pei and Mengde Xu and Shuyang Gu and Chunyu Wang and Liwei Wang and Han Hu},
year={2025},
eprint={2512.07778},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2512.07778},
}
