cache-dit 1.0.0__py3-none-any.whl → 1.0.2__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.

@@ -1,39 +1,40 @@
1
1
  cache_dit/__init__.py,sha256=sHRg0swXZZiw6lvSQ53fcVtN9JRayx0az2lXAz5OOGI,1510
2
- cache_dit/_version.py,sha256=vLA4ITz09S-S435nq6yTF6l3qiSz6w4euS1rOxXgd1M,704
2
+ cache_dit/_version.py,sha256=ZTgKq8LPNy3l9uR2ke-VtLhvvl5l71frQ9wO76n1L5k,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
6
6
  cache_dit/cache_factory/__init__.py,sha256=vy9I6Ofkj9jWeUoOvh-cY5a9QlDDKfj2FVPlVTf7BeA,1390
7
- cache_dit/cache_factory/cache_interface.py,sha256=A_8bBsLfGOE5wM3_rniQKPJ223_-fSpNIq65uv00sF0,10620
7
+ cache_dit/cache_factory/cache_interface.py,sha256=KseSPyZ9D3m6pmpE7k-uYr0wfBI-hhscG1Nw54GCHxk,12316
8
8
  cache_dit/cache_factory/cache_types.py,sha256=ooukxQRG55uTLmaZ0SKw6gIeY6SQHhMxkbv55uj2Sqk,991
9
9
  cache_dit/cache_factory/forward_pattern.py,sha256=FumlCuZ-TSmSYH0hGBHctSJ-oGLCftdZjLygqhsmdR4,2258
10
10
  cache_dit/cache_factory/params_modifier.py,sha256=zYJJsInTYCaYHBZ7mZJOP-PZnkSg3iN1WPewNOayXos,3628
11
11
  cache_dit/cache_factory/utils.py,sha256=XkVM9AXcB9zYq8-S8QKAsGz80r3tA6U3lBNGDGeHOe4,1871
12
- cache_dit/cache_factory/block_adapters/__init__.py,sha256=33geXMz56TxFWMp0c-H4__MY5SGRzKMKj3TXnUYOMlc,17512
12
+ cache_dit/cache_factory/block_adapters/__init__.py,sha256=vM3aDMzPY79Tw4L0hlV2PdA3MFYomnf0eo0BGBo9P78,18087
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=7heGoy8LHMP54ISMwfJ-i_ALngkbnUdeQDBRrE-MTgs,21303
16
+ cache_dit/cache_factory/cache_adapters/cache_adapter.py,sha256=HTyZdspd34G6QiJ2qPNoLmGwcxmAnCwpAf91NTIQtl4,21442
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
20
- cache_dit/cache_factory/cache_blocks/pattern_3_4_5.py,sha256=Bv56qETXhsREvCrNvnZpSqDIIHsi6Ze3FJW4Yk2x3uI,8597
21
- cache_dit/cache_factory/cache_blocks/pattern_base.py,sha256=wdh0bbcpKO08AW2FTsj9X_tTbFCLkDmBjrstMxTf7MQ,14668
20
+ cache_dit/cache_factory/cache_blocks/pattern_3_4_5.py,sha256=rfq5-WEt-ErY28vcB4ur9E-uCb6BKP0S8v5lTw61ROk,10555
21
+ cache_dit/cache_factory/cache_blocks/pattern_base.py,sha256=StNW2PyDiXEIxZd30byPUrZZ8jgSiuC_yrly2w7X2LQ,16176
22
22
  cache_dit/cache_factory/cache_blocks/pattern_utils.py,sha256=dGOC1tMMOvcbvEgx44eTESKn_jsv-0RZ3tRHPa3wmQ4,1315
23
- cache_dit/cache_factory/cache_contexts/__init__.py,sha256=T6Vak3x7Rs0Oy15Tou49p-rPQRA2jiuYtJBsbv1lBBU,388
23
+ cache_dit/cache_factory/cache_contexts/__init__.py,sha256=N3SxFnluXk5q09nhSqKIJCVzEGWzySJWm-vic6dH79E,412
24
24
  cache_dit/cache_factory/cache_contexts/cache_context.py,sha256=3EhaMCz3VUQ_NF81VgYwWoSEGIvhScPxPYhjL1OcgxE,15240
