Towards Stabilized and Efficient Diffusion Transformers through Long-Skip-Connections with Spectral Constraints
🎉🎉🎉 About
This repository contains the official PyTorch implementation of the paper: Towards Stabilized and Efficient Diffusion Transformers through Long-Skip-Connections with Spectral Constraints.
Diffusion Transformers (DiT) have emerged as a powerful architecture for image and video generation, offering superior quality and scalability. However, their practical application suffers from inherent dynamic feature instability, leading to error amplification during cached inference. Through systematic analysis, the authors identify the absence of long-range feature preservation mechanisms as the root cause of unstable feature propagation. Skip-DiT is an image and video generative DiT variant enhanced with Long-Skip-Connections (LSCs) which stabilize feature dynamics and enable an efficient statical caching mechanism.
🌟 Feature Stability of Skip-DiT
Visualization of the feature stability of Skip-DiT compared with vanilla DiT. Skip-DiT also shows superior training efficiency.
🛒 Released Models
| Model | Task | Training Data | Backbone | Size(G) | Skip-Cache |
|---|---|---|---|---|---|
| Latte-skip | text-to-video | Vimeo | Latte | 8.76 | ✅ |
| DiT-XL/2-skip | class-to-image | ImageNet | DiT-XL/2 | 11.40 | ✅ |
| ucf101-skip | class-to-video | UCF101 | Latte | 2.77 | ✅ |
| taichi-skip | class-to-video | Taichi-HD | Latte | 2.77 | ✅ |
| skytimelapse-skip | class-to-video | SkyTimelapse | Latte | 2.77 | ✅ |
| ffs-skip | class-to-video | FaceForensics | Latte | 2.77 | ✅ |
Pretrained text-to-image Model of HunYuan-DiT can be found in Huggingface.
🚀 Quick Start
Text-to-video Inference
To generate videos with Latte-skip, you just need 3 steps:
# 1. Prepare your conda environments
cd text-to-video ; conda env create -f environment.yaml ; conda activate latte
# 2. Download checkpoints of Latte and Latte-skip
python download.py
# 3. Generate videos with only one command line!
python sample/sample_t2v.py --config ./configs/t2v/t2v_sample_skip.yaml
# 4. (Optional) To accelerate generation with skip-cache, run following command
python sample/sample_t2v.py --config ./configs/t2v/t2v_sample_skip_cache.yaml --cache N2-700-50
Text-to-image Inference
To generate images with Hunyuan-DiT:
# 1. Prepare your conda environments
cd text-to-image ; conda env create -f environment.yaml ; conda activate HunyuanDiT
# 2. Download checkpoints of Hunyuan-DiT
mkdir ckpts ; huggingface-cli download Tencent-Hunyuan/HunyuanDiT-v1.2 --local-dir ./ckpts
# 3. Generate images with only one command line!
python sample_t2i.py --prompt "渔舟唱晚" --no-enhance --infer-steps 100 --image-size 1024 1024
# 4. (Optional) To accelerate generation with skip-cache, run the following command
python sample_t2i.py --prompt "渔舟唱晚" --no-enhance --infer-steps 100 --image-size 1024 1024 --cache --cache-step 2
🏃 Training
The training code of Latte-skip is available in the repository. To train the text-to-video model:
- Prepare your text-video datasets and implement the
text-to-video/datasets/t2v_joint_dataset.py - Run the two-stage training strategy:
- Freeze all the parameters except skip-branches. Set
freeze=Trueintext-to-video/configs/train_t2v.yaml. And then run the training scripts attext-to-video/train_scripts/t2v_joint_train_skip.sh. - Overall training. Set
freeze=Falseintext-to-video/configs/train_t2v.yaml. And then run the training scripts.
- Freeze all the parameters except skip-branches. Set
🌺 Acknowledgement
Skip-DiT has been greatly inspired by the following works and teams: DeepCache, Latte, DiT, and HunYuan-DiT.
License
The code and model weights are licensed under the Apache License 2.0.
Citation
@article{chen2024towards,
title={Towards Stabilized and Efficient Diffusion Transformers through Long-Skip-Connections with Spectral Constraints},
author={Chen, Guanjie and Zhao, Xinyu and Zhou, Yucheng and Chen, Tianlong and Yu, Cheng},
journal={arXiv preprint arXiv:2411.17616},
year={2024}
}