Zihan Su1,2*, Junhao Zhuang2*โ , Yaowei Li2, Siwen Lu1, Haoran Li2, Lingen Li3, Haoyu Wu2
Weiyang Jin2, Songchun Zhang2, Haoyang Huang2, Chun Yuan1โ , Zeyue Xue2, Nan Duan2
1Tsinghua University ย 2Joy Future Academy, JD ย 3The Chinese University of Hong Kong
*Equal contribution. ย โ Corresponding authors.
โญ If Self Gradient Forcing Plus is useful for your research, please consider starring this repository.
-
2026-10-9: We release the code for reproducing the gradient-conflict phenomena observed at the SGF and teacher-forcing initialization checkpoints. See the reproduction guide. In fact, beyond Wan2.1-1.3B, we have also observed this phenomenon in LTX-2.5.
-
2026-10-7: Paper, model checkpoints, inference scripts, and training code are publicly released.
Left to right: Self Forcing ยท Self Gradient Forcing ยท Self Gradient Forcing Plus. More videos are available on our project page.
By the train window
train_window_inline.mp4
A tiny monster, a candle
tiny_monster_inline.mp4
We uncover conflicting gradients between context writing and denoising in SGF. These gradients partially cancel on shared parameters, motivating separate optimization.
SGF+ separates context-writing and denoising parameters to resolve conflicting gradient updates, improving autoregressive video generation and enabling rollouts of up to 24 hours from only 5s training windows.
The environment follows the SGF setup.
git clone https://github.com/Zihan-Su/Self_Gradient_Forcing_Plus.git
cd Self_Gradient_Forcing_Plus
conda create -n sgf_plus python=3.10 -y
conda activate sgf_plus
pip install -r requirements.txt
pip install flash-attn --no-build-isolation
python setup.py developRun the following commands from the repository root.
bash scripts/download_weights.shThe script uses the Hugging Face CLI command hf by default. Set HF_CLI=huggingface-cli if your environment still uses the older command name.
It downloads:
- Wan base models to
wan_models/Wan2.1-T2V-1.3Bandwan_models/Wan2.1-T2V-14B. - Causal-Forcing AR initialization checkpoints to
checkpoints/init/chunkwise/ar_diffusion.ptandcheckpoints/init/framewise/ar_diffusion.pt. - Released SGF+ inference checkpoints to
hf_weights/chunkwise/model.ptandhf_weights/framewise/model.pt. - The training prompt list to
prompts/vidprom_filtered_extended.txt.
Run hf auth login first if authentication is required.
The default prompt file is 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 (chunkwise or framewise) and a checkpoint path, and selects the matching config automatically:
- chunkwise config:
configs/sgf_plus_chunkwise.yaml - framewise config:
configs/sgf_plus_framewise.yaml
The long-video KV-cache geometry is set in scripts/infer_self_gradient_forcing.sh, which is called by the SGF+ launcher. 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. Framewise defaults to KV_CACHE_SINK=4, KV_CACHE_FIFO_FRAMES=16, and KV_CACHE_CURRENT_FRAMES=1, so --kv_cache_max_frames is 21.
bash scripts/infer_sgf_plus.sh chunkwise hf_weights/chunkwise/model.ptThis uses:
configs/sgf_plus_chunkwise.yaml
hf_weights/chunkwise/model.pt
bash scripts/infer_sgf_plus.sh framewise hf_weights/framewise/model.ptThis uses:
configs/sgf_plus_framewise.yaml
hf_weights/framewise/model.pt
bash scripts/infer_sgf_plus.sh \
chunkwise \
hf_weights/chunkwise/model.pt \
prompts/test_prompt.txtUseful overrides:
NUM_OUTPUT_FRAMES=963 SEED=42 OUTPUT_ROOT=outputs/demo \
bash scripts/infer_sgf_plus.sh chunkwise hf_weights/chunkwise/model.ptFor trained checkpoints, pass the release setting first and the produced logs/.../checkpoint_model_*/model.pt path as the second argument. The script uses EMA weights by default; set USE_EMA=0 to use the non-EMA generator weights.
The reactor/ integration serves SGF+ as an interactive video
model with Reactor Runtime and a browser frontend. It uses
the released chunkwise checkpoint on one NVIDIA B200, supports text and optional
reference images, and lets you update the prompt while generation continues.
Install the Reactor CLI, Docker and the NVIDIA Container Toolkit. From the repository root, build and start the service on an available GPU; inference weights download automatically on first startup:
cd reactor
reactor build
reactor run --gpus device=0 --port 8080Once http://localhost:8080/health reports "state":"available", open another
terminal at the repository root and start the frontend (Node.js 22.12+ and npm):
cd reactor/demo
npm ci
npm run devOpen the printed URL, normally http://localhost:5173,
set Runtime URL to http://localhost:8080, and click Connect. Enter a
prompt, optionally choose an image, then click Start new video. Use
Update prompt to change subsequent chunks and Pause / Resume to hold or
continue the same video. Playback stays at the original 16 FPS export rate.
See the Reactor guide for controls, validation and remote
connection requirements, including WebRTC over SSH.
All training runs reported in the paper use 64 GPUs without gradient accumulation.
Reference training budget: 1,900 steps for framewise SGF+ and 700 steps for chunkwise SGF+. The number of training steps needed may vary slightly across random seeds.
bash scripts/train_sgf_plus_chunkwise.shEquivalent explicit form:
bash scripts/train_sgf_plus_chunkwise.sh \
configs/sgf_plus_chunkwise.yaml \
logs/sgf_plus_chunkwisebash scripts/train_sgf_plus_framewise.shEquivalent explicit form:
bash scripts/train_sgf_plus_framewise.sh \
configs/sgf_plus_framewise.yaml \
logs/sgf_plus_framewiseThe launchers accept [config.yaml] [logdir] [extra train.py args...] and support single-node and multi-node training. Without explicit or scheduler-provided topology settings, nodes auto-register through .rendezvous/ on the shared filesystem and launch static torchrun with an IP master address. For multi-node jobs, run the same command on every node within the gather window.
Useful overrides:
GATHER_WINDOW=90 NUM_GPUS=8 MASTER_PORT=29501 ENABLE_WANDB=1 \
bash scripts/train_sgf_plus_chunkwise.sh logs/sgf_plus_chunkwiseTo specify the topology manually, set NNODES, NODE_RANK, MASTER_ADDR and MASTER_PORT. Use a distinct NODE_RANK on each node and matching values for the other settings.
To reproduce our gradient-conflict experiments, see the experiment guide.
This repository builds on Self Gradient Forcing, Causal-Forcing, and Wan.
For questions, please contact Zihan Su at zh-su24@mails.tsinghua.edu.cn or Junhao Zhuang at zhuangjh23@tsinghua.org.cn.
This project is released under the Apache-2.0 license.
@article{su2026sgf+,
title={SGF+: Decoupling Gradient Flows for Autoregressive Video Generation},
author={Su, Zihan and Zhuang, Junhao and Li, Yaowei and Lu, Siwen and Li, Haoran and Li, Lingen and Wu, Haoyu and Jin, Weiyang and Zhang, Songchun and Huang, Haoyang and others},
journal={arXiv preprint arXiv:2610.10429},
year={2026}
}
@article{zhuang2026self,
title={Self Gradient Forcing: Native Long Video Extrapolation},
author={Zhuang, Junhao and Zhang, Shiyi and Bian, Yuxuan and Li, Yaowei and Luo, Yawen and Liu, Yijun and Jin, Weiyang and Zhang, Songchun and He, Xianglong and Zhang, Xuying and others},
journal={arXiv preprint arXiv:2607.20368},
year={2026}
}