25
- cache_dit/cache_factory/cache_contexts/cache_manager.py,sha256=hSKAeP1CxmO3RFUxjFjAK1xdvVvTmeayh5jEHMaQXNE,30225
25
+ cache_dit/cache_factory/cache_contexts/cache_manager.py,sha256=X99XnmiY-Us8D2pqJGPKxWcXAhQQpk3xdEWOOOYXIZ4,30465
26
26
  cache_dit/cache_factory/cache_contexts/calibrators/__init__.py,sha256=mzYXO8tbytGpJJ9rpPu20kMoj1Iu_7Ym9tjfzV8rA98,5574
27
27
  cache_dit/cache_factory/cache_contexts/calibrators/base.py,sha256=mn6ZBkChGpGwN5csrHTUGMoX6BBPvqHXSLbIExiW-EU,748
28
28
  cache_dit/cache_factory/cache_contexts/calibrators/foca.py,sha256=nhHGs_hxwW1M942BQDMJb9-9IuHdnOxp774Jrna1bJI,891
29
29
  cache_dit/cache_factory/cache_contexts/calibrators/taylorseer.py,sha256=aGxr9SpytYznTepDWGPAxWDnuVMSuNyn6uNXnLh2acQ,4001
30
- cache_dit/cache_factory/patch_functors/__init__.py,sha256=oI6F3N9ezahRHaFUOZ1GfrAw1qFdKrxFXXmlwwehHj4,530
30
+ cache_dit/cache_factory/patch_functors/__init__.py,sha256=IJZrvSkeHbR_xW-6IzY7sqEhApBsOfPyorQGJutvWH0,652
31
31
  cache_dit/cache_factory/patch_functors/functor_base.py,sha256=Ahk0fTfrHgNdEl-9JSkACvfyyv9G-Ei5OSz7XBIlX5o,357
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
+ cache_dit/cache_factory/patch_functors/functor_qwen_image_controlnet.py,sha256=D5i1Rrq1FQ49liupLcV2DW04moBqLnW9TICzfnMMzIU,10519
37
38
  cache_dit/compile/__init__.py,sha256=FcTVzCeyypl-mxlc59_ehHL3lBNiDAFsXuRoJ-5Cfi0,56
38
39
  cache_dit/compile/utils.py,sha256=nN2OIrSdwRR5zGxJinKDqb07pXpvTNTF3g_OgLkeeBU,3858
39
40
  cache_dit/custom_ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -45,13 +46,13 @@ cache_dit/metrics/fid.py,sha256=ZM_FM0XERtpnkMUfphmw2aOdljrh1uba-pnYItu0q6M,1821
45
46
  cache_dit/metrics/image_reward.py,sha256=N8HalJo1T1js0dsNb2V1KRv4kIdcm3nhx7iOXJuqcns,5421
46
47
  cache_dit/metrics/inception.py,sha256=pBVe2X6ylLPIXTG4-GWDM9DWnCviMJbJ45R3ulhktR0,12759
47
48
  cache_dit/metrics/lpips.py,sha256=hrHrmdM-f2B4TKDs0xLqJO5JFaYcCjq2qNIR8oCrVkc,811
48
- cache_dit/metrics/metrics.py,sha256=7UV-H2NRbhfr6dvrXEzU97Zy-BSQ5zEfm9CKtaK4ldg,40231
49
+ cache_dit/metrics/metrics.py,sha256=AZbQyoavE-djvyRUZ_EfCIrWSQbiWQFo7n2dhn7XptE,40466
49
50
  cache_dit/quantize/__init__.py,sha256=kWYoMAyZgBXu9BJlZjTQ0dRffW9GqeeY9_iTkXrb70A,59
50
- cache_dit/quantize/quantize_ao.py,sha256=Fx1KW4l3gdEkdrcAYtPoDW7WKBJWrs3glOHiEwW_TgE,6160
51
+ cache_dit/quantize/quantize_ao.py,sha256=Pr3u3Qr6qLvFkd8k-_rfcz4Mkjlg36U9BHG2t6Bl-6M,6301
51
52
  cache_dit/quantize/quantize_interface.py,sha256=2s_R7xPSKuJeFpEGeLwRxnq_CqJcBG3a3lzyW5wh-UM,1241
