cache-dit 0.3.3__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cache-dit might be problematic. Click here for more details.

cache_dit/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.3.3'
32
- __version_tuple__ = version_tuple = (0, 3, 3)
31
+ __version__ = version = '1.0.1'
32
+ __version_tuple__ = version_tuple = (1, 0, 1)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -334,6 +334,13 @@ class CachedAdapter:
334
334
 
335
335
  if getattr(transformer, "_hf_hook", None) is not None:
336
336
  _hf_hook = transformer._hf_hook # hooks from accelerate.hooks
337
+ if hasattr(transformer, "_old_forward"):
338
+ logger.warning(
339
+ "_hf_hook is not None, so, we have to re-direct transformer's "
340
+ f"original_forward({id(original_forward)}) to transformer's "
341
+ f"_old_forward({id(transformer._old_forward)})"
342
+ )
343
+ original_forward = transformer._old_forward
337
344
 
338
345
  # TODO: remove group offload hooks the re-apply after cache applied.
339
346
  # hooks = _diffusers_hook.hooks.copy(); _diffusers_hook.hooks.clear()
@@ -362,9 +362,7 @@ def __patch_transformer_forward__(
362
362
  )
363
363
  if hidden_states_masks is not None:
364
364
  # NOTE: Patched
365
- cur_llama31_encoder_hidden_states = llama31_encoder_hidden_states[
366
- self.double_stream_blocks[-1].block._block_id
367
- ]
365
+ cur_llama31_encoder_hidden_states = llama31_encoder_hidden_states[0]
368
366
  encoder_attention_mask_ones = torch.ones(
369
367
  (
370
368
  batch_size,
@@ -646,6 +646,7 @@ def entrypoint():
646
646
  not os.path.exists(img_test),
647
647
  )
648
648
  ):
649
+ logger.error(f"Not exist: {img_true} or {img_test}, skip.")
649
650
  return
650
651
  # img_true and img_test can be files or dirs
651
652
  img_true_info = os.path.basename(img_true)
@@ -684,6 +685,7 @@ def entrypoint():
684
685
  not os.path.exists(img_test), # dir
685
686
  )
686
687
  ):
688
+ logger.error(f"Not exist: {prompt_true} or {img_test}, skip.")
687
689
  return
688
690
 
689
691
  # img_true and img_test can be files or dirs
@@ -714,6 +716,7 @@ def entrypoint():
714
716
  not os.path.exists(video_test),
715
717
  )
716
718
  ):
719
+ logger.error(f"Not exist: {video_true} or {video_test}, skip.")
717
720
  return
718
721
 
