Inference and evaluation
Inference and evaluation scripts for FastGen.
Inference
Generate images and videos using pretrained or distilled models.
Key Arguments
Guidance
model.guidance_cfg decides which guidance terms run, and --neg_prompt_file
supplies their negative prompts. Classifier-free guidance (cfg.scale) and mix
guidance (mix.scale) evaluate a negative branch, so with either of them active,
pass a negative prompt file, or scripts/inference/prompts/empty_prompt.txt for
the empty negative prompt; omitting the file does not disable them. Configs whose
guidance runs neither term, such as those of guidance-distilled networks, need no
negative prompt. Class-conditional image runs (--classes) ignore the file and
use the all-zero class vector as the negative condition.
Example commands
Unconditional
Class-Conditional
Text-to-Image (T2I)
Image Editing (I2I)
Text-to-Video (T2V)
Image-to-Video (I2V)
Camera-Conditioned I2V
Video-to-Video (V2V)
Text-to-Video+Audio (LTX-2)
Video2World (Cosmos)
Causal / Autoregressive
Causal configs (e.g., config_sft_causal_wan22_5b.py) generate autoregressively, chunk by chunk with a KV cache.
Generating longer videos via extrapolation needs a CausVid or Self-Forcing config, such as
WanT2V/config_sf.py; other methods, including CausalSFT
configs like the one above, raise an error:
--num_segments N: Generate N consecutive video segments autoregressively (default: 1)--overlap_frames K: Overlap K latent frames between segments for temporal consistency (default: 0); K must end on a chunk boundary
FlashDreams Example: Self-Forcing Wan 2.1 T2V
FlashDreams provides an optimized
streaming runtime with torch.compile, CUDA Graph replay, and multi-GPU context
parallelism. This example uses it to run FastGen-distilled Self-Forcing Wan 2.1
T2V checkpoints. Other model families require a compatible FlashDreams
integration and checkpoint mapping.
Install the self_forcing integration from a local FlashDreams clone. The script targets FlashDreams v0.1.0; later versions moved this integration and changed its API:
Then run inference from the FastGen repo using that environment:
For DCP checkpoints, consolidate first with scripts/fsdp_convert.py, converting the network that inference uses: the first EMA when the config enables one (e.g. --model-type ema_model for use_ema=True), otherwise the default net_model. Monolithic checkpoints select the EMA automatically.
The inference settings are loaded from the FastGen config, and overrides use the same trailing - syntax as other FastGen scripts.
The rollout uses the first prompt of --prompt-file, which defaults to the same validation prompts as the other inference scripts.
For an approximately 30-second rollout at 16 FPS with a 1.3B chunk-3 config, use --sink --total-blocks 40.
For 14B, pass --config fastgen/configs/experiments/WanT2V/config_sf_14b.py.
Videos are written to $FASTGEN_OUTPUT_ROOT/<project>/<group>/<name>/flashdreams by default.
FID Evaluation
Compute Fréchet Inception Distance (FID) for image models using fid/compute_fid_from_ckpts.py.
Usage
For each checkpoint in trainer.checkpointer.save_dir, the script samples
eval.num_samples images from the student and records its FID against the
reference statistics in
{log_config.save_path}/{eval.samples_dir}/fid.json. See the
script docstring for checkpoint selection,
reruns, and storage requirements.
Config Options
Reference Statistics
FID reference statistics can be computed with the following commands:
This computes the FID reference statistics according to the EDM and EDM2 repositories and stores them in $DATA_ROOT_DIR/fid-refs/: