FastGen

NVlabsApache-2.0活跃维护

NVIDIA 开源的扩散模型加速生成方案,用一致性模型、分布匹配蒸馏和流映射等蒸馏技术,把扩散模型的多步采样压缩到极少步数,显著提升出图速度。

NVIDIA FastGen: Fast Generation from Diffusion Models

v0.2.0发布于 2026-10-28 17:04 UTC1,113star +4 / 7 天93fork同步于 2026-11-10 11:50 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/NVlabs/FastGen.git
cd FastGen
pip install -e .
硬件要求按 README 说明

README 未说明具体显存要求;训练示例在 OOM 时建议调小 batch size 并自动启用梯度累积。ARM64 上 PyPI 只提供 CPU 版 PyTorch,需先装 CUDA 版。

支持 Apple Silicon需要 CUDA多卡 / 张量并行
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

NVIDIA 开源的扩散模型蒸馏加速框架,把预训练扩散模型蒸馏成少步快速生成

NVIDIA 开源的扩散模型加速生成方案,用一致性模型、分布匹配蒸馏和流映射等蒸馏技术,把扩散模型的多步采样压缩到极少步数,显著提升出图速度。

核心能力

  • 支持轨迹匹配、分布匹配、微调三类蒸馏方法
  • 覆盖 T2I、I2I、I2V、V2V 及视频+音频多模态任务
  • 内置 EDM、DiT、SDXL、FLUX、Wan、Cosmos 等网络实现
  • 支持 DDP 与 FSDP2 多卡训练,可扩展至 20B 参数以上
  • 提供 ComfyUI 自定义节点做交互式推理

容易踩的坑

跑 Quick Start 前需先下载 CIFAR-10 数据集和预训练 EDM 模型(scripts/download_data.py --dataset cifar10);ARM64 上直接 pip install -e . 会装到 CPU 版 PyTorch,需先装 cu130 的 torch;并非所有方法与网络组合都受支持,需参考预定义 configs;W&B 未配置 API key 时会交互式提示。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

