使用 FLUX 模型需先在 HuggingFace 接受 FLUX.2 klein Base 9B 和 FLUX.1 dev 的使用条款,并执行 hf auth login 登录;安装需加 --no-build-isolation,且 PyTorch 版本要按官网选择匹配的 CUDA 版本;README 未给出具体显存门槛,跑大模型前需自行评估。

LakonLab
LakonikApache-2.0活跃维护提供 AsymFlow、pi-Flow、GMFlow 等流匹配与扩散蒸馏算法的官方 PyTorch 实现,用于加速文本到图像生成模型的训练与推理。
Official implementation of AsymFlow, pi-Flow, GMFlow
uv venv --python 3.10
source .venv/bin/activate
uv pip install torch==2.10.0 torchvision==0.25.0 --index-url https://download.pytorch.org/whl/cu128
uv pip install -e . --no-build-isolationREADME 未说明显存要求;环境为 Linux(Ubuntu 20 及以上)与 PyTorch 2.6+,示例安装使用 cu128 版 PyTorch。
斯坦福出品的扩散模型实验代码库,复现 AsymFlow、pi-Flow、GMFlow 三篇论文
提供 AsymFlow、pi-Flow、GMFlow 等流匹配与扩散蒸馏算法的官方 PyTorch 实现,用于加速文本到图像生成模型的训练与推理。
核心能力
- DDP、FSDP、FSDP2 无缝切换,支持梯度累积与混合精度
- 教师、学生、EMA 模型共享底层权重,兼容 DDP 与 FSDP
- 提供 FlowSDEScheduler 与 FlowMapSDEScheduler 两类流求解器
- 数据加载与 checkpoint 读写支持本地、S3、HuggingFace 和 HTTP
- 训练中在线计算 FID、KID、IS、CLIP、VQAScore、HPS 等指标
容易踩的坑
- v0.2.2LakonLab v0.2.2最新正式版2026-07-14 · 2026-07-14 01:10 UTC
Changelog
Added
- AsymFLUX.2 training instructions and data tool.
- Support for persistent local caching for S3 objects.
- Support for downloading from HuggingFace Space and Dataset repositories.
Changed
- Breaking: Rename the AsymFlow
base_rankoption tobasis_rank. - Improve DINOv2 position embedding resizing and compiled preprocessing.
- Reduce training log collection synchronization overhead.
- Strictly align DiT weight initialization to the original DiT implementation.
Fixed
- Fix NaN gradients in the Oklab codec.
- Fix CMYK image loading.
- v0.2.1LakonLab v0.2.12026-06-13 · 2026-06-13 11:25 UTC
查看更新说明
Changelog
Added
- AsymFLUX.2 variant models.
Changed
- Change default FSDP
buffer_dtypetofloat32. - Introduce various performance optimizations:
- Use fused foreach implementation for EMA.
- Add
compile_forwardforPretrainedDinoV2. - Change
metric_cpu_offloaddefault toTrue. - Add
log_intervaloption to reduce logging synchronization overhead (currently only forGaussianFlowandGMFlow). - Improve AsymFlow ImageNet training performance.
Fixed
- Fix an epoch counter error in saved checkpoints.
- v0.2.0LakonLab v0.2.02026-06-13 · 2026-06-13 11:24 UTC
查看更新说明
Changelog
Added
- AsymFlow release.
- JiT, RAE, and REPA-E model support and test configs.
- DPGBench, GenEval, and HPSv3 benchmark exporters.
- Media viewer pagination.
Changed
- Breaking: Replace the MMGeneration model registry dependency with local LakonLab registries.
- Breaking: Move model architectures from
lakonlab.models.architecturetolakonlab.models.architectures. - Update FSDP/DDP wrappers, checkpoint loading/saving, runner utilities, and S3 retry/refresh behavior.
Fixed
- Fix multiple bugs and edge cases.
- v0.1.2LakonLab v0.1.22026-01-19 · 2026-01-19 02:00 UTC
查看更新说明
Changelog
Added
- Support for loading prompt list from plain text files in
ImagePromptDataset. Example:prompt_dataset_kwargs=dict( path='text', data_files='https://raw.githubusercontent.com/ModelTC/Qwen-Image-Lightning/refs/heads/main/examples/prompt_list.txt', split="train"), - Support for
spawnstart method for S3 dataloader workers.
Changed
- Breaking: Teacher guidance parameters are now specified in the
teacher_test_cfgsection of the configuration file. Please update your configuration files accordingly. - Change
S3Backenddefault settings:- Set default
AWS_REGIONto None, - Disable anonymous mode by default.
- Set default
Fixed
- Fix the implementation of orthogonal guidance in GaussianFlow.
- Fix a bug with guidance interval.
- Fix
tools/train.pycrashing when using--launcher slurm. - Fix a bug in
tools/test.pythat caused the flag--reuse-vizto have no effect. - Fix a bug when running
tools/cache_image_prompt_data.pywith--skip-existingflag in distributed mode. - Fix several bugs that could cause distributed runs to hang due to I/O synchronization issues.
- Fix a bug that visualization images may not be saved in certain file systems due to unsupported filenames.
- Fix a version compatibility issue in the example GMDiT script in
configs/gmflow/README.md.
- Support for loading prompt list from plain text files in
- v0.1.1LakonLab v0.1.12025-12-18 · 2025-12-18 11:01 UTC
查看更新说明
Changelog
Changed
- Breaking: Rename the pretrained HuggingFace model argument
from_pretrainedtomodel_name_or_path. Please update any custom configurations or scripts accordingly.
Fixed
- Important: Fix a GMFlow batching bug introduced by the recent numerical-stability change.
- Fix loading pi-Flow adapters for TorchAO-quantized base models (#21).
- Fix a rare bug that could cause distributed runs to hang when loading pretrained HuggingFace models.
- Breaking: Rename the pretrained HuggingFace model argument
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
LakonLab: Official Codebase for AsymFlow, pi-Flow, and GMFlow
Official PyTorch implementation of the papers:
-
Asymmetric Flow Models [README] In NeurIPS 2026 Hansheng Chen, Jan Ackermann, Minseo Kim, Gordon Wetzstein, Leonidas Guibas Stanford University Project Page | arXiv | ComfyUI | AsymFLUX.2 klein Demo🤗
-
pi-Flow: Policy-Based Few-Step Generation via Imitation Distillation [README] In ICLR 2026 Hansheng Chen1, Kai Zhang2, Hao Tan2, Leonidas Guibas1, Gordon Wetzstein1, Sai Bi2 1Stanford University, 2Adobe Research arXiv | ComfyUI | pi-Qwen Demo🤗 | pi-FLUX Demo🤗 | pi-FLUX.2 Demo🤗
-
Gaussian Mixture Flow Matching Models [README] In ICML 2025 Hansheng Chen1, Kai Zhang2, Hao Tan2, Zexiang Xu3, Fujun Luan2, Leonidas Guibas1, Gordon Wetzstein1, Sai Bi2 1Stanford University, 2Adobe Research, 3Hillbot arXiv
🔥News
-
[May 20, 2026] AsymFlow is now supported in our ComfyUI extension.
-
[May 14, 2026] AsymFlow is released.
-
[Dec 12, 2025] pi-FLUX.2 is now available for 4-step image generation and editing. Check out the pi-FLUX.2 Demo🤗. Please re-install the latest version of LakonLab (this repository) to use pi-FLUX.2.
-
[Nov 7, 2025] ComfyUI-piFlow is now available. Supports 4-step sampling of Qwen-Image and Flux.1 dev using 8-bit models on a single consumer-grade GPU, powered by ComfyUI.
Installation
The code has been tested in the following environment:
- Linux (tested on Ubuntu 20 and above)
- PyTorch 2.6+
With the above prerequisites, run pip install -e . --no-build-isolation from the repository root to install the LakonLab codebase and its dependencies.
An example of installation commands is shown below:
# Move to this repository (the folder with setup.py) after cloning
cd <PATH_TO_YOUR_LOCAL_REPO>
# Create uv environment
uv venv --python 3.10
source .venv/bin/activate
# Install Pytorch. Goto https://pytorch.org/get-started/previous-versions/ to select the appropriate version
uv pip install torch==2.10.0 torchvision==0.25.0 --index-url https://download.pytorch.org/whl/cu128
# Install LakonLab in editable mode
uv pip install -e . --no-build-isolation
Additional notes:
To access FLUX models, please accept the FLUX.2 klein Base 9B conditions and FLUX.1 dev conditions, and then run hf auth login to login with your HuggingFace account.
Codebase
LakonLab is a high-performance codebase for experimenting with large diffusion models. Key features of LakonLab include:
-
Performance optimizations: Seamless switching between DDP, FSDP, and FSDP2, all supporting gradient accumulation and mixed precision.
-
Weight tying: For LoRA fine-tuning, the base weights of the teacher, student, and EMA models are tied, sharing the same underlying memory. This is compatible with DDP and FSDP.
-
Advanced flow solvers:
- FlowSDEScheduler: Generic flow SDE solver with an adjustable diffusion coefficient.
h=0corresponds to a flow ODE;h=1corresponds to a standard flow SDE;h='inf'corresponds to the re-noising sampler in the original consistency models. Powers the GM-SDE solver in GMFlow. - FlowMapSDEScheduler: Generic flow SDE solver for few-step flow map models, similar to above.
- FlowSDEScheduler: Generic flow SDE solver with an adjustable diffusion coefficient.
-
Storage backends: Most I/O operations (e.g., dataloaders, checkpoint I/O) support both local filesystems and AWS S3. In addition, model checkpoints can be loaded from HuggingFace (link format
huggingface://<HF_REPO_NAME>/<PATH_TO_MODEL>) and HTTP/HTTPS URLs directly. -
Streamlined training and evaluation: Supports online evaluation using common metrics, including FID, KID, IS, Precision, Recall, CLIP similarity, VQAScore, HPSv2, and HPSv3. Supports exporting results to offline evaluators, including HPSv3 Benchmark, DPG-Bench and GenEval.
-
3rd-party model inference reproduction:
-
ImageNet 256x256 models with ADM evaluation:
Model FID (reproduced) FID (official) SiT-XL/2 2.05 2.06 JiT-H/16 1.90 - DiT-XL RAE (unguided) 1.50 1.51 REPA-XL/2 1.38 1.42 REPA-E-XL VAVAE 1.12 1.12 Note: We use BF16 inference for all models except RAE. Original JiT paper uses its own evaluation protocol that differs from ADM evaluation.
-
Text-to-image models:
See examples in configs/misc and lakonlab/models/architectures/diffusers.
-
LakonLab uses the configuration system and code structure from MMCV.
Citation
@article{asymflow,
title={Asymmetric Flow Models},
author={Hansheng Chen and Jan Ackermann and Minseo Kim and Gordon Wetzstein and Leonidas Guibas},
url={https://arxiv.org/abs/2605.12964},
journal={arXiv preprint arXiv:2605.12964},
year={2026},
}
@article{piflow,
title={pi-Flow: Policy-Based Few-Step Generation via Imitation Distillation},
author={Hansheng Chen and Kai Zhang and Hao Tan and Leonidas Guibas and Gordon Wetzstein and Sai Bi},
url={https://arxiv.org/abs/2510.14974},
journal={arXiv preprint arXiv:2510.14974},
year={2025},
}
@article{gmflow,
title={Gaussian Mixture Flow Matching Models},
author={Hansheng Chen and Kai Zhang and Hao Tan and Zexiang Xu and Fujun Luan and Leonidas Guibas and Gordon Wetzstein and Sai Bi},
url={https://arxiv.org/abs/2504.05304},
journal={arXiv preprint arXiv:2504.05304},
year={2025},
}