zhuang2002 GitHub avatar

Self_Gradient_Forcing

zhuang2002

Self Gradient Forcing (SGF) enables video diffusion models trained on only 5-second clips to generate minute-long videos with improved identity, layout, and temporal consistency by recovering the missing context-gradient path via a bounded two-pass replay mechanism.

Stars

106

7-day growth

No data

Forks

2

Open issues

1

License

Apache-2.0

Last updated

2026-07-23

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It directly tackles the long-video extrapolation challenge—a major bottleneck in current video generation—without needing longer training sequences, and provides open-source code, pretrained models, and clear inference/training instructions built on top of the Wan video model ecosystem.

Who it is for

  • Video generation researchers exploring long-form synthesis
  • AI practitioners working with diffusion-based video models
  • Developers building tools for automated long-video content creation
  • Academics studying temporal consistency in generative models

Use cases

  • Generating extended video sequences from short text prompts
  • Extrapolating short video clips to full minute-long scenes for prototyping
  • Producing consistent long-form animations with stable object identity
  • Serving as a baseline or module for research in long-video generation

Strengths

  • Achieves native long-video extrapolation (∼240 seconds at 16 fps) from models trained only on 5-second windows
  • Provides two configurable variants (framewise and chunkwise) with ready-to-use inference and training scripts
  • Fully open-source: includes paper, pretrained checkpoints (both 1.3B and 14B scales), and complete codebase
  • Supports single-node and multi-node distributed training with automatic node registration

Considerations

  • Requires specific environment setup (Causal-Forcing, Wan base models, Flash Attention) and substantial GPU resources (8 GPUs recommended for inference)
  • KV-cache geometry must be manually configured via shell variables; may need tuning for different hardware or output lengths
  • Limited documentation on failure cases or quantitative performance benchmarks beyond the teaser results

README quick start

🌀 Self Gradient Forcing

Native Long-Video Extrapolation

     

Junhao Zhuang, Shiyi Zhang, Yuxuan Bian, Yaowei Li, Yawen Luo, Yijun Liu, Weiyang Jin, Songchun Zhang, Xianglong He, Xuying Zhang, Haoran Li, Haoyang Huang, Zeyue Xue, Nan Duan

Joy Future Academy, JD

⭐ If Self Gradient Forcing is useful for your research, please consider starring this repository.

🔥 News

  • 2026-07-23: Paper, model checkpoints, inference scripts, and training code are publicly released.

🧠 Method Overview

Self Gradient Forcing (SGF) recovers the missing context-gradient path for self-generated causal memory through a bounded two-pass replay, enabling models trained with only a 5-second window to extrapolate to minute-scale videos with stronger identity, layout, and temporal stability.

🛠️ Installation

The environment follows the Causal-Forcing setup.

conda create -n self_gradient_forcing python=3.10 -y
conda activate self_gradient_forcing

pip install -r requirements.txt
pip install flash-attn --no-build-isolation
python setup.py develop

⬇️ Download Weights

bash scripts/download_weights.sh

The 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.3B and wan_models/Wan2.1-T2V-14B.
  • All Causal-Forcing initialization checkpoints under checkpoints/init/framewise/ and checkpoints/init/chunkwise/: ar_diffusion.pt, causal_cd.pt, and causal_ode.pt.
  • Released SGF inference checkpoints to checkpoints/framewise/ar/model.pt and checkpoints/chunkwise/ar/model.pt.
  • The training prompt list to prompts/vidprom_filtered_extended.txt.

🚀 Inference

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 (framewise or chunkwise) and selects the matching config and checkpoint automatically:

  • framewise config: configs/self_gradient_forcing_framewise.yaml
  • chunkwise config: `configs/self_gradie

Description

Self Gradient Forcing (SGF) recovers the missing context-gradient path for self-generated causal memory through a bounded two-pass replay, enabling models trained with only a 5-second window to extrapolate to minute-scale videos with stronger identity, layout, and temporal stability.

Related repositories

Similar projects matched by category, topics, and programming language.

lopopolo
Featured
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI & Machine LearningAI Agents
2,390
slvDev
Featured
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI & Machine LearningLarge Language Models
1,960
littledivy
Featured
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI & Machine Learning
1,482