vipshop/cache-dit
关于
面向 DiTs 的原生 PyTorch 推理引擎,支持缓存、并行、量化和 CPU 卸载。
机器学习实测星标增长
- 24小时
- +1
- 7天
- +2
- 15天
- +7
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文**🤗Why Cache-DiT❓❓**Cache-DiT is built on top of the 🤗Diffusers library and now supports nearly ALL DiTs from Diffusers. It provides hybrid cache acceleration (DBCache, TaylorSeer, SCM, etc.) and comprehensive parallelism optimizations, including Context Parallelism, Tensor Parallelism, hybrid 2D or 3D parallelism, and dedicated extra parallelism support for Text Encoder, VAE, and ControlNet.
Cache-DiT is compatible with compilation, offload, and quantization, fully integrates with SGLang Diffusion, vLLM-Omni, TensorRT-LLM, xDiT, and runs natively on NVIDIA GPUs, Huawei Ascend NPUs and AMD GPUs. Cache-DiT is fast, easy to use, and flexible for various DiTs (online docs at 📘cache-dit.io).
⚡️9x speedup by Cache-DiT with Cache, Context Parallelism and Compilation
🚀Quick Start: Cache, Parallelism and Quantization
pip install -U cache-dit # PyPI, stable release.
pip install git+https://github.com/vipshop/cache-dit.git # latest.
>>> import cache_dit
>>> from diffusers import DiffusionPipeline
>>> pipe = DiffusionPipeline.from_pretrained(...).to("cuda")
>>> cache_dit.enable_cache(pipe) # Cache Acceleration with One-line code.
>>> from cache_dit import DBCacheConfig, ParallelismConfig
>>> cache_dit.enable_cache( # Or, Hybrid Cache Acceleration + Parallelism.
... pipe, cache_config=DBCacheConfig(), # w/ default
... parallelism_config=ParallelismConfig(ulysses_size=2))
>>> from cache_dit import DBCacheConfig, ParallelismConfig, QuantizeConfig
>>> cache_dit.enable_cache( # Or, Hybrid Cache + Parallelism + Quantization.
... pipe, cache_config=DBCacheConfig(), # w/ default
... parallelism_config=ParallelismConfig(ulysses_size=2),
... quantize_config=QuantizeConfig(quant_type=...))
>>> output = pipe(...) # Then, just call the pipe as normal.
🚀Quick Start: SVDQuant (W4A4) PTQ/DQ workflow
# Required: CUDA >=13.0, PyTorch >=2.11 (a CUDA 13 build), GLIBC 2.38.
pip install -U cache-dit --extra-index-url https://vipshop.github.io/cache-dit/whl/cu13/
# Latest, from source: one flag builds every CUDA extension (SVDQuant, comm, attn).
git submodule update --init --recursive --force # the SVDQuant sources need spdlog
CACHE_DIT_BUILD_CUDA=1 pip install -e ".[quantization]" # default, all archs.
>>> from cache_dit import QuantizeConfig
>>> pipe = DiffusionPipeline.from_pretrained(...).to("cuda")
>>> # ✅ PTQ: "...{dtype}_r{rank}", required `calibrate_fn`.
>>> def calibrate_fn(**_: object) -> None:
... for prompt in calibration_prompts: _ = pipe(...)
>>> pipe.transformer = cache_dit.quantize(
... pipe.transformer, quant_config=QuantizeConfig(
... quant_type="svdq_nvfp4_r32", calibrate_fn=calibrate_fn,
... serialize_to="path"))
>>> pipe.transformer = cache_dit.load(pipe.transformer, "path")
>>> # ✅ DQ: "...{dtype}_r{rank}_dq", NO calibration need.
>>> pipe.transformer = cache_dit.quantize(
... pipe.transformer, quant_config=QuantizeConfig(
... quant_type="svdq_{int4|nvfp4}_r{32|64|128|256|...}_dq",
... svdq_kwargs={"smooth_strategy": "few_shot"}))
>>> output = pipe(...) # Then, just call the pipe as normal.
🚀Quick Start: Bucket-style Layerwise CPU Offload
>>> import cache_dit
>>> cache_dit.layerwise_offload(
... pipe, # nn.Module: pipe, transformer, text_encoder, etc.
... onload_device="cuda",
... offload_device="cpu",
... async_transfer=True,
... transfer_buckets=4,
... persistent_buckets=64,
... persistent_bins=8,
... prefetch_limit=True,
... max_copy_streams=4,
... max_inflight_prefetch_bytes="8gib")
>>> output = pipe(...) # Then, just call the pipe as normal.
🚪Supported DiT Models
Cache-DiT supports 60+ DiT pipeline families (150+ Variants) from 🤗Diffusers, covering the vast majority of DiT-based pipelines. For full support matrix and detailed usage, please refer to our documentation at 📘cache-dit.io.
| Modality | Pipeline Series | Model Sources | Variants | C/P/Q/OF |
|---|---|---|---|---|
| Video | SANA-Video 2B (T2V/I2V) 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Video | SANA-WM (I2V) 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | FLUX.3 Klein 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Wan-Animate-2 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | Bria-Fibo 2.0 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Video | Kandinsky 6.0 (T2VA) 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✖️ |
| Audio | Stable Audio 3 (T2A) 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Audio | LongCat-AudioDiT (TTS) 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | Qwen-Image-2.1 🔥 | 🤗[email protected], 🤗HF |
3 | ✔️/✔️/✔️/✔️ |
| Video | LTX2.5 (DFR/T2V/I2V) 🔥 | 🤗[email protected], 🤗HF |
6 | ✔️/✔️/✔️/✔️ |
| Video | Echo (JoyAI-Echo) 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | MiniMax-H3 (T2VA) 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | MiniMax-H3 (FL2VA) 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | MiniMax-H3 (Ref2VA) 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Joy-Image | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Krea-2 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Ideogram 4 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Anima | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Any-Flow | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Any-Flow-FAR | 🤗[email protected], 🤗HF |
1 | ✖️/✖️/✔️/✔️ |
| Video | Cosmos3 (Omni) 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✖️/✔️/✔️ |
| Video | Motif-Video (T2V/I2V) 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | ERNIE-Image 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | NucleusMoE-Image 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | FLUX.2 Klein 🔥 | 🤗[email protected], 🤗HF |
3 | ✔️/✔️/✔️/✔️ |
| Image | GLM-Image 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | LongCat-Image 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Video | LTX2 | 🤗[email protected], 🤗HF |
6 | ✔️/✔️/✔️/✔️ |
| Video | Helios 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | FLUX.2 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Z-Image 🔥 | 🤗[email protected], 🤗HF |
6 | ✔️/✔️/✔️/✔️ |
| Image | Bria-Fibo | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | Ovis-Image | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Hunyuan-Image 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | Bria | 🤗[email protected], 🤗HF |
1 | ✔️/✖️/✔️/✔️ |
| Image | PRX / PRXPixel 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | FireRed-Image-Edit | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Video | HunyuanVideo 1.5 🔥 | 🤗[email protected], 🤗HF |
2 | ✔️/✖️/✔️/✔️ |
| Video | ChronoEdit | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Kandinsky5 (T2V/I2V) | 🤗[email protected], 🤗HF |
4 | ✔️/✔️/✔️/✔️ |
| Other | LucyEdit | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Qwen-Image 🔥 | 🤗[email protected], 🤗HF |
9+ | ✔️/✔️/✔️/✔️ |
| Video | Wan 2.2 (T2V/I2V) 🔥 | 🤗[email protected], 🤗HF |
3 | ✔️/✔️/✔️/✔️ |
| Video | SkyReelsV2 | 🤗[email protected], 🤗HF |
5 | ✔️/✔️/✔️/✔️ |
| Image | HiDream | 🤗[email protected], 🤗HF |
1 | ✔️/✖️/✔️/✔️ |
| Image | Chroma | 🤗[email protected], 🤗HF |
3 | ✔️/✔️/✔️/✔️ |
| Image | VisualCloze | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Video | Cosmos | 🤗[email protected], 🤗HF |
7+ | ✔️/✖️/✔️/✔️ |
| Video | Wan-VACE 🔥 | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | CogView4 | 🤗[email protected], 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | OmniGen | 🤗[email protected], 🤗HF |
1 | ✔️/✖️/✔️/✔️ |
| Image | Lumina 2 | 🤗[email protected], 🤗HF |
2 | ✔️/✖️/✔️/✔️ |
| Video | Wan 2.1 (T2V/I2V) 🔥 | 🤗[email protected], 🤗HF |
3 | ✔️/✔️/✔️/✔️ |
| Video | EasyAnimate | 🤗[email protected], 🤗HF |
3 | ✔️/✖️/✔️/✔️ |
| Video | ConsisID | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Sana (image) | 🤗[email protected], 🤗HF |
4 | ✔️/✖️/✔️/✔️ |
| Video | HunyuanVideo | 🤗[email protected], 🤗HF |
4 | ✔️/✔️/✔️/✔️ |
| Video | Mochi | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Allegro | 🤗[email protected], 🤗HF |
1 | ✔️/✖️/✔️/✔️ |
| Video | LTX | 🤗[email protected], 🤗HF |
5 | ✔️/✔️/✔️/✔️ |
| Image | CogView3Plus | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | FLUX | 🤗[email protected], 🤗HF |
10+ | ✔️/✔️/✔️/✔️ |
| Image | HunyuanDiT-PAG | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | AuraFlow | 🤗[email protected], 🤗HF |
1 | ✔️/✖️/✔️/✔️ |
| Image | Lumina | 🤗[email protected], 🤗HF |
2 | ✔️/✖️/✔️/✔️ |
| Video | CogVideoX | 🤗[email protected], 🤗HF |
4 | ✔️/✔️/✔️/✔️ |
| Audio | StableAudio | 🤗[email protected], 🤗HF |
1 | ✔️/✖️/✔️/✔️ |
| Image | SD3 | 🤗[email protected], 🤗HF |
3 | ✔️/✖️/✔️/✔️ |
| Image | HunyuanDiT | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | PixArt-Sigma | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Image | Amused | 🤗[email protected], 🤗HF |
1 | ✔️/✖️/✔️/✔️ |
| Image | PixArt-Alpha | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Other | Shap-E | 🤗[email protected], 🤗HF |
1 | ✔️/✖️/✔️/✔️ |
| Image | DiT | 🤗[email protected], 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
C: Hybrid Cache (DBCache + Calibrator: TaylorSeer/DMD/FoCa/SCM); P: Parallelism (Ulysses/Ring/USP
TP/TE-P/VAE-P/2D-P/3D-P); Q: Quantization; OF: Bucket-style Layerwise Offload; @: Minimum version.
🚀Built-in Pipelines Beyond 🤗Diffusers
| Modality | Pipeline Series | Model Sources | Variants | C/P/Q/OF |
|---|---|---|---|---|
| Video | Pika H3 Flex (T2VA) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Pika H3 Flex (FL2VA) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Pika H3 Flex (REF2VA) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | SANA-Video 2.0 (T2V/TI2V) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | LingBot-Video Dense 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | MAGI-2 Preview (T2VA/I2VA) 🔥 | 🎯cache-dit@main, 🤗HF |
2 | ✖️/✔️/✖️/✔️ |
| Image | MOSS-Image 🔥 | 🎯cache-dit@main, 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | Ming-Image 0.1 🔥 | 🎯cache-dit@main, 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Image | HiDream-O1-Image 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Fast-H3 (fastvideo@main) 🔥 |
🎯cache-dit@main, 🤗HF |
2 | ✔️/✔️/✔️/✔️ |
| Video | CausVid-Wan 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✖️/✔️/✔️/✔️ |
| Video | LongLive 2.0 (5B) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | LongCat-Video (A2V/AI2V) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | Wan2.2-S2V (S2V) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | MOVA 360p (T2VA/I2VA) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
| Video | HY-Nomas (T2V) 🔥 | 🎯cache-dit@main, 🤗HF |
1 | ✔️/✔️/✔️/✔️ |
Cache-DiT also provides built-in pipelines for models that are not currently included in 🤗Diffusers.
🤖Agentic Workflows
Cache-DiT provides a model-integration SKILL to help users integrate new DiT pipelines into Cache-DiT, including Cache, CP, TP, TE-P, VAE-P and carefully designed test cases. Users can use it with Coding Agents, e.g, GitHub Copilot, Claude Code, Open Code.
gh skill install vipshop/cache-dit cache-dit-model-integration --allow-hidden-dirs
Model integration: The SKILL guides the Coding Agent through: search and download the model weights (e.g. from 🤗Hugging Face or ModelScope), match the model against the corresponding 🤗Diffusers pipeline and transformer code, and then implement support for it following the SKILL's instructions.
/cache-dit-model-integration "Please download and support MiniMax-H3 in Cache-DiT."
Performance: It can also run the performance matrix for models that Cache-DiT already supports. For examples:
/cache-dit-model-integration "Run the perf matrix for MiniMax-H3 with 1/2/4/8 GPUs."
🌐Community Integration
- 🎉MindIE-SD x Cache-DiT
- 🎉xDiT x Cache-DiT
- 🎉ComfyUI x Cache-DiT
- 🎉Diffusers x Cache-DiT
- 🎉TensorRT-LLM x Cache-DiT
- 🎉SGLang Omni x Cache-DiT
- 🎉SGLang Diffusion x Cache-DiT
- 🎉vLLM-Omni x Cache-DiT
- 🎉Nunchaku x Cache-DiT
- 🎉SD.Next x Cache-DiT
- 🎉stable-diffusion.cpp x Cache-DiT
- 🎉jetson-containers x Cache-DiT
- 🎉RH-MinMax-H3 x Cache-DiT
©️Acknowledgements
Special thanks to vipshop's Computer Vision AI Team for supporting testing and deployment of this project. We learned and reused codes from: Diffusers, SGLang, vLLM-Omni, Nunchaku, xDiT and TaylorSeer.
©️Citations
@misc{cache-dit@2025,
title={Cache-DiT: A PyTorch-native Inference Engine with Cache, Parallelism, Quantization and CPU Offload for DiTs.},
url={https://github.com/vipshop/cache-dit.git},
note={Open-source software available at https://github.com/vipshop/cache-dit.git},
author={DefTruth, vipshop.com, etc.},
year={2025}
}
探索相关项目
加载中…
⚡️🎉A PyTorch-native Inference Engine with Cache,