719
722
  # video_true and video_test can be files or dirs
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.4
2
+ Name: cache_dit
3
+ Version: 1.0.1
4
+ Summary: A Unified, Flexible and Training-free Cache Acceleration Framework for 🤗Diffusers.
5
+ Author: DefTruth, vipshop.com, etc.
6
+ Maintainer: DefTruth, vipshop.com, etc
7
+ Project-URL: Repository, https://github.com/vipshop/cache-dit.git
8
+ Project-URL: Homepage, https://github.com/vipshop/cache-dit.git
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: packaging
13
+ Requires-Dist: pyyaml
14
+ Requires-Dist: torch>=2.7.1
15
+ Requires-Dist: transformers>=4.55.2
16
+ Requires-Dist: diffusers>=0.35.1
17
+ Requires-Dist: scikit-image
18
+ Requires-Dist: scipy
19
+ Requires-Dist: lpips==0.1.4
20
+ Requires-Dist: torchao>=0.12.0
21
+ Requires-Dist: image-reward
22
+ Provides-Extra: all
23
+ Provides-Extra: metrics
24
+ Requires-Dist: image-reward; extra == "metrics"
25
+ Requires-Dist: pytorch-fid; extra == "metrics"
26
+ Requires-Dist: lpips==0.1.4; extra == "metrics"
27
+ Provides-Extra: dev
28
+ Requires-Dist: pre-commit; extra == "dev"
29
+ Requires-Dist: pytest<8.0.0,>=7.0.0; extra == "dev"
30
+ Requires-Dist: pytest-html; extra == "dev"
31
+ Requires-Dist: expecttest; extra == "dev"
32
+ Requires-Dist: hypothesis; extra == "dev"
33
+ Requires-Dist: transformers; extra == "dev"
34
+ Requires-Dist: diffusers; extra == "dev"
35
+ Requires-Dist: accelerate; extra == "dev"
36
+ Requires-Dist: peft; extra == "dev"
37
+ Requires-Dist: protobuf; extra == "dev"
38
+ Requires-Dist: sentencepiece; extra == "dev"
39
+ Requires-Dist: opencv-python-headless; extra == "dev"
40
+ Requires-Dist: ftfy; extra == "dev"
41
+ Requires-Dist: scikit-image; extra == "dev"
42
+ Requires-Dist: pytorch-fid; extra == "dev"
43
+ Dynamic: license-file
44
+ Dynamic: provides-extra
45
+ Dynamic: requires-dist
46
+ Dynamic: requires-python
47
+
48
+ <a href="./README.md">📚English</a> | <a href="./README_CN.md">📚中文阅读 </a>
49
+
50
+ <div align="center">
51
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cache-dit-logo.png height="120">
52
+ <p align="center">
53
+ A <b>Unified</b>, Flexible and Training-free <b>Cache Acceleration</b> Framework for <b>🤗Diffusers</b> <br>
54
+ ♥️ Cache Acceleration with <b>One-line</b> Code ~ ♥️
55
+ </p>
56
+ <div align='center'>
57
+ <img src=https://img.shields.io/badge/Language-Python-brightgreen.svg >
58
+ <img src=https://img.shields.io/badge/PRs-welcome-blue.svg >
59
+ <img src=https://img.shields.io/badge/PyPI-pass-brightgreen.svg >
60
+ <img src=https://static.pepy.tech/badge/cache-dit >
61
+ <img src=https://img.shields.io/github/stars/vipshop/cache-dit.svg?style=dark >
62
+ <img src=https://img.shields.io/badge/Release-v1.0-brightgreen.svg >
63
+ </div>
64
+ <p align="center">
65
+ 🎉Now, <b>cache-dit</b> covers almost <b>All</b> Diffusers' <b>DiT</b> Pipelines🎉<br>
66
+ 🔥<a href="./examples/">Qwen-Image</a> | <a href="./examples/">FLUX.1</a> | <a href="./examples/">Qwen-Image-Lightning</a> | <a href="./examples/"> Wan 2.1 </a> | <a href="./examples/"> Wan 2.2 </a>🔥<br>
67
+ 🔥<a href="./examples/">HunyuanImage-2.1</a> | <a href="./examples/">HunyuanVideo</a> | <a href="./examples/">HunyuanDiT</a> | <a href="./examples/">HiDream</a> | <a href="./examples/">AuraFlow</a>🔥<br>
68
+ 🔥<a href="./examples/">CogView3Plus</a> | <a href="./examples/">CogView4</a> | <a href="./examples/">LTXVideo</a> | <a href="./examples/">CogVideoX</a> | <a href="./examples/">CogVideoX 1.5</a> | <a href="./examples/">ConsisID</a>🔥<br>
69
+ 🔥<a href="./examples/">Cosmos</a> | <a href="./examples/">SkyReelsV2</a> | <a href="./examples/">VisualCloze</a> | <a href="./examples/">OmniGen 1/2</a> | <a href="./examples/">Lumina 1/2</a> | <a href="./examples/">PixArt</a>🔥<br>
70
+ 🔥<a href="./examples/">Chroma</a> | <a href="./examples/">Sana</a> | <a href="./examples/">Allegro</a> | <a href="./examples/">Mochi</a> | <a href="./examples/">SD 3/3.5</a> | <a href="./examples/">Amused</a> | <a href="./examples/"> ... </a> | <a href="./examples/">DiT-XL</a>🔥
71
+ <br>♥️ Please consider to leave a <b>⭐️ Star</b> to support us ~ ♥️
72
+ </p>
73
+ </div>
74
+
75
+ ## 🔥Hightlight <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit"><img src=https://img.shields.io/badge/🤗Diffusers-ecosystem-yellow.svg ></a>
76
+
77
+ <div align='center'>
78
+ <details>
79
+ <summary> 🔥<b>Click</b> here to show <b>Important News</b>: First API-stable (v1.0.0) Release🔥 </summary>
80
+
81
+ 2025.09.25: 🎉The **first API-stable version (v1.0.0)** of cache-dit has finally been released!<br>
82
+ 2025.09.25: 🔥**cache-dit** has joined the Diffusers community ecosystem: <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit"><img src=https://img.shields.io/badge/🤗Diffusers-ecosystem-yellow.svg ></a><br>
83
+ 2025.09.10: 🎉Day 1 support [**HunyuanImage-2.1**](https://github.com/Tencent-Hunyuan/HunyuanImage-2.1) with **1.7x↑🎉** speedup! Check this [example](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_hunyuan_image_2.1.py).<br>
84
+ 2025.09.08: 🔥[**Qwen-Image-Lightning**](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image_lightning.py) **7.1/3.5 steps🎉** inference with **[DBCache: F16B16](https://github.com/vipshop/cache-dit)**.<br>
85
+ 2025.09.03: 🎉[**Wan2.2-MoE**](https://github.com/Wan-Video) **2.4x↑🎉** speedup! Please refer to [run_wan_2.2.py](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_wan_2.2.py) as an example.<br>
86
+ 2025.08.12: 🎉First caching mechanism in [QwenLM/Qwen-Image](https://github.com/QwenLM/Qwen-Image) with **[cache-dit](https://github.com/vipshop/cache-dit)**, check this [PR](https://github.com/QwenLM/Qwen-Image/pull/61).<br>
87
+ 2025.08.11: 🔥[**Qwen-Image**](https://github.com/QwenLM/Qwen-Image) **1.8x↑🎉** speedup! Please refer to [run_qwen_image.py](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image.py) as an example.<br>
88
+ 2025.09.08: 🎉First caching mechanism in [Wan2.2](https://github.com/Wan-Video/Wan2.2) with **[cache-dit](https://github.com/vipshop/cache-dit)**, check this [PR](https://github.com/Wan-Video/Wan2.2/pull/127) for more details.<br>
89
+ 2025.09.08: 🎉First caching mechanism in [Qwen-Image-Lightning](https://github.com/ModelTC/Qwen-Image-Lightning) with **[cache-dit](https://github.com/vipshop/cache-dit)**, check this [PR](https://github.com/ModelTC/Qwen-Image-Lightning/pull/35).<br>
90
+ 2025.08.19: 🔥[**Qwen-Image-Edit**](https://github.com/QwenLM/Qwen-Image) **2x↑🎉** speedup! Check the example: [run_qwen_image_edit.py](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image_edit.py).<br>
91
+ 2025.09.01: 📚[**Hybird Forward Pattern**](#unified) is supported! Please check [FLUX.1-dev](https://github.com/vipshop/cache-dit/blob/main/examples/run_flux_adapter.py) as an example.<br>
92
+ 2025.08.10: 🔥[**FLUX.1-Kontext-dev**](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev) is supported! Please refer [run_flux_kontext.py](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_flux_kontext.py) as an example.<br>
93
+ 2025.07.18: 🎉First caching mechanism in [🤗huggingface/flux-fast](https://github.com/huggingface/flux-fast) with **[cache-dit](https://github.com/vipshop/cache-dit)**, check the [PR](https://github.com/huggingface/flux-fast/pull/13).<br>
94
+ 2025.07.13: 🎉[**FLUX.1-dev**](https://github.com/xlite-dev/flux-faster) **3.3x↑🎉** speedup! NVIDIA L20 with **[cache-dit](https://github.com/vipshop/cache-dit)** + **compile + FP8 DQ**.<br>
95
+
96
+ </details>
97
+ </div>
98
+
99
+ We are excited to announce that the **first API-stable version (v1.0.0)** of cache-dit has finally been released!
100
+ **[cache-dit](https://github.com/vipshop/cache-dit)** is a **Unified**, **Flexible**, and **Training-free** cache acceleration framework for 🤗 Diffusers, enabling cache acceleration with just **one line** of code. Key features include **Unified Cache APIs**, **Forward Pattern Matching**, **Automatic Block Adapter**, **Hybrid Forward Pattern**, **DBCache**, **TaylorSeer Calibrator**, and **Cache CFG**.
101
+
102
+ ```bash
103
+ pip3 install -U cache-dit # pip3 install git+https://github.com/vipshop/cache-dit.git
104
+ ```
105
+ You can install the stable release of cache-dit from PyPI, or the latest development version from GitHub. Then try ♥️ Cache Acceleration with just **one line** of code ~ ♥️
106
+ ```python
107
+ >>> import cache_dit
108
+ >>> from diffusers import DiffusionPipeline
109
+ >>> pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image") # Can be any diffusion pipeline
110
+ >>> cache_dit.enable_cache(pipe) # One-line code with default cache options.
111
+ >>> output = pipe(...) # Just call the pipe as normal.
112
+ >>> stats = cache_dit.summary(pipe) # Then, get the summary of cache acceleration stats.
113
+ >>> cache_dit.disable_cache(pipe) # Disable cache and run original pipe.
114
+ ```
115
+
116
+ ### 📚Core Features
117
+
118
+ - **[🎉Full 🤗Diffusers Support](./docs/User_Guide.md#supported-pipelines)**: Notably, **[cache-dit](https://github.com/vipshop/cache-dit)** now supports nearly **all** of Diffusers' **DiT-based** pipelines, such as Qwen-Image, FLUX.1, Qwen-Image-Lightning, HunyuanImage-2.1, HunyuanVideo, HunyuanDiT, Wan 2.1/2.2, HiDream, AuraFlow, CogView3Plus, CogView4, LTXVideo, CogVideoX 1.5, ConsisID, SkyReelsV2, VisualCloze, OmniGen, Lumina, PixArt, Chroma, Sana, Allegro, Mochi, SD 3.5, Amused, and DiT-XL.
119
+ - **[🎉Extremely Easy to Use](./docs/User_Guide.md#unified-cache-apis)**: In most cases, you only need **one line** of code: `cache_dit.enable_cache(...)`. After calling this API, just use the pipeline as normal.
120
+ - **[🎉Easy New Model Integration](./docs/User_Guide.md#automatic-block-adapter)**: Features like **Unified Cache APIs**, **Forward Pattern Matching**, **Automatic Block Adapter**, **Hybrid Forward Pattern**, and **Patch Functor** make it highly functional and flexible. For example, we achieved 🎉 Day 1 support for [HunyuanImage-2.1](https://github.com/Tencent-Hunyuan/HunyuanImage-2.1) with 1.7x speedup w/o precision loss—even before it was available in the Diffusers library.
121
+ - **[🎉State-of-the-Art Performance](./bench/)**: Compared with algorithms including Δ-DiT, Chipmunk, FORA, DuCa, TaylorSeer and FoCa, cache-dit achieves the best accuracy when the speedup ratio is below 4x.
122
+ - **[🎉Support for 4/8-Steps Distilled Models](./bench/)**: Surprisingly, cache-dit's **DBCache** works for extremely few-step distilled models—something many other methods fail to do.
123
+ - **[🎉Compatibility with Other Optimizations](./docs/User_Guide.md#️torch-compile)**: Designed to work seamlessly with torch.compile, model CPU offload, sequential CPU offload, group offloading, etc.
124
+ - **[🎉Hybrid Cache Acceleration](./docs/User_Guide.md#taylorseer-calibrator)**: Now supports hybrid **DBCache + Calibrator** schemes (e.g., DBCache + TaylorSeerCalibrator). DBCache acts as the **Indicator** to decide *when* to cache, while the Calibrator decides *how* to cache. More mainstream cache acceleration algorithms (e.g., FoCa) will be supported in the future, along with additional benchmarks—stay tuned for updates!
125
+ - **[🤗Diffusers Ecosystem Integration](https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit)**: 🔥**cache-dit** has joined the Diffusers community ecosystem as the **first** DiT-specific cache acceleration framework! Check out the documentation here: <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit"><img src=https://img.shields.io/badge/🤗Diffusers-ecosystem-yellow.svg ></a>
126
+
127
+ ![image-reward-bench](https://github.com/vipshop/cache-dit/raw/main/assets/image-reward-bench.png)
128
+
129
+ <details align='center'>
130
+ <summary>🔥<b>Click</b> here to show many <b>Image/Video</b> cases🔥</summary>
131
+
132
+ <div align='center'>
133
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/wan2.2.C0_Q0_NONE.gif width=124px>
134
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/wan2.2.C1_Q0_DBCACHE_F1B0_W2M8MC2_T1O2_R0.08.gif width=124px>
135
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/hunyuan_video.C0_L0_Q0_NONE.gif width=126px>
136
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/hunyuan_video.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.12_S27.gif width=126px>
137
+ <p><b>🔥Wan2.2 MoE</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.0x↑🎉 | <b>HunyuanVideo</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.1x↑🎉</p>
138
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image.C0_Q0_NONE.png width=160px>
139
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image.C1_Q0_DBCACHE_F8B0_W8M0MC0_T1O4_R0.12_S23.png width=160px>
140
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux.C0_Q0_NONE_T23.69s.png width=90px>
141
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux.C0_Q0_DBCACHE_F1B0_W4M0MC0_T1O2_R0.15_S16_T11.39s.png width=90px>
142
+ <p><b>🔥Qwen-Image</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.8x↑🎉 | <b>FLUX.1-dev</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.1x↑🎉</p>
143
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-lightning.4steps.C0_L1_Q0_NONE.png width=160px>
144
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-lightning.4steps.C0_L1_Q0_DBCACHE_F16B16_W2M1MC1_T0O2_R0.9_S1.png width=160px>
145
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hunyuan-image-2.1.C0_L0_Q1_fp8_w8a16_wo_NONE.png width=90px>
146
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hunyuan-image-2.1.C0_L0_Q1_fp8_w8a16_wo_DBCACHE_F8B0_W8M0MC2_T1O2_R0.12_S25.png width=90px>
147
+ <p><b>🔥Qwen...Lightning</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.14x↑🎉 | <b>HunyuanImage</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.7x↑🎉</p>
148
+ <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/bear.png width=125px>
149
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-edit.C0_L0_Q0_NONE.png width=125px>
150
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-edit.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S18.png width=125px>
151
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-edit.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.12_S24.png width=125px>
152
+ <p><b>🔥Qwen-Image-Edit</b> | Input w/o Edit | Baseline | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.6x↑🎉 | 1.9x↑🎉 </p>
153
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext-cat.C0_L0_Q0_NONE.png width=100px>
154
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_NONE.png width=100px>
155
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S10.png width=100px>
156
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.12_S12.png width=100px>
157
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_DBCACHE_F1B0_W2M0MC2_T0O2_R0.15_S15.png width=100px>
158
+ <p><b>🔥FLUX-Kontext-dev</b> | Baseline | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.3x↑🎉 | 1.7x↑🎉 | 2.0x↑ 🎉</p>
159
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hidream.C0_L0_Q0_NONE.png width=100px>
160
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hidream.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.08_S24.png width=100px>
161
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview4.C0_L0_Q0_NONE.png width=100px>
162
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview4.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S15.png width=100px>
163
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview4.C0_L0_Q0_DBCACHE_F1B0_W4M0MC4_T0O2_R0.2_S22.png width=100px>
164
+ <p><b>🔥HiDream-I1</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.9x↑🎉 | <b>CogView4</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.4x↑🎉 | 1.7x↑🎉</p>
165
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview3_plus.C0_L0_Q0_NONE.png width=100px>
166
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview3_plus.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S15.png width=100px>
167
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview3_plus.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.08_S25.png width=100px>
168
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/chroma1-hd.C0_L0_Q0_NONE.png width=100px>
169
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/chroma1-hd.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.08_S20.png width=100px>
170
+ <p><b>🔥CogView3</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.5x↑🎉 | 2.0x↑🎉| <b>Chroma1-HD</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.9x↑🎉</p>
171
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/mochi.C0_L0_Q0_NONE.gif width=125px>
172
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/mochi.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S34.gif width=125px>
173
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/skyreels_v2.C0_L0_Q0_NONE.gif width=125px>
174
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/skyreels_v2.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.12_S17.gif width=125px>
175
+ <p><b>🔥Mochi-1-preview</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.8x↑🎉 | <b>SkyReelsV2</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.6x↑🎉</p>
176
+ <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/visualcloze/00555_00.jpg width=100px>
177
+ <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/visualcloze/12265_00.jpg width=100px>
178
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/visualcloze-512.C0_L0_Q0_NONE.png width=100px>
179
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/visualcloze-512.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S15.png width=100px>
180
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/visualcloze-512.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.08_S18.png width=100px>
181
+ <p><b>🔥VisualCloze-512</b> | Model | Cloth | Baseline | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.4x↑🎉 | 1.7x↑🎉 </p>
182
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/ltx-video.C0_L0_Q0_NONE.gif width=144px>
183
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/ltx-video.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.15_S13.gif width=144px>
184
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/cogvideox1.5.C0_L0_Q0_NONE.gif width=105px>
185
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/cogvideox1.5.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.12_S22.gif width=105px>
186
+ <p><b>🔥LTX-Video-0.9.7</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.7x↑🎉 | <b>CogVideoX1.5</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.0x↑🎉</p>
187
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/omingen-v1.C0_L0_Q0_NONE.png width=100px>
188
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/omingen-v1.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S24.png width=100px>
189
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/omingen-v1.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T1O2_R0.08_S38.png width=100px>
190
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/lumina2.C0_L0_Q0_NONE.png width=100px>
191
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/lumina2.C0_L0_Q0_DBCACHE_F1B0_W2M0MC2_T0O2_R0.12_S14.png width=100px>
192
+ <p><b>🔥OmniGen-v1</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.5x↑🎉 | 3.3x↑🎉 | <b>Lumina2</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.9x↑🎉</p>
193
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/allegro.C0_L0_Q0_NONE.gif width=117px>
194
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/allegro.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.26_S27.gif width=117px>
195
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/auraflow.C0_L0_Q0_NONE.png width=133px>
196
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/auraflow.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.08_S28.png width=133px>
197
+ <p><b>🔥Allegro</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.36x↑🎉 | <b>AuraFlow-v0.3</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.27x↑🎉 </p>
198
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sana.C0_L0_Q0_NONE.png width=100px>
199
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sana.C0_L0_Q0_DBCACHE_F8B0_W8M0MC2_T0O2_R0.25_S6.png width=100px>
200
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sana.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.3_S8.png width=100px>
201
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-sigma.C0_L0_Q0_NONE.png width=100px>
202
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-sigma.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S28.png width=100px>
203
+ <p><b>🔥Sana</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.3x↑🎉 | 1.6x↑🎉| <b>PixArt-Sigma</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.3x↑🎉</p>
204
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-alpha.C0_L0_Q0_NONE.png width=100px>
205
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-alpha.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.05_S27.png width=100px>
206
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-alpha.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S32.png width=100px>
207
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sd_3_5.C0_L0_Q0_NONE.png width=100px>
208
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sd_3_5.C0_L0_Q0_DBCACHE_F1B0_W8M0MC3_T0O2_R0.12_S30.png width=100px>
209
+ <p><b>🔥PixArt-Alpha</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.6x↑🎉 | 1.8x↑🎉| <b>SD 3.5</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.5x↑🎉</p>
210
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/amused.C0_L0_Q0_NONE.png width=100px>
211
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/amused.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.34_S1.png width=100px>
212
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/amused.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.38_S2.png width=100px>
213
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/dit-xl.C0_L0_Q0_NONE.png width=100px>
214
+ <img src=https://github.com/vipshop/cache-dit/raw/main/assets/dit-xl.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.15_S11.png width=100px>
215
+ <p><b>🔥Asumed</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.1x↑🎉 | 1.2x↑🎉 | <b>DiT-XL-256</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.8x↑🎉
216
+ <br>♥️ Please consider to leave a <b>⭐️ Star</b> to support us ~ ♥️</p>
217
+ </div>
218
+
219
+ </details>
220
+
221
+ ## 📚User Guide
222
+
223
+ <div id="user-guide"></div>
224
+
225
+ For more advanced features such as **Unified Cache APIs**, **Forward Pattern Matching**, **Automatic Block Adapter**, **Hybrid Forward Pattern**, **Patch Functor**, **DBCache**, **TaylorSeer Calibrator**, and **Hybrid Cache CFG**, please refer to the [🎉User_Guide.md](./docs/User_Guide.md) for details.
226
+
227
+ - [⚙️Installation](./docs/User_Guide.md#️installation)
228
+ - [🔥Benchmarks](./docs/User_Guide.md#benchmarks)
229
+ - [🔥Supported Pipelines](./docs/User_Guide.md#supported-pipelines)
230
+ - [🎉Unified Cache APIs](./docs/User_Guide.md#unified-cache-apis)
231
+ - [📚Forward Pattern Matching](./docs/User_Guide.md#forward-pattern-matching)
232
+ - [📚Cache with One-line Code](./docs/User_Guide.md#%EF%B8%8Fcache-acceleration-with-one-line-code)
233
+ - [🔥Automatic Block Adapter](./docs/User_Guide.md#automatic-block-adapter)
234
+ - [📚Hybird Forward Pattern](./docs/User_Guide.md#hybird-forward-pattern)
235
+ - [📚Implement Patch Functor](./docs/User_Guide.md#implement-patch-functor)
236
+ - [🤖Cache Acceleration Stats](./docs/User_Guide.md#cache-acceleration-stats-summary)
237
+ - [⚡️Dual Block Cache](./docs/User_Guide.md#️dbcache-dual-block-cache)
238
+ - [🔥TaylorSeer Calibrator](./docs/User_Guide.md#taylorseer-calibrator)
239
+ - [⚡️Hybrid Cache CFG](./docs/User_Guide.md#️hybrid-cache-cfg)
240
+ - [🛠Metrics CLI](./docs/User_Guide.md#metrics-cli)
241
+ - [⚙️Torch Compile](./docs/User_Guide.md#️torch-compile)
242
+ - [📚API Documents](./docs/User_Guide.md#api-documentation)
243
+
244
+ ## 👋Contribute
245
+ <div id="contribute"></div>
246
+
247
+ How to contribute? Star ⭐️ this repo to support us or check [CONTRIBUTE.md](https://github.com/vipshop/cache-dit/raw/main/CONTRIBUTE.md).
248
+
249
+ <div align='center'>
250
+ <a href="https://star-history.com/#vipshop/cache-dit&Date">
251
+ <picture align='center'>
252
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date&theme=dark" />
253
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date" />
254
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date" width=400px />
255
+ </picture>
256
+ </a>
257
+ </div>
258
+
259
+ ## ©️Acknowledgements
260
+
261
+ <div id="Acknowledgements"></div>
262
+
263
+ The **cache-dit** codebase is adapted from FBCache. Over time its codebase diverged a lot, and **cache-dit** API is no longer compatible with FBCache.
264
+
265
+ ## ©️Special Acknowledgements
266
+
267
+ Special thanks to vipshop's Computer Vision AI Team for supporting document, testing and production-level deployment of this project.
268
+
269
+ ## ©️Citations
270
+
271
+ <div id="citations"></div>
272
+
273
+ ```BibTeX
274
+ @misc{cache-dit@2025,
275
+ title={cache-dit: A Unified, Flexible and Training-free Cache Acceleration Framework for Diffusers.},
276
+ url={https://github.com/vipshop/cache-dit.git},
277
+ note={Open-source software available at https://github.com/vipshop/cache-dit.git},
278
+ author={vipshop.com},
279
+ year={2025}
280
+ }
281
+ ```
@@ -1,5 +1,5 @@
1
1
  cache_dit/__init__.py,sha256=sHRg0swXZZiw6lvSQ53fcVtN9JRayx0az2lXAz5OOGI,1510
2
- cache_dit/_version.py,sha256=lemL_4Kl75FgrO6lVuFrrtw6-Dcf9wtXBalKkXuzkO4,704
2
+ cache_dit/_version.py,sha256=JvmBpae6cHui8lSCsCcZQAxzawN2NERHGsr-rIUeJMo,704
3
3
  cache_dit/logger.py,sha256=0zsu42hN-3-rgGC_C29ms1IvVpV4_b4_SwJCKSenxBE,4304
4
4
  cache_dit/utils.py,sha256=AyYRwi5XBxYBH4GaXxOxv9-X24Te_IYOYwh54t_1d3A,10674
5
5
  cache_dit/cache_factory/.gitignore,sha256=5Cb-qT9wsTUoMJ7vACDF7ZcLpAXhi5v-xdcWSRit988,23
@@ -13,7 +13,7 @@ cache_dit/cache_factory/block_adapters/__init__.py,sha256=33geXMz56TxFWMp0c-H4__
13
13
  cache_dit/cache_factory/block_adapters/block_adapters.py,sha256=2TVK_KqiYXC7AKZ2s07fzdOzUoeUBc9P1SzQtLVzhf4,22249
14
14
  cache_dit/cache_factory/block_adapters/block_registers.py,sha256=2L7QeM4ygnaKQpC9PoJod0QRYyxidUKU2AYpysDCUwE,2572
15
15
  cache_dit/cache_factory/cache_adapters/__init__.py,sha256=py71WGD3JztQ1uk6qdLVbzYcQ1rvqFidNNaQYo7tqTo,79
16
- cache_dit/cache_factory/cache_adapters/cache_adapter.py,sha256=PuNFO0t9510MhOOJy93cz0uiG8PeWKsjgUWshNj76LQ,20906
16
+ cache_dit/cache_factory/cache_adapters/cache_adapter.py,sha256=7heGoy8LHMP54ISMwfJ-i_ALngkbnUdeQDBRrE-MTgs,21303
17
17
  cache_dit/cache_factory/cache_blocks/__init__.py,sha256=mivvm8YOfqT7YHs8y_MzGOGztPw8LxAqKGXuSRXxCv0,3032
18
18
  cache_dit/cache_factory/cache_blocks/offload_utils.py,sha256=wusgcqaCrwEjvv7Guy-6VXhNOgPPUrBV2sSVuRmGuvo,3513
19
19
  cache_dit/cache_factory/cache_blocks/pattern_0_1_2.py,sha256=ElMps6_7uI74tSF9GDR_dEI0bZEhdzcepM29xFWnYo8,428
@@ -32,7 +32,7 @@ cache_dit/cache_factory/patch_functors/functor_base.py,sha256=Ahk0fTfrHgNdEl-9JS
32
32
  cache_dit/cache_factory/patch_functors/functor_chroma.py,sha256=xD0Q96VArp1vYBLQ0pcjRIyFB1i_Y7muZ2q07Hz8Oqs,13430
33
33
  cache_dit/cache_factory/patch_functors/functor_dit.py,sha256=SDjhzCWa6PoFNN4_upoQEf6DHvW1yJ7zuXMS2VvyJco,3904
34
34
  cache_dit/cache_factory/patch_functors/functor_flux.py,sha256=UMkyuEYjO7UO_zmXi9Djd-nD-XMgCUgE-qkYA3plWSM,9559
35
- cache_dit/cache_factory/patch_functors/functor_hidream.py,sha256=pi_vvpDy1lsgQHxu3eK3v93rdJL7oNwkt3WakRP8pbw,15375
35
+ cache_dit/cache_factory/patch_functors/functor_hidream.py,sha256=inf4T5UcIa06zVsoLWCNJbb1bEDmGeBGSyC7OL1zpuc,15309
36
36
  cache_dit/cache_factory/patch_functors/functor_hunyuan_dit.py,sha256=iSo5dD5uKnjQQeysDUIkKt0wdnK5bzXTc_F_lfHG70w,6401
37
37
  cache_dit/compile/__init__.py,sha256=FcTVzCeyypl-mxlc59_ehHL3lBNiDAFsXuRoJ-5Cfi0,56
38
38
  cache_dit/compile/utils.py,sha256=nN2OIrSdwRR5zGxJinKDqb07pXpvTNTF3g_OgLkeeBU,3858
@@ -45,13 +45,13 @@ cache_dit/metrics/fid.py,sha256=ZM_FM0XERtpnkMUfphmw2aOdljrh1uba-pnYItu0q6M,1821
45
45
  cache_dit/metrics/image_reward.py,sha256=N8HalJo1T1js0dsNb2V1KRv4kIdcm3nhx7iOXJuqcns,5421
46
46
  cache_dit/metrics/inception.py,sha256=pBVe2X6ylLPIXTG4-GWDM9DWnCviMJbJ45R3ulhktR0,12759
47
47
  cache_dit/metrics/lpips.py,sha256=hrHrmdM-f2B4TKDs0xLqJO5JFaYcCjq2qNIR8oCrVkc,811
48
- cache_dit/metrics/metrics.py,sha256=7UV-H2NRbhfr6dvrXEzU97Zy-BSQ5zEfm9CKtaK4ldg,40231
48
+ cache_dit/metrics/metrics.py,sha256=AZbQyoavE-djvyRUZ_EfCIrWSQbiWQFo7n2dhn7XptE,40466
49
49
  cache_dit/quantize/__init__.py,sha256=kWYoMAyZgBXu9BJlZjTQ0dRffW9GqeeY9_iTkXrb70A,59
50
50
  cache_dit/quantize/quantize_ao.py,sha256=Fx1KW4l3gdEkdrcAYtPoDW7WKBJWrs3glOHiEwW_TgE,6160
51
51
  cache_dit/quantize/quantize_interface.py,sha256=2s_R7xPSKuJeFpEGeLwRxnq_CqJcBG3a3lzyW5wh-UM,1241
52
- cache_dit-0.3.3.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
53
- cache_dit-0.3.3.dist-info/METADATA,sha256=2kUqLHOXsbb25iz6uO8Y3pzOVMSaRHs-st6o3imjX_o,34752
54
- cache_dit-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
- cache_dit-0.3.3.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
56
- cache_dit-0.3.3.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
57
- cache_dit-0.3.3.dist-info/RECORD,,
52
+ cache_dit-1.0.1.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
53
+ cache_dit-1.0.1.dist-info/METADATA,sha256=Oygjg65VRvdeNciptBlFK7Eh3vURd1Hxcq35UEYN5Tg,26173
54
+ cache_dit-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
+ cache_dit-1.0.1.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
56
+ cache_dit-1.0.1.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
57
+ cache_dit-1.0.1.dist-info/RECORD,,
@@ -1,505 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cache_dit
3
- Version: 0.3.3
4
- Summary: A Unified, Flexible and Training-free Cache Acceleration Framework for 🤗Diffusers.
5
- Author: DefTruth, vipshop.com, etc.
6
- Maintainer: DefTruth, vipshop.com, etc
7
- Project-URL: Repository, https://github.com/vipshop/cache-dit.git
8
- Project-URL: Homepage, https://github.com/vipshop/cache-dit.git
9
- Requires-Python: >=3.10
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: packaging
13
- Requires-Dist: pyyaml
14
- Requires-Dist: torch>=2.7.1
15
- Requires-Dist: transformers>=4.55.2
16
- Requires-Dist: diffusers>=0.35.1
17
- Requires-Dist: scikit-image
18
- Requires-Dist: scipy
19
- Requires-Dist: lpips==0.1.4
20
- Requires-Dist: torchao>=0.12.0
21
- Requires-Dist: image-reward
22
- Provides-Extra: all
23
- Provides-Extra: metrics
24
- Requires-Dist: image-reward; extra == "metrics"
25
- Requires-Dist: pytorch-fid; extra == "metrics"
26
- Requires-Dist: lpips==0.1.4; extra == "metrics"
27
- Provides-Extra: dev
28
- Requires-Dist: pre-commit; extra == "dev"
29
- Requires-Dist: pytest<8.0.0,>=7.0.0; extra == "dev"
30
- Requires-Dist: pytest-html; extra == "dev"
31
- Requires-Dist: expecttest; extra == "dev"
32
- Requires-Dist: hypothesis; extra == "dev"
33
- Requires-Dist: transformers; extra == "dev"
34
- Requires-Dist: diffusers; extra == "dev"
35
- Requires-Dist: accelerate; extra == "dev"
36
- Requires-Dist: peft; extra == "dev"
37
- Requires-Dist: protobuf; extra == "dev"
38
- Requires-Dist: sentencepiece; extra == "dev"
39
- Requires-Dist: opencv-python-headless; extra == "dev"
40
- Requires-Dist: ftfy; extra == "dev"
41
- Requires-Dist: scikit-image; extra == "dev"
42
- Requires-Dist: pytorch-fid; extra == "dev"
43
- Dynamic: license-file
44
- Dynamic: provides-extra
45
- Dynamic: requires-dist
46
- Dynamic: requires-python
47
-
48
- <a href="./README.md">📚English</a> | <a href="./README_CN.md">📚中文阅读</a>
49
-
50
- <div align="center">
51
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cache-dit-logo.png height="120">
52
-
53
- <p align="center">
54
- A <b>Unified</b>, Flexible and Training-free <b>Cache Acceleration</b> Framework for <b>🤗Diffusers</b> <br>
55
- ♥️ Cache Acceleration with <b>One-line</b> Code ~ ♥️
56
- </p>
57
- <div align='center'>
58
- <img src=https://img.shields.io/badge/Language-Python-brightgreen.svg >
59
- <img src=https://img.shields.io/badge/PRs-welcome-9cf.svg >
60
- <img src=https://img.shields.io/badge/PyPI-pass-brightgreen.svg >
61
- <img src=https://static.pepy.tech/badge/cache-dit >
62
- <img src=https://img.shields.io/github/stars/vipshop/cache-dit.svg?style=dark >
63
- <img src=https://img.shields.io/badge/Python-3.10|3.11|3.12-9cf.svg >
64
- </div>
65
- <p align="center">
66
- <b><a href="#unified">📚Unified Cache APIs</a></b> | <a href="#forward-pattern-matching">📚Forward Pattern Matching</a> | <a href="./docs/User_Guide.md">📚Automatic Block Adapter</a><br>
67
- <a href="./docs/User_Guide.md">📚Hybrid Forward Pattern</a> | <a href="#dbcache">📚DBCache</a> | <a href="./docs/User_Guide.md">📚TaylorSeer Calibrator</a> | <a href="./docs/User_Guide.md">📚Cache CFG</a><br>
68
- <a href="#benchmarks">📚Text2Image DrawBench</a> | <a href="#benchmarks">📚Text2Image Distillation DrawBench</a>
69
- </p>
70
- <p align="center">
71
- 🎉Now, <b>cache-dit</b> covers almost <b>All</b> Diffusers' <b>DiT</b> Pipelines🎉<br>
72
- 🔥<a href="#supported">Qwen-Image</a> | <a href="#supported">FLUX.1</a> | <a href="#supported">Qwen-Image-Lightning</a> | <a href="#supported"> Wan 2.1 </a> | <a href="#supported"> Wan 2.2 </a>🔥<br>
73
- 🔥<a href="#supported">HunyuanImage-2.1</a> | <a href="#supported">HunyuanVideo</a> | <a href="#supported">HunyuanDiT</a> | <a href="#supported">HiDream</a> | <a href="#supported">AuraFlow</a>🔥<br>
74
- 🔥<a href="#supported">CogView3Plus</a> | <a href="#supported">CogView4</a> | <a href="#supported">LTXVideo</a> | <a href="#supported">CogVideoX</a> | <a href="#supported">CogVideoX 1.5</a> | <a href="#supported">ConsisID</a>🔥<br>
75
- 🔥<a href="#supported">Cosmos</a> | <a href="#supported">SkyReelsV2</a> | <a href="#supported">VisualCloze</a> | <a href="#supported">OmniGen 1/2</a> | <a href="#supported">Lumina 1/2</a> | <a href="#supported">PixArt</a>🔥<br>
76
- 🔥<a href="#supported">Chroma</a> | <a href="#supported">Sana</a> | <a href="#supported">Allegro</a> | <a href="#supported">Mochi</a> | <a href="#supported">SD 3/3.5</a> | <a href="#supported">Amused</a> | <a href="#supported"> ... </a> | <a href="#supported">DiT-XL</a>🔥
77
- </p>
78
- </div>
79
-
80
-
81
- <div align='center'>
82
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/wan2.2.C0_Q0_NONE.gif width=124px>
83
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/wan2.2.C1_Q0_DBCACHE_F1B0_W2M8MC2_T1O2_R0.08.gif width=124px>
84
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/hunyuan_video.C0_L0_Q0_NONE.gif width=126px>
85
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/hunyuan_video.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.12_S27.gif width=126px>
86
- <p><b>🔥Wan2.2 MoE</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.0x↑🎉 | <b>HunyuanVideo</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.1x↑🎉</p>
87
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image.C0_Q0_NONE.png width=160px>
88
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image.C1_Q0_DBCACHE_F8B0_W8M0MC0_T1O4_R0.12_S23.png width=160px>
89
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux.C0_Q0_NONE_T23.69s.png width=90px>
90
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux.C0_Q0_DBCACHE_F1B0_W4M0MC0_T1O2_R0.15_S16_T11.39s.png width=90px>
91
- <p><b>🔥Qwen-Image</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.8x↑🎉 | <b>FLUX.1-dev</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.1x↑🎉</p>
92
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-lightning.4steps.C0_L1_Q0_NONE.png width=160px>
93
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-lightning.4steps.C0_L1_Q0_DBCACHE_F16B16_W2M1MC1_T0O2_R0.9_S1.png width=160px>
94
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hunyuan-image-2.1.C0_L0_Q1_fp8_w8a16_wo_NONE.png width=90px>
95
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hunyuan-image-2.1.C0_L0_Q1_fp8_w8a16_wo_DBCACHE_F8B0_W8M0MC2_T1O2_R0.12_S25.png width=90px>
96
- <p><b>🔥Qwen...Lightning</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.14x↑🎉 | <b>HunyuanImage</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.7x↑🎉</p>
97
- <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/bear.png width=125px>
98
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-edit.C0_L0_Q0_NONE.png width=125px>
99
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-edit.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S18.png width=125px>
100
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-edit.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.12_S24.png width=125px>
101
- <p><b>🔥Qwen-Image-Edit</b> | Input w/o Edit | Baseline | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.6x↑🎉 | 1.9x↑🎉
102
- <br>♥️ Please consider to leave a <b>⭐️ Star</b> to support us ~ ♥️
103
- </p>
104
- </div>
105
-
106
- <details align='center'>
107
-
108
- <summary>Click here to show more Image/Video cases</summary>
109
-
110
- <div align='center'>
111
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext-cat.C0_L0_Q0_NONE.png width=100px>
112
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_NONE.png width=100px>
113
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S10.png width=100px>
114
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.12_S12.png width=100px>
115
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_DBCACHE_F1B0_W2M0MC2_T0O2_R0.15_S15.png width=100px>
116
- <p><b>🔥FLUX-Kontext-dev</b> | Baseline | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.3x↑🎉 | 1.7x↑🎉 | 2.0x↑ 🎉</p>
117
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hidream.C0_L0_Q0_NONE.png width=100px>
118
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hidream.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.08_S24.png width=100px>
119
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview4.C0_L0_Q0_NONE.png width=100px>
120
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview4.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S15.png width=100px>
121
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview4.C0_L0_Q0_DBCACHE_F1B0_W4M0MC4_T0O2_R0.2_S22.png width=100px>
122
- <p><b>🔥HiDream-I1</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.9x↑🎉 | <b>CogView4</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.4x↑🎉 | 1.7x↑🎉</p>
123
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview3_plus.C0_L0_Q0_NONE.png width=100px>
124
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview3_plus.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S15.png width=100px>
125
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview3_plus.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.08_S25.png width=100px>
126
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/chroma1-hd.C0_L0_Q0_NONE.png width=100px>
127
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/chroma1-hd.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.08_S20.png width=100px>
128
- <p><b>🔥CogView3</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.5x↑🎉 | 2.0x↑🎉| <b>Chroma1-HD</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.9x↑🎉</p>
129
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/mochi.C0_L0_Q0_NONE.gif width=125px>
130
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/mochi.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S34.gif width=125px>
131
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/skyreels_v2.C0_L0_Q0_NONE.gif width=125px>
132
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/skyreels_v2.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.12_S17.gif width=125px>
133
- <p><b>🔥Mochi-1-preview</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.8x↑🎉 | <b>SkyReelsV2</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.6x↑🎉</p>
134
- <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/visualcloze/00555_00.jpg width=100px>
135
- <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/visualcloze/12265_00.jpg width=100px>
136
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/visualcloze-512.C0_L0_Q0_NONE.png width=100px>
137
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/visualcloze-512.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S15.png width=100px>
138
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/visualcloze-512.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.08_S18.png width=100px>
139
- <p><b>🔥VisualCloze-512</b> | Model | Cloth | Baseline | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.4x↑🎉 | 1.7x↑🎉 </p>
140
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/ltx-video.C0_L0_Q0_NONE.gif width=144px>
141
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/ltx-video.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.15_S13.gif width=144px>
142
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/cogvideox1.5.C0_L0_Q0_NONE.gif width=105px>
143
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/cogvideox1.5.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T0O2_R0.12_S22.gif width=105px>
144
- <p><b>🔥LTX-Video-0.9.7</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.7x↑🎉 | <b>CogVideoX1.5</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.0x↑🎉</p>
145
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/omingen-v1.C0_L0_Q0_NONE.png width=100px>
146
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/omingen-v1.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S24.png width=100px>
147
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/omingen-v1.C0_L0_Q0_DBCACHE_F1B0_W8M0MC0_T1O2_R0.08_S38.png width=100px>
148
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/lumina2.C0_L0_Q0_NONE.png width=100px>
149
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/lumina2.C0_L0_Q0_DBCACHE_F1B0_W2M0MC2_T0O2_R0.12_S14.png width=100px>
150
- <p><b>🔥OmniGen-v1</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.5x↑🎉 | 3.3x↑🎉 | <b>Lumina2</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.9x↑🎉</p>
151
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/allegro.C0_L0_Q0_NONE.gif width=117px>
152
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/allegro.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.26_S27.gif width=117px>
153
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/auraflow.C0_L0_Q0_NONE.png width=133px>
154
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/auraflow.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.08_S28.png width=133px>
155
- <p><b>🔥Allegro</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.36x↑🎉 | <b>AuraFlow-v0.3</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.27x↑🎉 </p>
156
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sana.C0_L0_Q0_NONE.png width=100px>
157
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sana.C0_L0_Q0_DBCACHE_F8B0_W8M0MC2_T0O2_R0.25_S6.png width=100px>
158
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sana.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.3_S8.png width=100px>
159
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-sigma.C0_L0_Q0_NONE.png width=100px>
160
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-sigma.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S28.png width=100px>
161
- <p><b>🔥Sana</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.3x↑🎉 | 1.6x↑🎉| <b>PixArt-Sigma</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.3x↑🎉</p>
162
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-alpha.C0_L0_Q0_NONE.png width=100px>
163
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-alpha.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.05_S27.png width=100px>
164
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-alpha.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.08_S32.png width=100px>
165
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sd_3_5.C0_L0_Q0_NONE.png width=100px>
166
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sd_3_5.C0_L0_Q0_DBCACHE_F1B0_W8M0MC3_T0O2_R0.12_S30.png width=100px>
167
- <p><b>🔥PixArt-Alpha</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.6x↑🎉 | 1.8x↑🎉| <b>SD 3.5</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:2.5x↑🎉</p>
168
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/amused.C0_L0_Q0_NONE.png width=100px>
169
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/amused.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.34_S1.png width=100px>
170
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/amused.C0_L0_Q0_DBCACHE_F8B0_W8M0MC0_T0O2_R0.38_S2.png width=100px>
171
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/dit-xl.C0_L0_Q0_NONE.png width=100px>
172
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/dit-xl.C0_L0_Q0_DBCACHE_F1B0_W8M0MC2_T0O2_R0.15_S11.png width=100px>
173
- <p><b>🔥Asumed</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.1x↑🎉 | 1.2x↑🎉 | <b>DiT-XL-256</b> | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.8x↑🎉
174
- <br>♥️ Please consider to leave a <b>⭐️ Star</b> to support us ~ ♥️</p>
175
- </div>
176
- </details>
177
-
178
- ## 🔥News
179
-
180
- - [2025-09-10] 🎉Day 1 support [**HunyuanImage-2.1**](https://github.com/Tencent-Hunyuan/HunyuanImage-2.1) with **1.7x↑🎉** speedup! Check this [example](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_hunyuan_image_2.1.py).
181
- - [2025-09-08] 🔥[**Qwen-Image-Lightning**](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image_lightning.py) **7.1/3.5 steps🎉** inference with **[DBCache: F16B16](https://github.com/vipshop/cache-dit)**.
182
- - [2025-09-03] 🎉[**Wan2.2-MoE**](https://github.com/Wan-Video) **2.4x↑🎉** speedup! Please refer to [run_wan_2.2.py](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_wan_2.2.py) as an example.
183
- - [2025-08-19] 🔥[**Qwen-Image-Edit**](https://github.com/QwenLM/Qwen-Image) **2x↑🎉** speedup! Check the example: [run_qwen_image_edit.py](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image_edit.py).
184
- - [2025-08-11] 🔥[**Qwen-Image**](https://github.com/QwenLM/Qwen-Image) **1.8x↑🎉** speedup! Please refer to [run_qwen_image.py](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image.py) as an example.
185
-
186
- <details>
187
- <summary> Previous News </summary>
188
-
189
- - [2025-07-13] 🎉[**FLUX.1-dev**](https://github.com/xlite-dev/flux-faster) **3.3x↑🎉** speedup! NVIDIA L20 with **[cache-dit](https://github.com/vipshop/cache-dit)** + **compile + FP8 DQ**.
190
- - [2025-09-08] 🎉First caching mechanism in [Qwen-Image-Lightning](https://github.com/ModelTC/Qwen-Image-Lightning) with **[cache-dit](https://github.com/vipshop/cache-dit)**, check this [PR](https://github.com/ModelTC/Qwen-Image-Lightning/pull/35).
191
- - [2025-09-08] 🎉First caching mechanism in [Wan2.2](https://github.com/Wan-Video/Wan2.2) with **[cache-dit](https://github.com/vipshop/cache-dit)**, check this [PR](https://github.com/Wan-Video/Wan2.2/pull/127) for more details.
192
- - [2025-08-12] 🎉First caching mechanism in [QwenLM/Qwen-Image](https://github.com/QwenLM/Qwen-Image) with **[cache-dit](https://github.com/vipshop/cache-dit)**, check this [PR](https://github.com/QwenLM/Qwen-Image/pull/61).
193
- - [2025-09-01] 📚[**Hybird Forward Pattern**](#unified) is supported! Please check [FLUX.1-dev](https://github.com/vipshop/cache-dit/blob/main/examples/run_flux_adapter.py) as an example.
194
- - [2025-08-10] 🔥[**FLUX.1-Kontext-dev**](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev) is supported! Please refer [run_flux_kontext.py](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_flux_kontext.py) as an example.
195
- - [2025-07-18] 🎉First caching mechanism in [🤗huggingface/flux-fast](https://github.com/huggingface/flux-fast) with **[cache-dit](https://github.com/vipshop/cache-dit)**, check the [PR](https://github.com/huggingface/flux-fast/pull/13).
196
-
197
- </details>
198
-
199
- ## 📖Contents
200
-
201
- <div id="contents"></div>
202
-
203
- - [⚙️Installation](#️installation)
204
- - [🔥Quick Start](#quick-start)
205
- - [📚Pattern Matching](#forward-pattern-matching)
206
- - [⚡️Dual Block Cache](#dbcache)
207
- - [🔥TaylorSeer Calibrator](#taylorseer)
208
- - [📚Hybrid Cache CFG](#cfg)
209
- - [🔥Benchmarks](#benchmarks)
210
- - [🎉User Guide](#user-guide)
211
- - [©️Citations](#citations)
212
-
213
- ## ⚙️Installation
214
-
215
- <div id="installation"></div>
216
-
217
- You can install the stable release of `cache-dit` from PyPI:
218
-
219
- ```bash
220
- pip3 install -U cache-dit
221
- ```
222
- Or you can install the latest develop version from GitHub:
223
-
224
- ```bash
225
- pip3 install git+https://github.com/vipshop/cache-dit.git
226
- ```
227
-
228
- ## 🔥Quick Start
229
-
230
- <div id="unified"></div>
231
-
232
- <div id="quick-start"></div>
233
-
234
- In most cases, you only need to call ♥️**one-line**♥️ of code, that is `cache_dit.enable_cache(...)`. After this API is called, you just need to call the pipe as normal. The `pipe` param can be **any** Diffusion Pipeline. Please refer to [Qwen-Image](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image.py) as an example.
235
-
236
- ```python
237
- >>> import cache_dit
238
- >>> from diffusers import DiffusionPipeline
239
- >>> pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image") # Can be any diffusion pipeline
240
- >>> cache_dit.enable_cache(pipe) # One-line code with default cache options.
241
- >>> output = pipe(...) # Just call the pipe as normal.
242
- >>> stats = cache_dit.summary(pipe) # Then, get the summary of cache acceleration stats.
243
- >>> cache_dit.disable_cache(pipe) # Disable cache and run original pipe.
244
- ```
245
-
246
- ## 📚Forward Pattern Matching
247
-
248
- <div id="supported"></div>
249
-
250
- <div id="forward-pattern-matching"></div>
251
-
252
- cache-dit works by matching specific input/output patterns as shown below.
253
-
254
- ![](https://github.com/vipshop/cache-dit/raw/main/assets/patterns-v1.png)
255
-
256
- Please check [🎉Examples](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline) for more details. Here are just some of the tested models listed.
257
-
258
- ```python
259
- >>> import cache_dit
260
- >>> cache_dit.supported_pipelines()
261
- (30, ['Flux*', 'Mochi*', 'CogVideoX*', 'Wan*', 'HunyuanVideo*', 'QwenImage*', 'LTX*', 'Allegro*',
262
- 'CogView3Plus*', 'CogView4*', 'Cosmos*', 'EasyAnimate*', 'SkyReelsV2*', 'StableDiffusion3*',
263
- 'ConsisID*', 'DiT*', 'Amused*', 'Bria*', 'Lumina*', 'OmniGen*', 'PixArt*', 'Sana*', 'StableAudio*',
264
- 'VisualCloze*', 'AuraFlow*', 'Chroma*', 'ShapE*', 'HiDream*', 'HunyuanDiT*', 'HunyuanDiTPAG*'])
265
- ```
266
-
267
- <details>
268
- <summary> Show all pipelines </summary>
269
-
270
- - [🚀HunyuanImage-2.1](https://github.com/vipshop/cache-dit/blob/main/examples)
271
- - [🚀Qwen-Image-Lightning](https://github.com/vipshop/cache-dit/blob/main/examples)
272
- - [🚀Qwen-Image-Edit](https://github.com/vipshop/cache-dit/blob/main/examples)
273
- - [🚀Qwen-Image](https://github.com/vipshop/cache-dit/blob/main/examples)
274
- - [🚀FLUX.1-dev](https://github.com/vipshop/cache-dit/blob/main/examples)
275
- - [🚀FLUX.1-Fill-dev](https://github.com/vipshop/cache-dit/blob/main/examples)
276
- - [🚀FLUX.1-Kontext-dev](https://github.com/vipshop/cache-dit/blob/main/examples)
277
- - [🚀CogView4](https://github.com/vipshop/cache-dit/blob/main/examples)
278
- - [🚀Wan2.2-T2V](https://github.com/vipshop/cache-dit/blob/main/examples)
279
- - [🚀HunyuanVideo](https://github.com/vipshop/cache-dit/blob/main/examples)
280
- - [🚀HiDream-I1-Full](https://github.com/vipshop/cache-dit/blob/main/examples)
281
- - [🚀HunyuanDiT](https://github.com/vipshop/cache-dit/blob/main/examples)
282
- - [🚀Wan2.1-T2V](https://github.com/vipshop/cache-dit/blob/main/examples)
283
- - [🚀Wan2.1-FLF2V](https://github.com/vipshop/cache-dit/blob/main/examples)
284
- - [🚀SkyReelsV2](https://github.com/vipshop/cache-dit/blob/main/examples)
285
- - [🚀Chroma1-HD](https://github.com/vipshop/cache-dit/blob/main/examples)
286
- - [🚀CogVideoX1.5](https://github.com/vipshop/cache-dit/blob/main/examples)
287
- - [🚀CogView3-Plus](https://github.com/vipshop/cache-dit/blob/main/examples)
288
- - [🚀CogVideoX](https://github.com/vipshop/cache-dit/blob/main/examples)
289
- - [🚀VisualCloze](https://github.com/vipshop/cache-dit/blob/main/examples)
290
- - [🚀LTXVideo](https://github.com/vipshop/cache-dit/blob/main/examples)
291
- - [🚀OmniGen](https://github.com/vipshop/cache-dit/blob/main/examples)
292
- - [🚀Lumina2](https://github.com/vipshop/cache-dit/blob/main/examples)
293
- - [🚀mochi-1-preview](https://github.com/vipshop/cache-dit/blob/main/examples)
294
- - [🚀AuraFlow-v0.3](https://github.com/vipshop/cache-dit/blob/main/examples)
295
- - [🚀PixArt-Alpha](https://github.com/vipshop/cache-dit/blob/main/examples)
296
- - [🚀PixArt-Sigma](https://github.com/vipshop/cache-dit/blob/main/examples)
297
- - [🚀NVIDIA Sana](https://github.com/vipshop/cache-dit/blob/main/examples)
298
- - [🚀SD-3/3.5](https://github.com/vipshop/cache-dit/blob/main/examples)
299
- - [🚀ConsisID](https://github.com/vipshop/cache-dit/blob/main/examples)
300
- - [🚀Allegro](https://github.com/vipshop/cache-dit/blob/main/examples)
301
- - [🚀Amused](https://github.com/vipshop/cache-dit/blob/main/examples)
302
- - [🚀DiT-XL](https://github.com/vipshop/cache-dit/blob/main/examples)
303
- - ...
304
-
305
- </details>
306
-
307
- ## ⚡️DBCache: Dual Block Cache
308
-
309
- <div id="dbcache"></div>
310
-
311
- ![](https://github.com/vipshop/cache-dit/raw/main/assets/dbcache-v1.png)
312
-
313
- **DBCache**: **Dual Block Caching** for Diffusion Transformers. Different configurations of compute blocks (**F8B12**, etc.) can be customized in DBCache, enabling a balanced trade-off between performance and precision. Moreover, it can be entirely **training**-**free**. Please Check the [DBCache](https://github.com/vipshop/cache-dit/blob/main/docs/DBCache.md) and [User Guide](https://github.com/vipshop/cache-dit/blob/main/docs/User_Guide.md#dbcache) docs for more design details.
314
-
315
- ```python
316
- # Default options, F8B0, 8 warmup steps, and unlimited cached
317
- # steps for good balance between performance and precision
318
- cache_dit.enable_cache(pipe_or_adapter)
319
-
320
- # Custom options, F8B8, higher precision
321
- from cache_dit import BasicCacheConfig
322
-
323
- cache_dit.enable_cache(
324
- pipe_or_adapter,
325
- cache_config=BasicCacheConfig(
326
- max_warmup_steps=8, # steps do not cache
327
- max_cached_steps=-1, # -1 means no limit
328
- Fn_compute_blocks=8, # Fn, F8, etc.
329
- Bn_compute_blocks=8, # Bn, B8, etc.
330
- residual_diff_threshold=0.12,
331
- ),
332
- )
333
- ```
334
-
335
- ## 🔥TaylorSeer Calibrator
336
-
337
- <div id="taylorseer"></div>
338
-
339
- The [TaylorSeers](https://huggingface.co/papers/2503.06923) algorithm further improves the precision of DBCache in cases where the cached steps are large (Hybrid TaylorSeer + DBCache). At timesteps with significant intervals, the feature similarity in diffusion models decreases substantially, significantly harming the generation quality.
340
-
341
- TaylorSeer employs a differential method to approximate the higher-order derivatives of features and predict features in future timesteps with Taylor series expansion. The TaylorSeer implemented in CacheDiT supports both hidden states and residual cache types. F_pred can be a residual cache or a hidden-state cache.
342
-
343
- ```python
344
- from cache_dit import BasicCacheConfig, TaylorSeerCalibratorConfig
345
-
346
- cache_dit.enable_cache(
347
- pipe_or_adapter,
348
- # Basic DBCache w/ FnBn configurations
349
- cache_config=BasicCacheConfig(
350
- max_warmup_steps=8, # steps do not cache
351
- max_cached_steps=-1, # -1 means no limit
352
- Fn_compute_blocks=8, # Fn, F8, etc.
353
- Bn_compute_blocks=8, # Bn, B8, etc.
354
- residual_diff_threshold=0.12,
355
- ),
356
- # Then, you can use the TaylorSeer Calibrator to approximate
357
- # the values in cached steps, taylorseer_order default is 1.
358
- calibrator_config=TaylorSeerCalibratorConfig(
359
- taylorseer_order=1,
360
- ),
361
- )
362
- ```
363
-
364
- > [!TIP]
365
- > The `Bn_compute_blocks` parameter of DBCache can be set to `0` if you use TaylorSeer as the calibrator for approximate hidden states. DBCache's `Bn_compute_blocks` also acts as a calibrator, so you can choose either `Bn_compute_blocks` > 0 or TaylorSeer. We recommend using the configuration scheme of TaylorSeer + DBCache FnB0.
366
-
367
- ## 📚Hybrid Cache CFG
368
-
369
- <div id="cfg"></div>
370
-
371
- cache-dit supports caching for CFG (classifier-free guidance). For models that fuse CFG and non-CFG into a single forward step, or models that do not include CFG (classifier-free guidance) in the forward step, please set `enable_separate_cfg` parameter to `False (default, None)`. Otherwise, set it to `True`.
372
-
373
- ```python
374
- from cache_dit import BasicCacheConfig
375
-
376
- cache_dit.enable_cache(
377
- pipe_or_adapter,
378
- cache_config=BasicCacheConfig(
379
- ...,
380
- # For example, set it as True for Wan 2.1/Qwen-Image
381
- # and set it as False for FLUX.1, HunyuanVideo, CogVideoX, etc.
382
- enable_separate_cfg=True,
383
- ),
384
- )
385
- ```
386
-
387
- ## 🔥Benchmarks
388
-
389
- <div id="benchmarks"></div>
390
-
391
- The comparison between **cache-dit: DBCache** and algorithms such as Δ-DiT, Chipmunk, FORA, DuCa, TaylorSeer and FoCa is as follows. Now, in the comparison with a speedup ratio less than **3x**, cache-dit achieved the best accuracy. Surprisingly, cache-dit: DBCache still works in the extremely few-step distill model. For a complete benchmark, please refer to [📚Benchmarks](https://github.com/vipshop/cache-dit/raw/main/bench/).
392
-
393
- | Method | TFLOPs(↓) | SpeedUp(↑) | ImageReward(↑) | Clip Score(↑) |
394
- | --- | --- | --- | --- | --- |
395
- | [**FLUX.1**-dev]: 50 steps | 3726.87 | 1.00× | 0.9898 | 32.404 |
396
- | [**FLUX.1**-dev]: 60% steps | 2231.70 | 1.67× | 0.9663 | 32.312 |
397
- | Δ-DiT(N=2) | 2480.01 | 1.50× | 0.9444 | 32.273 |
398
- | Δ-DiT(N=3) | 1686.76 | 2.21× | 0.8721 | 32.102 |
399
- | [**FLUX.1**-dev]: 34% steps | 1264.63 | 3.13× | 0.9453 | 32.114 |
400
- | Chipmunk | 1505.87 | 2.47× | 0.9936 | 32.776 |
401
- | FORA(N=3) | 1320.07 | 2.82× | 0.9776 | 32.266 |
402
- | **[DBCache(F=4,B=0,W=4,MC=4)](https://github.com/vipshop/cache-dit)** | 1400.08 | **2.66×** | **1.0065** | 32.838 |
403
- | **[DBCache+TaylorSeer(F=1,B=0,O=1)](https://github.com/vipshop/cache-dit)** | 1153.05 | **3.23×** | **1.0221** | 32.819 |
404
- | DuCa(N=5) | 978.76 | 3.80× | 0.9955 | 32.241 |
405
- | TaylorSeer(N=4,O=2) | 1042.27 | 3.57× | 0.9857 | 32.413 |
406
- | **[DBCache(F=1,B=0,W=4,MC=6)](https://github.com/vipshop/cache-dit)** | 944.75 | **3.94×** | 0.9997 | 32.849 |
407
- | **[DBCache+TaylorSeer(F=1,B=0,O=1)](https://github.com/vipshop/cache-dit)** | 944.75 | **3.94×** | **1.0107** | 32.865 |
408
- | **[FoCa(N=5): arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | 893.54 | **4.16×** | **1.0029** | **32.948** |
409
-
410
- <details>
411
- <summary> Show all comparison </summary>
412
-
413
- | Method | TFLOPs(↓) | SpeedUp(↑) | ImageReward(↑) | Clip Score(↑) |
414
- | --- | --- | --- | --- | --- |
415
- | [**FLUX.1**-dev]: 50 steps | 3726.87 | 1.00× | 0.9898 | 32.404 |
416
- | [**FLUX.1**-dev]: 60% steps | 2231.70 | 1.67× | 0.9663 | 32.312 |
417
- | Δ-DiT(N=2) | 2480.01 | 1.50× | 0.9444 | 32.273 |
418
- | Δ-DiT(N=3) | 1686.76 | 2.21× | 0.8721 | 32.102 |
419
- | [**FLUX.1**-dev]: 34% steps | 1264.63 | 3.13× | 0.9453 | 32.114 |
420
- | Chipmunk | 1505.87 | 2.47× | 0.9936 | 32.776 |
421
- | FORA(N=3) | 1320.07 | 2.82× | 0.9776 | 32.266 |
422
- | **[DBCache(F=4,B=0,W=4,MC=4)](https://github.com/vipshop/cache-dit)** | 1400.08 | **2.66×** | **1.0065** | 32.838 |
423
- | DuCa(N=5) | 978.76 | 3.80× | 0.9955 | 32.241 |
424
- | TaylorSeer(N=4,O=2) | 1042.27 | 3.57× | 0.9857 | 32.413 |
425
- | **[DBCache+TaylorSeer(F=1,B=0,O=1)](https://github.com/vipshop/cache-dit)** | 1153.05 | **3.23×** | **1.0221** | 32.819 |
426
- | **[DBCache(F=1,B=0,W=4,MC=6)](https://github.com/vipshop/cache-dit)** | 944.75 | **3.94×** | 0.9997 | 32.849 |
427
- | **[DBCache+TaylorSeer(F=1,B=0,O=1)](https://github.com/vipshop/cache-dit)** | 944.75 | **3.94×** | **1.0107** | 32.865 |
428
- | **[FoCa(N=5): arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | 893.54 | **4.16×** | **1.0029** | **32.948** |
429
- | [**FLUX.1**-dev]: 22% steps | 818.29 | 4.55× | 0.8183 | 31.772 |
430
- | FORA(N=4) | 967.91 | 3.84× | 0.9730 | 32.142 |
431
- | ToCa(N=8) | 784.54 | 4.74× | 0.9451 | 31.993 |
432
- | DuCa(N=7) | 760.14 | 4.89× | 0.9757 | 32.066 |
433
- | TeaCache(l=0.8) | 892.35 | 4.17× | 0.8683 | 31.704 |
434
- | **[DBCache(F=4,B=0,W=4,MC=10)](https://github.com/vipshop/cache-dit)** | 816.65 | 4.56x | 0.8245 | 32.191 |
435
- | TaylorSeer(N=5,O=2) | 893.54 | 4.16× | 0.9768 | 32.467 |
436
- | **[FoCa(N=7): arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | 670.44 | **5.54×** | **0.9891** | **32.920** |
437
- | FORA(N=7) | 670.14 | 5.55× | 0.7418 | 31.519 |
438
- | ToCa(N=12) | 644.70 | 5.77× | 0.7155 | 31.808 |
439
- | DuCa(N=10) | 606.91 | 6.13× | 0.8382 | 31.759 |
440
- | TeaCache(l=1.2) | 669.27 | 5.56× | 0.7394 | 31.704 |
441
- | **[DBCache(F=1,B=0,W=4,MC=10)](https://github.com/vipshop/cache-dit)** | 651.90 | **5.72x** | 0.8796 | **32.318** |
442
- | TaylorSeer(N=7,O=2) | 670.44 | 5.54× | 0.9128 | 32.128 |
443
- | **[FoCa(N=8): arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | 596.07 | **6.24×** | **0.9502** | **32.706** |
444
-
445
- NOTE: Except for DBCache, other performance data are referenced from the paper [FoCa, arxiv.2508.16211](https://arxiv.org/pdf/2508.16211).
446
-
447
- </details>
448
-
449
- ## 🎉User Guide
450
-
451
- <div id="user-guide"></div>
452
-
453
- For more advanced features such as **Unified Cache APIs**, **Forward Pattern Matching**, **Automatic Block Adapter**, **Hybrid Forward Pattern**, **DBCache**, **TaylorSeer Calibrator**, and **Hybrid Cache CFG**, please refer to the [🎉User_Guide.md](./docs/User_Guide.md) for details.
454
-
455
- - [⚙️Installation](./docs/User_Guide.md#️installation)
456
- - [🔥Benchmarks](./docs/User_Guide.md#benchmarks)
457
- - [🔥Supported Pipelines](./docs/User_Guide.md#supported-pipelines)
458
- - [🎉Unified Cache APIs](./docs/User_Guide.md#unified-cache-apis)
459
- - [📚Forward Pattern Matching](./docs/User_Guide.md#forward-pattern-matching)
460
- - [📚Cache with One-line Code](./docs/User_Guide.md#%EF%B8%8Fcache-acceleration-with-one-line-code)
461
- - [🔥Automatic Block Adapter](./docs/User_Guide.md#automatic-block-adapter)
462
- - [📚Hybird Forward Pattern](./docs/User_Guide.md#hybird-forward-pattern)
463
- - [📚Implement Patch Functor](./docs/User_Guide.md#implement-patch-functor)
464
- - [🤖Cache Acceleration Stats](./docs/User_Guide.md#cache-acceleration-stats-summary)
465
- - [⚡️Dual Block Cache](./docs/User_Guide.md#️dbcache-dual-block-cache)
466
- - [🔥TaylorSeer Calibrator](./docs/User_Guide.md#taylorseer-calibrator)
467
- - [⚡️Hybrid Cache CFG](./docs/User_Guide.md#️hybrid-cache-cfg)
468
- - [⚙️Torch Compile](./docs/User_Guide.md#️torch-compile)
469
- - [🛠Metrics CLI](./docs/User_Guide.md#metrics-cli)
470
- - [📚API Documents](./docs/User_Guide.md#api-documentation)
471
-
472
- ## 👋Contribute
473
- <div id="contribute"></div>
474
-
475
- How to contribute? Star ⭐️ this repo to support us or check [CONTRIBUTE.md](https://github.com/vipshop/cache-dit/raw/main/CONTRIBUTE.md).
476
-
477
- <div align='center'>
478
- <a href="https://star-history.com/#vipshop/cache-dit&Date">
479
- <picture align='center'>
480
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date&theme=dark" />
481
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date" />
482
- <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date" width=400px />
483
- </picture>
484
- </a>
485
- </div>
486
-
487
- ## ©️Acknowledgements
488
-
489
- <div id="Acknowledgements"></div>
490
-
491
- The **cache-dit** codebase is adapted from FBCache. Over time its codebase diverged a lot, and **cache-dit** API is no longer compatible with FBCache.
492
-
493
- ## ©️Citations
494
-
495
- <div id="citations"></div>
496
-
497
- ```BibTeX
498
- @misc{cache-dit@2025,
499
- title={cache-dit: A Unified, Flexible and Training-free Cache Acceleration Framework for Diffusers.},
500
- url={https://github.com/vipshop/cache-dit.git},
501
- note={Open-source software available at https://github.com/vipshop/cache-dit.git},
502
- author={vipshop.com},
503
- year={2025}
504
- }
505
- ```