2 个版本v0.2.0
  1. v0.2.0FastGen v0.2.0最新正式版2026-10-28 · 2026-10-28 17:04 UTC

    FastGen v0.2.0

    FastGen v0.2.0 is the first major update since v0.1.0 and includes every pull request merged since then (#10, #25–#29, #33, #37 and #38). Some import paths, config fields and inference flags changed; see "Upgrading from v0.1.0" below.

    Highlights

    • Methods: AYF, PDD, AnyFlow, Phased DMD, Causal-Forcing and backward simulation.
    • Networks: FLUX.2, Wan 2.2 A14B, Cosmos 3, LingBot-world, and FastGen's first video+audio models: LTX-2, LTX-2.3, LTX-2.5 and MiniMax H3.
    • Training core: LoRA for any network, one guidance API for sampling and training, sharded EMA under FSDP2, and a separate precision for method and sampling state.
    • Tooling: ComfyUI custom nodes, a VLM judge, FlashDreams streaming inference, and 117 experiment configs, up from 73.

    New methods

    Trajectory matching now groups the consistency-model and knowledge-distillation methods (CM, ECT, sCM, TCM, MeanFlow, KD, CausalKD) and adds:

    • AYF (AYFModel): continuous-time flow map distillation.
    • PDD (PDDModel): parallel decoding distillation for image and video generation.

    Distribution matching adds:

    • AnyFlow (AnyFlowModel, #25): any-step video generation with on-policy flow map distillation.
    • Phased DMD: few-step distribution matching with score matching within timestep subintervals.
    • Causal-Forcing: autoregressive diffusion distillation for real-time interactive video.
    • Backward simulation: the student trains on its own sampling trajectories instead of noised data.

    Fine-tuning adds teacher forcing for causal models (CausalTeacherForcingSFTModel). Causal video methods share autoregressive student sampling with KV caching.

    New networks

    DataNew in v0.2.0
    ImageFLUX.2 [dev] and FLUX.2 [klein] base 4B and 9B, each for text-to-image and image editing
    VideoWan 2.2 A14B (mixture of experts) for text- and image-to-video, Cosmos 3, and LingBot-world for camera-controlled generation
    Video+audioLTX-2, LTX-2.3 and LTX-2.5, with image-to-video recipes for LTX-2 and LTX-2.3; MiniMax H3

    fastgen/networks/README.md lists the supported checkpoints.

    Training core

    • Module preparation. Modules are prepared once, in the same order on every rank (precision, train mode, gradients, then device placement or FSDP2 sharding), including tied parameters and shared submodules.
    • LoRA. model.net_adapter adds PEFT adapters and extra trainable modules to any network. The teacher reuses the student's frozen base weights instead of keeping a second copy. Adapters train with DDP; FSDP is not supported yet.
    • Guidance. model.guidance_cfg combines classifier-free, mix and skip-layer guidance, each schedulable over time, with optional rescaling. Sampling and teacher passes during training share it.
    • Sampling grids. model.student_grid_cfg sets the student's sampling grid (type, steps and options), replacing student_sample_steps and sample_t_cfg.t_list.
    • Precision. precision now covers only data and method/sampling arithmetic, so it can differ from the model weights (precision_model). Optimizer state, master weights and EMA use precision_opt, which replaces precision_fsdp.
    • FSDP2. EMA copies are sharded like the live network instead of being replicated on every GPU, and validation samples come from the EMA with FSDP too. model.extra_fsdp_modules shards frozen modules such as the teacher or text encoder, and meta-device initialization (model.meta_init) also works without FSDP.
    • torch.compile. model.torch_compile_mode compiles the training networks (#28).
    • Environment. A .env file (see .env.example) sets the output, data, checkpoint a
  2. v0.1.0FastGen v0.1.02026-07-24 · 2026-07-24 01:41 UTC
    查看更新说明

    Release of NVIDIA FastGen, a PyTorch framework for building fast generative models using various distillation and acceleration techniques.

    Highlights

    Modular, model-agnostic design
    Built with Hydra and OmegaConf, allowing methods, networks, and data configurations to be composed independently and extended with additional models and datasets.

    Distillation and training methods
    CM, sCM, TCM, MeanFlow, DMD2, f-Distill, LADD, CausVid, Self-Forcing, SFT, KD, and more.

    Network support
    EDM, EDM2, DiT, Stable Diffusion 1.5, SDXL, Flux, Qwen-Image, WAN, CogVideoX, and Cosmos Predict2.

    Image and video workflows
    Support for T2I, T2V, I2V, V2V, and autoregressive long-video generation.

    Production-scale training
    DDP and FSDP2, mixed precision, EMA, Weights & Biases integration, automatic resume, and WebDataset with local or S3-backed data.

    Reproducibility

    The FastGen results reported in the README files included in this release were obtained using this version.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Documentation Agent Skills License PyTorch NVIDIA

    Note: The current codebase offers early access to new, experimental features. Results reported in the README files were obtained using FastGen v0.1.0.

    FastGen is a PyTorch-based framework for building fast generative models using various distillation and acceleration techniques. It supports:

    • large-scale training with ≥20B parameters.
    • different tasks and modalities, including T2I, I2I, I2V, V2V, multimodal video+audio generation, and causal generation.
    • various distillation methods, including flow maps, distribution matching, parallel decoding distillation, self-forcing, and more.

    Repository Structure

    fastgen/
    ├── fastgen/
    │   ├── callbacks/           # Training callbacks (EMA, profiling, etc.)
    │   ├── configs/             # Configuration system
    │   │   ├── experiments/     # Experiment configs
    │   │   └── methods/         # Method-specific configs
    │   ├── datasets/            # Dataset loaders
    │   ├── methods/             # Trajectory matching, distribution matching, and fine-tuning
    │   ├── networks/            # Neural network architectures
    │   ├── third_party/         # Third-party dependencies
    │   ├── trainer.py           # Main training loop
    │   └── utils/               # Utilities (distributed, checkpointing)
    ├── comfyui/                 # ComfyUI custom nodes for interactive inference
    ├── scripts/                 # Inference and evaluation scripts
    ├── tests/                   # Unit tests
    ├── Makefile                 # Development commands (lint, format, test)
    └── train.py                 # Main training entry point
    

    Setup

    Recommended: Use the provided Docker container for a consistent environment. See CONTRIBUTING.md for Docker setup instructions. Otherwise, create a new conda environment with conda create -y -n fastgen python=3.12.3 pip; conda activate fastgen.

    Installation

    git clone https://github.com/NVlabs/FastGen.git
    cd FastGen
    pip install -e .
    

    On ARM64, PyPI only provides CPU builds of PyTorch, so install the CUDA build first:

    pip install "torch>=2.10,<2.11" "torchvision>=0.25,<0.26" --index-url https://download.pytorch.org/whl/cu130
    pip install -e .
    

    Credentials (Optional)

    For W&B logging, get your API key and save it to credentials/wandb_api.txt or set the WANDB_API_KEY environment variable. Without either of these, W&B will prompt for your API key interactively. For more details, including S3 storage and other environment variables, see fastgen/configs/README.md.

    Quick Start

    Before running the following commands, download the CIFAR-10 dataset and pretrained EDM models:

    python scripts/download_data.py --dataset cifar10
    

    For other datasets and models, see fastgen/networks/README.md and fastgen/datasets/README.md.

    Basic Training

    python train.py --config=fastgen/configs/experiments/EDM/config_dmd2_fast.py
    

    If you run out-of-memory, try a smaller batch-size, e.g., dataloader_train.batch_size=32, which automatically uses gradient accumulation to match the global batch-size.

    Expected Output: See the training log for a link to the run on wandb.ai. Training outputs go to $FASTGEN_OUTPUT_ROOT/{project}/{group}/{name}/, where name defaults to the config file's name without .py (see Run Directory). With default settings, outputs are organized as follows:

    FASTGEN_OUTPUT/fastgen/cifar10/config_dmd2_fast/
    ├── checkpoints/    # Model checkpoints in the format {iteration:07d}.pth
    │   ├── 0001000.pth
    │   └── ...
    ├── config.yaml     # Resolved configuration for reproducibility
    ├── wandb_id.txt    # W&B run ID for resuming
    └── ...
    

    DDP/FSDP2 Training

    For multi-GPU training, use DDP:

    torchrun --nproc_per_node=8 train.py \
        --config=fastgen/configs/experiments/EDM/config_dmd2_fast.py \
        - trainer.ddp=True log_config.name=test_ddp
    

    For large models, use FSDP2 for model sharding by replacing trainer.ddp=True with trainer.fsdp=True.

    Inference

    python scripts/inference/image_model_inference.py --config fastgen/configs/experiments/EDM/config_dmd2_fast.py \
      --classes=10 --prompt_file=scripts/inference/prompts/classes.txt --ckpt_path=FASTGEN_OUTPUT/fastgen/cifar10/config_dmd2_fast/checkpoints/0002000.pth - log_config.name=test_inference
    

    For other inference modes and FID evaluations, see scripts/README.md. FastGen-distilled models can also be served with:

    • FlashDreams for optimized streaming inference of Self-Forcing models.
    • vLLM-Omni for DMD2 model inference.

    Command-Line Overrides

    Override any config parameter using Hydra-style syntax (note the - separator):

    python train.py --config=path/to/config.py - key=value nested.key=value
    

    Use +key=value for a key the config does not define yet; see fastgen/configs/README.md.

    Documentation

    The documentation is published at docs.nvidia.com/fastgen. Its pages are generated from the READMEs in this repository, plus the authored training and checkpoints, troubleshooting, and release notes pages. See Contributing to the docs for how to edit them. The main components and their source READMEs are:

    ComponentREADMEDescription
    Methodsfastgen/methods/README.mdTrajectory matching, distribution matching, and fine-tuning methods
    Networksfastgen/networks/README.mdNetwork architectures (Flux, Qwen-Image, Wan, LingBot-world, Cosmos, LTX-2, etc.) and pretrained models
    Configsfastgen/configs/README.mdConfiguration system, environment variables, and creating custom configs
    Datasetsfastgen/datasets/README.mdDataset preparation and WebDataset loaders (image, video, video+audio)
    Callbacksfastgen/callbacks/README.mdTraining callbacks (EMA, logging, gradient clipping, etc.)
    Inferencescripts/README.mdInference modes (T2I, I2I, T2V, I2V, V2V, etc.) and FID evaluation
    ComfyUIcomfyui/README.mdComfyUI custom nodes for interactive teacher/student inference
    Skillsskills/README.mdAgent Skills for coding agents: setup, configuration, data, training, inference, validation, and extending FastGen
    Third Partyfastgen/third_party/README.mdThird-party dependencies (Depth Anything V2, etc.)

    Supported Methods

    CategoryMethods
    Trajectory MatchingCM, ECT, sCM, TCM, MeanFlow, AYF, KD, CausalKD, PDD
    Distribution MatchingDMD2, f-Distill, Phased DMD, LADD, AnyFlow, CausVid, Self-Forcing, Causal-Forcing
    Fine-TuningSFT, CausalSFT (diffusion/teacher forcing)

    See fastgen/methods/README.md for details.

    Supported Networks and Data

    FastGen is designed to be agnostic to the network and data and you can add your own architectures and datasets (see fastgen/networks/README.md and fastgen/datasets/README.md). For reference, we provide the following implementations:

    DataNetworks
    ImageEDM, EDM2, DiT, SiT, SD 1.5, SDXL, FLUX.1, FLUX.2, Qwen-Image
    VideoWan2.1, Wan2.2, Wan Vace, LingBot-world, CogVideoX, Cosmos Predict2, Cosmos 3
    Video+AudioLTX-2, LTX-2.3, LTX-2.5, MiniMax H3

    See fastgen/networks/README.md for details. Not all combinations of methods and networks are currently supported. We provide typical use-cases in our predefined configs in fastgen/configs/experiments.

    Adoption, Collaboration, and Usage

    FastGen is used across NVIDIA and the community to build fast generative models.

    Models Distilled Using FastGen

    Projects Using FastGen

    FastGen Collaborations

    Contributing

    We welcome contributions! Please see CONTRIBUTING.md for details.

    We thank everyone who has helped design, build, and test FastGen!

    • Core contributors: Julius Berner, Chao Liu
    • Other contributors: Weili Nie, Amirmojtaba Sabour, James Lucas, David Pankratz, Sushil Koundinyan, Sihyun Yu, Willis Ma, Yilun Xu, Shengqu Cai, Xinyin Ma, Yanke Song
    • Collaborators: Sophia Zalewski, Wei Xiong, Christian Laforte, Sajad Norouzi, Kaiwen Zheng, Miloš Hašan, Saeed Hadadan, Gene Liu, David Dynerman, Alicia Sui, Grace Lam, Pooya Jannaty, Jan Kautz, and many more.
    • Project lead: Arash Vahdat

    License

    This project is licensed under the Apache License 2.0 - see LICENSE for details. Third-party licenses are documented in licenses/README.md.

    Reference

    @misc{fastgen2026,
      title={NVIDIA FastGen: Fast Generation from Diffusion Models},
      author={Berner, Julius and Liu, Chao and Vahdat, Arash},
      url={https://github.com/NVlabs/FastGen},
      year={2026},
    }