📚English | 📚中文阅读
一个专门为🤗Diffusers而开发的,统一、灵活以及无需训练的缓存加速框架
🎉目前, cache-dit 支持Diffusers中几乎所有DiT模型🎉
🔥Qwen-Image | FLUX.1 | Qwen-Image-Lightning | Wan 2.1 | Wan 2.2 🔥
🔥HunyuanImage-2.1 | HunyuanVideo | HunyuanDiT | HiDream | AuraFlow🔥
🔥CogView3Plus | CogView4 | LTXVideo | CogVideoX | CogVideoX 1.5 | ConsisID🔥
🔥Cosmos | SkyReelsV2 | VisualCloze | OmniGen 1/2 | Lumina 1/2 | PixArt🔥
🔥Chroma | Sana | Allegro | Mochi | SD 3/3.5 | Amused | ... | DiT-XL🔥
我们非常兴奋地宣布,cache-dit 的**首个 API 稳定版本 (v1.0.0)**终于正式发布!
cache-dit 是一款为 🤗 Diffusers 打造的统一化(Unified)、高灵活(Flexible)、无需训练(Training-free) 的缓存加速框架,仅需一行代码即可实现缓存加速。核心特性包括统一缓存接口(Unified Cache APIs)、前向模式匹配(Forward Pattern Matching)、自动块适配(Automatic Block Adapter)、混合前向模式(Hybrid Forward Pattern)、DBCache 机制、TaylorSeer 校准器(TaylorSeer Calibrator) 及Cache CFG。
pip3 install -U cache-dit # pip3 install git+https://github.com/vipshop/cache-dit.git您可以从 PyPI 安装 cache-dit 的稳定版本,或从 GitHub 安装最新的开发版本。然后,只需一行代码即可体验
>>> import cache_dit
>>> from diffusers import DiffusionPipeline
>>> pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image") # Can be any diffusion pipeline
>>> cache_dit.enable_cache(pipe) # One-line code with default cache options.
>>> output = pipe(...) # Just call the pipe as normal.
>>> stats = cache_dit.summary(pipe) # Then, get the summary of cache acceleration stats.
>>> cache_dit.disable_cache(pipe) # Disable cache and run original pipe.点击这里查看更多Image/Video加速示例
🔥Wan2.2 MoE | +cache-dit:2.0x↑🎉 | HunyuanVideo | +cache-dit:2.1x↑🎉
🔥Qwen-Image | +cache-dit:1.8x↑🎉 | FLUX.1-dev | +cache-dit:2.1x↑🎉
🔥Qwen...Lightning | +cache-dit:1.14x↑🎉 | HunyuanImage | +cache-dit:1.7x↑🎉
🔥Qwen-Image-Edit | Input w/o Edit | Baseline | +cache-dit:1.6x↑🎉 | 1.9x↑🎉
🔥FLUX-Kontext-dev | Baseline | +cache-dit:1.3x↑🎉 | 1.7x↑🎉 | 2.0x↑ 🎉
🔥HiDream-I1 | +cache-dit:1.9x↑🎉 | CogView4 | +cache-dit:1.4x↑🎉 | 1.7x↑🎉
🔥CogView3 | +cache-dit:1.5x↑🎉 | 2.0x↑🎉| Chroma1-HD | +cache-dit:1.9x↑🎉
🔥Mochi-1-preview | +cache-dit:1.8x↑🎉 | SkyReelsV2 | +cache-dit:1.6x↑🎉
🔥VisualCloze-512 | Model | Cloth | Baseline | +cache-dit:1.4x↑🎉 | 1.7x↑🎉
🔥LTX-Video-0.9.7 | +cache-dit:1.7x↑🎉 | CogVideoX1.5 | +cache-dit:2.0x↑🎉
🔥OmniGen-v1 | +cache-dit:1.5x↑🎉 | 3.3x↑🎉 | Lumina2 | +cache-dit:1.9x↑🎉
🔥Allegro | +cache-dit:1.36x↑🎉 | AuraFlow-v0.3 | +cache-dit:2.27x↑🎉
🔥Sana | +cache-dit:1.3x↑🎉 | 1.6x↑🎉| PixArt-Sigma | +cache-dit:2.3x↑🎉
🔥PixArt-Alpha | +cache-dit:1.6x↑🎉 | 1.8x↑🎉| SD 3.5 | +cache-dit:2.5x↑🎉
🔥Asumed | +cache-dit:1.1x↑🎉 | 1.2x↑🎉 | DiT-XL-256 | +cache-dit:1.8x↑🎉
- 全面支持 🤗 Diffusers:值得注意的是,cache-dit 目前已支持 Diffusers 中几乎所有基于 DiT(Transformer 扩散模型)的流水线,例如 Qwen-Image、FLUX.1、Qwen-Image-Lightning、Wan 2.1/2.2、HunyuanImage-2.1、HunyuanVideo、HunyuanDiT、HiDream、AuraFlow、CogView3Plus、CogView4、LTXVideo、CogVideoX/X 1.5、ConsisID、Cosmos、SkyReelsV2、VisualCloze、OmniGen 1/2、Lumina 1/2、PixArt、Chroma、Sana、Allegro、Mochi、SD 3/3.5、Amused 以及 DiT-XL 等。
- 极致易用:在大多数场景下,仅需
♥️ 一行♥️ 代码即可启用:cache_dit.enable_cache(...)。调用该接口后,正常使用流水线即可享受加速。 - 轻松集成新模型:统一缓存接口、前向模式匹配、自动块适配、混合前向模式及 Patch Functor 等特性,使其具备极强的功能性与灵活性。例如,我们实现了对 HunyuanImage-2.1 的 🎉 首日支持(Day 1 Support)——即便该模型当时尚未在 Diffusers 库中正式发布。
- 业界领先性能:与 Δ-DiT、Chipmunk、FORA、DuCa、TaylorSeer、FoCa 等算法相比,在加速比低于 4 倍的场景下,cache-dit 的 DBCache 机制实现了最优精度。
- 支持 4/8 步蒸馏模型:令人惊喜的是,cache-dit 的 DBCache 机制可适配极少量步数的蒸馏模型,而这是许多其他方法无法实现的。
- 兼容多种优化方案:设计上可与 torch.compile、模型 CPU 卸载、顺序 CPU 卸载、分组卸载等优化方案无缝协同。
- 混合缓存加速:目前已支持 DBCache + 校准器 混合方案(例如 DBCache + TaylorSeerCalibrator)。其中 DBCache 作为指示器(Indicator) 决定何时(when) 缓存,校准器则负责决定如何(how) 缓存。未来将支持更多主流缓存加速算法(如 FoCa 等)及更多基准测试,敬请期待更新!
- 🤗 Diffusers 生态集成:🔥 cache-dit 已正式加入 🤗 Diffusers 社区生态,成为首个针对 DiT 的缓存加速框架!查看文档:Diffusers 官方文档。
对于更高级的功能,如Unified Cache APIs、Forward Pattern Matching、Automatic Block Adapter、Hybrid Forward Pattern、DBCache、TaylorSeer Calibrator和Hybrid Cache CFG,详情请参考🎉User_Guide.md。
- ⚙️Installation
- 🔥Benchmarks
- 🔥Supported Pipelines
- 🎉Unified Cache APIs
- ⚡️DBCache: Dual Block Cache
- ⚡️DBPrune: Dynamic Block Prune
- ⚡️Hybrid Cache CFG
- 🔥Hybrid TaylorSeer Calibrator
- ⚡️Hybrid Context Parallelism
- 🛠Metrics Command Line
- ⚙️Torch Compile
- 📚API Documents
如何贡献?点亮星标 ⭐️ 支持我们,或查看 CONTRIBUTE.md。
本项目的顺利推进与落地,离不开 唯品会-计算机视觉算法团队 的鼎力支持。特别鸣谢该团队在文档建设、功能测试及生产级应用落地等关键环节提供的专业指导与全面协助。
@misc{cache-dit@2025,
title={cache-dit: A Unified, Flexible and Training-free Cache Acceleration Framework for Diffusers.},
url={https://github.com/vipshop/cache-dit.git},
note={Open-source software available at https://github.com/vipshop/cache-dit.git},
author={vipshop.com},
year={2025}
}