rCM & Causal-rCM: Leading and Unified Algorithms/Infrastructures for Bidirectional/Autoregressive Video Diffusion Distillation at Scale
rCM & Causal-rCM: Leading and Unified Algorithms/Infrastructures for Bidirectional/Autoregressive Video Diffusion Distillation at Scale
rCM: Score-Regularized Continuous-Time Consistency Model
Causal-rCM: A Unified Teacher-Forcing and Self-Forcing Open Recipe for Streaming Video Generation and Interactive World Models
State-of-the-Art JVP-Based Diffusion Distillation · Few-Step Video Generation · Scaling Up sCM/MeanFlow · Causal/Autoregressive Extension
A Leading, Unified and Scalable Open-Source Algorithm-and-Infrastructure Recipe for Diffusion Distillation and Causal Training
Notice: rCM now includes a causal/autoregressive training stack, showing how teacher-forcing (forward-divergence/offline) CM complements self-forcing (reverse-divergence/on-policy) DMD in autoregressive video diffusion distillation.
Illustration of Causal-rCM.This repository now supports advanced algorithms and infrastructure for autoregressive video diffusion training and distillation. Causal-rCM provides a state-of-the-art causal distillation recipe. See Causal_rCM.md for details.
Also included:
Optimized causal inference with time benchmarking, quantized KV cache, and bounded-memory length extrapolation.
Simplified and reproducible VBench evaluation suite.
Infrastructure comparison with other codebases.
rCM is the first work that:
| teacher | DMD2 | SiD |
|---|---|---|
| sCM | rCM (Ours) | |
rCM achieves both high quality and strong diversity.
| 1-step | 2-step | 4-step |
|---|---|---|
Our training and inference are based on native PyTorch, completely free from accelerate and diffusers.
…Below is an example inference script for running rCM on T2V:
…See Wan examples for additional usage and I2V examples.
For Causal-rCM inference, I2V, quantized KV cache, length extrapolation, and training recipes, see Causal_rCM.md.
In this repo, we provide training code based on Wan2.1 and its synthetic data.
Advanced training infrastructure:
model.config.fsdp_shard_size.model_parallel.context_parallel_size. Ulysses CP requires that the CP size is a factor of num_heads (12 for Wan2.1 1.3B, 40 for Wan2.1 14B). When enabling CP, ensure that the number of GPUs is divisible by the chosen CP size. The effective batch size is reduced by a factor of the CP size. model.config.net.sac_config.mode.trainer.grad_accum_iter.Distillation baselines (dCM, sCM, DMD):
model.config.cm_type=dcm and optionally disabling the DMD loss (setting model.config.net_fake_score=null or model.config.loss_scale_dmd=0).model.config.net_fake_score=null or model.config.loss_scale_dmd=0.model.config.loss_scale=0), and optionally fixing the backward simulation timesteps to predetermined values (setting model.config.dmd_fix_timesteps=True, recommended).Note: sCM + DMD joint training may be unstable for some models. We recommend a most robust way of applying rCM: splitting the distillation process into separate stages (dCM (warmup) -> sCM -> DMD (+sCM)).
rcm/utils/flash_attention_jvp_triton.pyrcm/networks/wan2pt1_jvp.pyrcm/models/t2v_model_distill_rcm.pyrcm/models/t2v_model_causal.pyrcm/utils/blockmask.py, rcm/utils/kv_cache.pyDownload the Wan2.1 teacher checkpoints in .pth format and VAE/text encoder to assets/checkpoints:
# make sure git lfs is installed
git clone https://huggingface.co/worstcoder/Wan assets/checkpointsrCM and Causal-rCM checkpoints can be placed in the same assets/checkpoints directory. See Causal_rCM.md for causal checkpoint naming and per-step inference commands.
Our code is based on FSDP2 and relies on Distributed Checkpoint (DCP) for loading and saving checkpoints. Before training, optionally convert .pth teacher checkpoints to .dcp first (this step can be ommited now, because the current code also supports loading .pth/.pt directly):
python -m torch.distributed.checkpoint.format_utils torch_to_dcp assets/checkpoints/Wan2.1-T2V-1.3B.pth assets/checkpoints/Wan2.1-T2V-1.3B.dcpAfter training, the saved .dcp checkpoints can be converted to .pth using the script scripts/dcp_to_pth.py.
We provide Wan2.1-14B-synthesized dataset with prompts from https://huggingface.co/gdhe17/Self-Forcing/resolve/main/vidprom_filtered_extended.txt. Download to assets/datasets using:
# make sure git lfs is installed
git clone https://huggingface.co/datasets/worstcoder/Wan_datasets assets/datasetsSingle-node training example:
…Please refer to rcm/configs/experiments/rcm/wan2pt1_t2v.py for the 14B config or perform modifications as needed.
For causal training, see rcm/configs/experiments/causal_rcm/wan2pt1_t2v.py and Causal_rCM.md.
There are promising directions to explore based on rCM. For example:
We thank the Cosmos-Predict2 and Cosmos-Predict2.5 project for providing the awesome open-source video diffusion training codebase.
…No open issues yet, or sync has not completed.