Views
No views yet


1conda create -n self_gradient_forcing python=3.10 -y
2conda activate self_gradient_forcing
3
4pip install -r requirements.txt
5pip install flash-attn --no-build-isolation
6python setup.py developbash scripts/download_weights.shhf by default. Set HF_CLI=huggingface-cli if your environment still uses the older command name.wan_models/Wan2.1-T2V-1.3B and wan_models/Wan2.1-T2V-14B.checkpoints/init/framewise/ and checkpoints/init/chunkwise/: ar_diffusion.pt, causal_cd.pt, and causal_ode.pt.checkpoints/framewise/ar/model.pt and checkpoints/chunkwise/ar/model.pt.prompts/vidprom_filtered_extended.txt.prompts/test_prompt.txt with 8 prompts. The launcher uses 8 GPUs when at least 8 GPUs are visible; otherwise it falls back to single-GPU serial inference. By default it generates 963 latent frames, which decode to about 240 seconds of video at 16 fps.
The inference script takes the release setting name (framewise or chunkwise) and selects the matching config and checkpoint automatically:configs/self_gradient_forcing_framewise.yamlconfigs/self_gradient_forcing_chunkwise.yamlscripts/infer_self_gradient_forcing.sh. Framewise defaults to KV_CACHE_SINK=4, KV_CACHE_FIFO_FRAMES=16, and KV_CACHE_CURRENT_FRAMES=1, so the actual --kv_cache_max_frames passed to inference.py is 4 + 16 + 1 = 21. Chunkwise defaults to KV_CACHE_SINK=3, KV_CACHE_FIFO_FRAMES=6, and KV_CACHE_CURRENT_FRAMES=3, so --kv_cache_max_frames is 12.bash scripts/infer_self_gradient_forcing.sh framewise1configs/self_gradient_forcing_framewise.yaml
2checkpoints/framewise/ar/model.ptbash scripts/infer_self_gradient_forcing.sh chunkwise1configs/self_gradient_forcing_chunkwise.yaml
2checkpoints/chunkwise/ar/model.pt1bash scripts/infer_self_gradient_forcing.sh \
2 framewise \
3 checkpoints/framewise/ar/model.pt \
4 prompts/test_prompt.txt1NUM_OUTPUT_FRAMES=963 SEED=42 OUTPUT_ROOT=outputs/demo \
2 bash scripts/infer_self_gradient_forcing.sh framewiselogs/.../checkpoint_model_*/model.pt path as the second argument. The script uses EMA weights by default; set USE_EMA=0 if you explicitly want the non-EMA generator weights.bash scripts/train_self_gradient_forcing_framewise.sh1bash scripts/train_self_gradient_forcing_framewise.sh \
2 configs/self_gradient_forcing_framewise.yaml \
3 logs/sgf_framewisebash scripts/train_self_gradient_forcing_chunkwise.sh1bash scripts/train_self_gradient_forcing_chunkwise.sh \
2 configs/self_gradient_forcing_chunkwise.yaml \
3 logs/sgf_chunkwise[config.yaml] [logdir] [extra train.py args...], matching the multi-node launcher convention used by the reference training scripts. They support single-node and multi-node training. For multi-node jobs, run the same command on every node within the gather window. The scripts auto-register nodes through .rendezvous/ on the shared filesystem and launch static torchrun with an IP master address.1GATHER_WINDOW=90 NUM_GPUS=8 MASTER_PORT=29501 ENABLE_WANDB=1 \
2 bash scripts/train_self_gradient_forcing_framewise.sh logs/sgf_framewise
3
4NNODES=2 NODE_RANK=0 MASTER_ADDR=10.0.0.1 NUM_GPUS=8 \
5 bash scripts/train_self_gradient_forcing_chunkwise.sh logs/sgf_chunkwisethu-ml/Causal-Forcing. We thank the open-source community for the infrastructure that made this release possible.1@misc{zhuang2026selfgradientforcingnative,
2 title={Self Gradient Forcing: Native Long Video Extrapolation},
3 author={Junhao Zhuang and Shiyi Zhang and Yuxuan Bian and Yaowei Li and Yawen Luo and Yijun Liu and Weiyang Jin and Songchun Zhang and Xianglong He and Xuying Zhang and Haoran Li and Haoyang Huang and Zeyue Xue and Nan Duan},
4 year={2026},
5 eprint={2607.20368},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2607.20368},
9}