52
- cache_dit-1.0.0.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
53
- cache_dit-1.0.0.dist-info/METADATA,sha256=HbV42qlhu8PFIO6FD_PuIo1dO-7K-yBiPCc5fikKIsg,35959
54
- cache_dit-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
- cache_dit-1.0.0.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
56
- cache_dit-1.0.0.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
57
- cache_dit-1.0.0.dist-info/RECORD,,
53
+ cache_dit-1.0.2.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
54
+ cache_dit-1.0.2.dist-info/METADATA,sha256=E6MkP_T9cwJEbqWE1DIRVkQLI7wLWr5zryY2poWgkyw,26766
55
+ cache_dit-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
56
+ cache_dit-1.0.2.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
57
+ cache_dit-1.0.2.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
58
+ cache_dit-1.0.2.dist-info/RECORD,,
@@ -1,520 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cache_dit
3
- Version: 1.0.0
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
- <div align="center">
49
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cache-dit-logo.png height="120">
50
-
51
- <p align="center">
52
- A <b>Unified</b>, Flexible and Training-free <b>Cache Acceleration</b> Framework for <b>🤗Diffusers</b> <br>
53
- ♥️ Cache Acceleration with <b>One-line</b> Code ~ ♥️
54
- </p>
55
- <div align='center'>
56
- <img src="./assets/image-reward-bench.png" width=580px >
57
- </div>
58
- <div align='center'>
59
- <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit"><img src=https://img.shields.io/badge/🤗Diffusers-ecosystem-yellow.svg ></a>
60
- <img src=https://img.shields.io/badge/Language-Python-brightgreen.svg >
61
- <img src=https://img.shields.io/badge/PRs-welcome-blue.svg >
62
- <img src=https://img.shields.io/badge/PyPI-pass-brightgreen.svg >
63
- <img src=https://static.pepy.tech/badge/cache-dit >
64
- <img src=https://img.shields.io/github/stars/vipshop/cache-dit.svg?style=dark >
65
- </div>
66
- <div align='center'>
67
- <a href="./README.md">📚English</a> | <a href="./README_CN.md">📚中文阅读 </a> | <a href="./docs/User_Guide.md#api-documentation"> 📚API Documentation </a> | <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit">🤗Diffusers' Documentation</a>
68
- </div>
69
- <!--
70
- <p align="center">
71
- <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>
72
- <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>
73
- <a href="#benchmarks">📚Text2Image DrawBench</a> | <a href="#benchmarks">📚Text2Image Distillation DrawBench</a>
74
- </p>
75
- -->
76
- <p align="center">
77
- 🎉Now, <b>cache-dit</b> covers almost <b>All</b> Diffusers' <b>DiT</b> Pipelines🎉<br>
78
- 🔥<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>
79
- 🔥<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>
80
- 🔥<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>
81
- 🔥<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>
82
- 🔥<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>🔥
83
- </p>
84
- </div>
85
-
86
-
87
- <div align='center'>
88
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/wan2.2.C0_Q0_NONE.gif width=124px>
89
- <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>
90
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/hunyuan_video.C0_L0_Q0_NONE.gif width=126px>
91
- <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>
92
- <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>
93
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image.C0_Q0_NONE.png width=160px>
94
- <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>
95
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux.C0_Q0_NONE_T23.69s.png width=90px>
96
- <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>
97
- <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>
98
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-lightning.4steps.C0_L1_Q0_NONE.png width=160px>
99
- <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>
100
- <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>
101
- <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>
102
- <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>
103
- <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/bear.png width=125px>
104
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-edit.C0_L0_Q0_NONE.png width=125px>
105
- <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>
106
- <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>
107
- <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↑🎉
108
- <br>♥️ Please consider to leave a <b>⭐️ Star</b> to support us ~ ♥️
109
- </p>
110
- </div>
111
-
112
- <details align='center'>
113
-
114
- <summary>Click here to show more Image/Video cases</summary>
115
-
116
- <div align='center'>
117
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext-cat.C0_L0_Q0_NONE.png width=100px>
118
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_NONE.png width=100px>
119
- <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>
120
- <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>
121
- <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>
122
- <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>
123
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/hidream.C0_L0_Q0_NONE.png width=100px>
124
- <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>
125
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview4.C0_L0_Q0_NONE.png width=100px>
126
- <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>
127
- <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>
128
- <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>
129
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview3_plus.C0_L0_Q0_NONE.png width=100px>
130
- <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>
131
- <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>
132
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/chroma1-hd.C0_L0_Q0_NONE.png width=100px>
133
- <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>
134
- <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>
135
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/mochi.C0_L0_Q0_NONE.gif width=125px>
136
- <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>
137
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/skyreels_v2.C0_L0_Q0_NONE.gif width=125px>
138
- <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>
139
- <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>
140
- <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/visualcloze/00555_00.jpg width=100px>
141
- <img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/visualcloze/12265_00.jpg width=100px>
142
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/visualcloze-512.C0_L0_Q0_NONE.png width=100px>
143
- <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>
144
- <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>
145
- <p><b>🔥VisualCloze-512</b> | Model | Cloth | Baseline | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.4x↑🎉 | 1.7x↑🎉 </p>
146
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/ltx-video.C0_L0_Q0_NONE.gif width=144px>
147
- <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>
148
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/cogvideox1.5.C0_L0_Q0_NONE.gif width=105px>
149
- <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>
150
- <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>
151
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/omingen-v1.C0_L0_Q0_NONE.png width=100px>
152
- <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>
153
- <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>
154
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/lumina2.C0_L0_Q0_NONE.png width=100px>
155
- <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>
156
- <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>
157
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/allegro.C0_L0_Q0_NONE.gif width=117px>
158
- <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>
159
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/auraflow.C0_L0_Q0_NONE.png width=133px>
160
- <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>
161
- <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>
162
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sana.C0_L0_Q0_NONE.png width=100px>
163
- <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>
164
- <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>
165
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-sigma.C0_L0_Q0_NONE.png width=100px>
166
- <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>
167
- <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>
168
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-alpha.C0_L0_Q0_NONE.png width=100px>
169
- <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>
170
- <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>
171
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/sd_3_5.C0_L0_Q0_NONE.png width=100px>
172
- <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>
173
- <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>
174
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/amused.C0_L0_Q0_NONE.png width=100px>
175
- <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>
176
- <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>
177
- <img src=https://github.com/vipshop/cache-dit/raw/main/assets/dit-xl.C0_L0_Q0_NONE.png width=100px>
178
- <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>
179
- <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↑🎉
180
- <br>♥️ Please consider to leave a <b>⭐️ Star</b> to support us ~ ♥️</p>
181
- </div>
182
- </details>
183
-
184
- ## 🔥News
185
-
186
- - [2025-09-24] 🔥**cache-dit** has now joined the 🤗 Diffusers community ecosystem as the **first** cache acceleration framework for DiTs! Check out the documentation here: **[Diffusers Docs](https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit)**. <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit"><img src=https://img.shields.io/badge/🤗Diffusers-ecosystem-yellow.svg ></a>
187
- - [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).
188
- - [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)**.
189
- - [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.
190
- - [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).
191
- - [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.
192
-
193
- <details>
194
- <summary> Previous News </summary>
195
-
196
- - [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**.
197
- - [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).
198
- - [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.
199
- - [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).
200
- - [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.
201
- - [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.
202
- - [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).
203
-
204
- </details>
205
-
206
- ## 📖Contents
207
-
208
- <div id="contents"></div>
209
-
210
- - [⚙️Installation](#️installation)
211
- - [🔥Benchmarks](#benchmarks)
212
- - [🔥Quick Start](#quick-start)
213
- - [📚Pattern Matching](#forward-pattern-matching)
214
- - [⚡️Dual Block Cache](#dbcache)
215
- - [🔥TaylorSeer Calibrator](#taylorseer)
216
- - [📚Hybrid Cache CFG](#cfg)
217
- - [🎉User Guide](#user-guide)
218
- - [©️Citations](#citations)
219
-
220
- ## ⚙️Installation
221
-
222
- <div id="installation"></div>
223
-
224
- You can install the stable release of `cache-dit` from PyPI:
225
-
226
- ```bash
227
- pip3 install -U cache-dit
228
- ```
229
- Or you can install the latest develop version from GitHub:
230
-
231
- ```bash
232
- pip3 install git+https://github.com/vipshop/cache-dit.git
233
- ```
234
-
235
- ## 🔥Benchmarks
236
-
237
- <div id="benchmarks"></div>
238
-
239
- ![image-reward-bench](https://github.com/vipshop/cache-dit/raw/main/assets/image-reward-bench.png)
240
-
241
- 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/).
242
-
243
- | Method | TFLOPs(↓) | SpeedUp(↑) | ImageReward(↑) | Clip Score(↑) |
244
- | --- | --- | --- | --- | --- |
245
- | [**FLUX.1**-dev]: 50 steps | 3726.87 | 1.00× | 0.9898 | 32.404 |
246
- | [**FLUX.1**-dev]: 60% steps | 2231.70 | 1.67× | 0.9663 | 32.312 |
247
- | Δ-DiT(N=2) | 2480.01 | 1.50× | 0.9444 | 32.273 |
248
- | Δ-DiT(N=3) | 1686.76 | 2.21× | 0.8721 | 32.102 |
249
- | [**FLUX.1**-dev]: 34% steps | 1264.63 | 3.13× | 0.9453 | 32.114 |
250
- | Chipmunk | 1505.87 | 2.47× | 0.9936 | 32.776 |
251
- | FORA(N=3) | 1320.07 | 2.82× | 0.9776 | 32.266 |
252
- | **[DBCache(F=4,B=0,W=4,MC=4)](https://github.com/vipshop/cache-dit)** | 1400.08 | **2.66×** | **1.0065** | 32.838 |
253
- | **[DBCache+TaylorSeer(F=1,B=0,O=1)](https://github.com/vipshop/cache-dit)** | 1153.05 | **3.23×** | **1.0221** | 32.819 |
254
- | DuCa(N=5) | 978.76 | 3.80× | 0.9955 | 32.241 |
255
- | TaylorSeer(N=4,O=2) | 1042.27 | 3.57× | 0.9857 | 32.413 |
256
- | **[DBCache(F=1,B=0,W=4,MC=6)](https://github.com/vipshop/cache-dit)** | 944.75 | **3.94×** | 0.9997 | 32.849 |
257
- | **[DBCache+TaylorSeer(F=1,B=0,O=1)](https://github.com/vipshop/cache-dit)** | 944.75 | **3.94×** | **1.0107** | 32.865 |
258
- | **[FoCa(N=5): arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | 893.54 | **4.16×** | **1.0029** | **32.948** |
259
-
260
- <details>
261
- <summary> Show all comparison </summary>
262
-
263
- ![clip-score-bench](https://github.com/vipshop/cache-dit/raw/main/assets/clip-score-bench.png)
264
-
265
- | Method | TFLOPs(↓) | SpeedUp(↑) | ImageReward(↑) | Clip Score(↑) |
266
- | --- | --- | --- | --- | --- |
267
- | [**FLUX.1**-dev]: 50 steps | 3726.87 | 1.00× | 0.9898 | 32.404 |
268
- | [**FLUX.1**-dev]: 60% steps | 2231.70 | 1.67× | 0.9663 | 32.312 |
269
- | Δ-DiT(N=2) | 2480.01 | 1.50× | 0.9444 | 32.273 |
270
- | Δ-DiT(N=3) | 1686.76 | 2.21× | 0.8721 | 32.102 |
271
- | [**FLUX.1**-dev]: 34% steps | 1264.63 | 3.13× | 0.9453 | 32.114 |
272
- | Chipmunk | 1505.87 | 2.47× | 0.9936 | 32.776 |
273
- | FORA(N=3) | 1320.07 | 2.82× | 0.9776 | 32.266 |
274
- | **[DBCache(F=4,B=0,W=4,MC=4)](https://github.com/vipshop/cache-dit)** | 1400.08 | **2.66×** | **1.0065** | 32.838 |
275
- | DuCa(N=5) | 978.76 | 3.80× | 0.9955 | 32.241 |
276
- | TaylorSeer(N=4,O=2) | 1042.27 | 3.57× | 0.9857 | 32.413 |
277
- | **[DBCache+TaylorSeer(F=1,B=0,O=1)](https://github.com/vipshop/cache-dit)** | 1153.05 | **3.23×** | **1.0221** | 32.819 |
278
- | **[DBCache(F=1,B=0,W=4,MC=6)](https://github.com/vipshop/cache-dit)** | 944.75 | **3.94×** | 0.9997 | 32.849 |
279
- | **[DBCache+TaylorSeer(F=1,B=0,O=1)](https://github.com/vipshop/cache-dit)** | 944.75 | **3.94×** | **1.0107** | 32.865 |
280
- | **[FoCa(N=5): arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | 893.54 | **4.16×** | **1.0029** | **32.948** |
281
- | [**FLUX.1**-dev]: 22% steps | 818.29 | 4.55× | 0.8183 | 31.772 |
282
- | FORA(N=4) | 967.91 | 3.84× | 0.9730 | 32.142 |
283
- | ToCa(N=8) | 784.54 | 4.74× | 0.9451 | 31.993 |
284
- | DuCa(N=7) | 760.14 | 4.89× | 0.9757 | 32.066 |
285
- | TeaCache(l=0.8) | 892.35 | 4.17× | 0.8683 | 31.704 |
286
- | **[DBCache(F=4,B=0,W=4,MC=10)](https://github.com/vipshop/cache-dit)** | 816.65 | 4.56x | 0.8245 | 32.191 |
287
- | TaylorSeer(N=5,O=2) | 893.54 | 4.16× | 0.9768 | 32.467 |
288
- | **[FoCa(N=7): arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | 670.44 | **5.54×** | **0.9891** | **32.920** |
289
- | FORA(N=7) | 670.14 | 5.55× | 0.7418 | 31.519 |
290
- | ToCa(N=12) | 644.70 | 5.77× | 0.7155 | 31.808 |
291
- | DuCa(N=10) | 606.91 | 6.13× | 0.8382 | 31.759 |
292
- | TeaCache(l=1.2) | 669.27 | 5.56× | 0.7394 | 31.704 |
293
- | **[DBCache(F=1,B=0,W=4,MC=10)](https://github.com/vipshop/cache-dit)** | 651.90 | **5.72x** | 0.8796 | **32.318** |
294
- | TaylorSeer(N=7,O=2) | 670.44 | 5.54× | 0.9128 | 32.128 |
295
- | **[FoCa(N=8): arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | 596.07 | **6.24×** | **0.9502** | **32.706** |
296
-
297
- NOTE: Except for DBCache, other performance data are referenced from the paper [FoCa, arxiv.2508.16211](https://arxiv.org/pdf/2508.16211).
298
-
299
- </details>
300
-
301
- ## 🔥Quick Start
302
-
303
- <div id="unified"></div>
304
-
305
- <div id="quick-start"></div>
306
-
307
- 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.
308
-
309
- ```python
310
- >>> import cache_dit
311
- >>> from diffusers import DiffusionPipeline
312
- >>> pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image") # Can be any diffusion pipeline
313
- >>> cache_dit.enable_cache(pipe) # One-line code with default cache options.
314
- >>> output = pipe(...) # Just call the pipe as normal.
315
- >>> stats = cache_dit.summary(pipe) # Then, get the summary of cache acceleration stats.
316
- >>> cache_dit.disable_cache(pipe) # Disable cache and run original pipe.
317
- ```
318
-
319
- ## 📚Forward Pattern Matching
320
-
321
- <div id="supported"></div>
322
-
323
- <div id="forward-pattern-matching"></div>
324
-
325
- cache-dit works by matching specific input/output patterns as shown below.
326
-
327
- ![](https://github.com/vipshop/cache-dit/raw/main/assets/patterns-v1.png)
328
-
329
- 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.
330
-
331
- ```python
332
- >>> import cache_dit
333
- >>> cache_dit.supported_pipelines()
334
- (30, ['Flux*', 'Mochi*', 'CogVideoX*', 'Wan*', 'HunyuanVideo*', 'QwenImage*', 'LTX*', 'Allegro*',
335
- 'CogView3Plus*', 'CogView4*', 'Cosmos*', 'EasyAnimate*', 'SkyReelsV2*', 'StableDiffusion3*',
336
- 'ConsisID*', 'DiT*', 'Amused*', 'Bria*', 'Lumina*', 'OmniGen*', 'PixArt*', 'Sana*', 'StableAudio*',
337
- 'VisualCloze*', 'AuraFlow*', 'Chroma*', 'ShapE*', 'HiDream*', 'HunyuanDiT*', 'HunyuanDiTPAG*'])
338
- ```
339
-
340
- <details>
341
- <summary> Show all pipelines </summary>
342
-
343
- - [🚀HunyuanImage-2.1](https://github.com/vipshop/cache-dit/blob/main/examples)
344
- - [🚀Qwen-Image-Lightning](https://github.com/vipshop/cache-dit/blob/main/examples)
345
- - [🚀Qwen-Image-Edit](https://github.com/vipshop/cache-dit/blob/main/examples)
346
- - [🚀Qwen-Image](https://github.com/vipshop/cache-dit/blob/main/examples)
347
- - [🚀FLUX.1-dev](https://github.com/vipshop/cache-dit/blob/main/examples)
348
- - [🚀FLUX.1-Fill-dev](https://github.com/vipshop/cache-dit/blob/main/examples)
349
- - [🚀FLUX.1-Kontext-dev](https://github.com/vipshop/cache-dit/blob/main/examples)
350
- - [🚀CogView4](https://github.com/vipshop/cache-dit/blob/main/examples)
351
- - [🚀Wan2.2-T2V](https://github.com/vipshop/cache-dit/blob/main/examples)
352
- - [🚀HunyuanVideo](https://github.com/vipshop/cache-dit/blob/main/examples)
353
- - [🚀HiDream-I1-Full](https://github.com/vipshop/cache-dit/blob/main/examples)
354
- - [🚀HunyuanDiT](https://github.com/vipshop/cache-dit/blob/main/examples)
355
- - [🚀Wan2.1-T2V](https://github.com/vipshop/cache-dit/blob/main/examples)
356
- - [🚀Wan2.1-FLF2V](https://github.com/vipshop/cache-dit/blob/main/examples)
357
- - [🚀SkyReelsV2](https://github.com/vipshop/cache-dit/blob/main/examples)
358
- - [🚀Chroma1-HD](https://github.com/vipshop/cache-dit/blob/main/examples)
359
- - [🚀CogVideoX1.5](https://github.com/vipshop/cache-dit/blob/main/examples)
360
- - [🚀CogView3-Plus](https://github.com/vipshop/cache-dit/blob/main/examples)
361
- - [🚀CogVideoX](https://github.com/vipshop/cache-dit/blob/main/examples)
362
- - [🚀VisualCloze](https://github.com/vipshop/cache-dit/blob/main/examples)
363
- - [🚀LTXVideo](https://github.com/vipshop/cache-dit/blob/main/examples)
364
- - [🚀OmniGen](https://github.com/vipshop/cache-dit/blob/main/examples)
365
- - [🚀Lumina2](https://github.com/vipshop/cache-dit/blob/main/examples)
366
- - [🚀mochi-1-preview](https://github.com/vipshop/cache-dit/blob/main/examples)
367
- - [🚀AuraFlow-v0.3](https://github.com/vipshop/cache-dit/blob/main/examples)
368
- - [🚀PixArt-Alpha](https://github.com/vipshop/cache-dit/blob/main/examples)
369
- - [🚀PixArt-Sigma](https://github.com/vipshop/cache-dit/blob/main/examples)
370
- - [🚀NVIDIA Sana](https://github.com/vipshop/cache-dit/blob/main/examples)
371
- - [🚀SD-3/3.5](https://github.com/vipshop/cache-dit/blob/main/examples)
372
- - [🚀ConsisID](https://github.com/vipshop/cache-dit/blob/main/examples)
373
- - [🚀Allegro](https://github.com/vipshop/cache-dit/blob/main/examples)
374
- - [🚀Amused](https://github.com/vipshop/cache-dit/blob/main/examples)
375
- - [🚀DiT-XL](https://github.com/vipshop/cache-dit/blob/main/examples)
376
- - ...
377
-
378
- </details>
379
-
380
- ## ⚡️DBCache: Dual Block Cache
381
-
382
- <div id="dbcache"></div>
383
-
384
- ![](https://github.com/vipshop/cache-dit/raw/main/assets/dbcache-v1.png)
385
-
386
- **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 details.
387
-
388
- ```python
389
- # Default options, F8B0, 8 warmup steps, and unlimited cached
390
- # steps for good balance between performance and precision
391
- cache_dit.enable_cache(pipe_or_adapter)
392
-
393
- # Custom options, F8B8, higher precision
394
- from cache_dit import BasicCacheConfig
395
-
396
- cache_dit.enable_cache(
397
- pipe_or_adapter,
398
- cache_config=BasicCacheConfig(
399
- max_warmup_steps=8, # steps do not cache
400
- max_cached_steps=-1, # -1 means no limit
401
- Fn_compute_blocks=8, # Fn, F8, etc.
402
- Bn_compute_blocks=8, # Bn, B8, etc.
403
- residual_diff_threshold=0.12,
404
- ),
405
- )
406
- ```
407
-
408
- ## 🔥TaylorSeer Calibrator
409
-
410
- <div id="taylorseer"></div>
411
-
412
- 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.
413
-
414
- 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.
415
-
416
- ```python
417
- from cache_dit import BasicCacheConfig, TaylorSeerCalibratorConfig
418
-
419
- cache_dit.enable_cache(
420
- pipe_or_adapter,
421
- # Basic DBCache w/ FnBn configurations
422
- cache_config=BasicCacheConfig(
423
- max_warmup_steps=8, # steps do not cache
424
- max_cached_steps=-1, # -1 means no limit
425
- Fn_compute_blocks=8, # Fn, F8, etc.
426
- Bn_compute_blocks=8, # Bn, B8, etc.
427
- residual_diff_threshold=0.12,
428
- ),
429
- # Then, you can use the TaylorSeer Calibrator to approximate
430
- # the values in cached steps, taylorseer_order default is 1.
431
- calibrator_config=TaylorSeerCalibratorConfig(
432
- taylorseer_order=1,
433
- ),
434
- )
435
- ```
436
-
437
- > [!TIP]
438
- > 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.
439
-
440
- ## 📚Hybrid Cache CFG
441
-
442
- <div id="cfg"></div>
443
-
444
- 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`.
445
-
446
- ```python
447
- from cache_dit import BasicCacheConfig
448
-
449
- cache_dit.enable_cache(
450
- pipe_or_adapter,
451
- cache_config=BasicCacheConfig(
452
- ...,
453
- # For example, set it as True for Wan 2.1/Qwen-Image
454
- # and set it as False for FLUX.1, HunyuanVideo, CogVideoX, etc.
455
- enable_separate_cfg=True,
456
- ),
457
- )
458
- ```
459
-
460
- ## 🎉User Guide
461
-
462
- <div id="user-guide"></div>
463
-
464
- 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.
465
-
466
- - [⚙️Installation](./docs/User_Guide.md#️installation)
467
- - [🔥Benchmarks](./docs/User_Guide.md#benchmarks)
468
- - [🔥Supported Pipelines](./docs/User_Guide.md#supported-pipelines)
469
- - [🎉Unified Cache APIs](./docs/User_Guide.md#unified-cache-apis)
470
- - [📚Forward Pattern Matching](./docs/User_Guide.md#forward-pattern-matching)
471
- - [📚Cache with One-line Code](./docs/User_Guide.md#%EF%B8%8Fcache-acceleration-with-one-line-code)
472
- - [🔥Automatic Block Adapter](./docs/User_Guide.md#automatic-block-adapter)
473
- - [📚Hybird Forward Pattern](./docs/User_Guide.md#hybird-forward-pattern)
474
- - [📚Implement Patch Functor](./docs/User_Guide.md#implement-patch-functor)
475
- - [🤖Cache Acceleration Stats](./docs/User_Guide.md#cache-acceleration-stats-summary)
476
- - [⚡️Dual Block Cache](./docs/User_Guide.md#️dbcache-dual-block-cache)
477
- - [🔥TaylorSeer Calibrator](./docs/User_Guide.md#taylorseer-calibrator)
478
- - [⚡️Hybrid Cache CFG](./docs/User_Guide.md#️hybrid-cache-cfg)
479
- - [⚙️Torch Compile](./docs/User_Guide.md#️torch-compile)
480
- - [🛠Metrics CLI](./docs/User_Guide.md#metrics-cli)
481
- - [📚API Documents](./docs/User_Guide.md#api-documentation)
482
-
483
- ## 👋Contribute
484
- <div id="contribute"></div>
485
-
486
- How to contribute? Star ⭐️ this repo to support us or check [CONTRIBUTE.md](https://github.com/vipshop/cache-dit/raw/main/CONTRIBUTE.md).
487
-
488
- <div align='center'>
489
- <a href="https://star-history.com/#vipshop/cache-dit&Date">
490
- <picture align='center'>
491
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date&theme=dark" />
492
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date" />
493
- <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date" width=400px />
494
- </picture>
495
- </a>
496
- </div>
497
-
498
- ## ©️Acknowledgements
499
-
500
- <div id="Acknowledgements"></div>
501
-
502
- 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.
503
-
504
- ## ©️Special Acknowledgements
505
-
506
- Special thanks to vipshop's Computer Vision AI Team for supporting document, testing and production-level deployment of this project.
507
-
508
- ## ©️Citations
509
-
510
- <div id="citations"></div>
511
-
512
- ```BibTeX
513
- @misc{cache-dit@2025,
514
- title={cache-dit: A Unified, Flexible and Training-free Cache Acceleration Framework for Diffusers.},
515
- url={https://github.com/vipshop/cache-dit.git},
516
- note={Open-source software available at https://github.com/vipshop/cache-dit.git},
517
- author={vipshop.com},
518
- year={2025}
519
- }
520
- ```