cache-dit 0.2.21__py3-none-any.whl → 0.2.23__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/__init__.py +2 -4
- cache_dit/_version.py +2 -2
- cache_dit/cache_factory/__init__.py +5 -62
- cache_dit/cache_factory/cache_adapters.py +194 -91
- cache_dit/cache_factory/cache_blocks.py +9 -3
- cache_dit/cache_factory/cache_context.py +40 -40
- cache_dit/cache_factory/cache_interface.py +149 -0
- cache_dit/cache_factory/cache_types.py +21 -52
- cache_dit/cache_factory/taylorseer.py +0 -2
- cache_dit/cache_factory/utils.py +4 -0
- cache_dit/compile/utils.py +6 -2
- cache_dit/utils.py +33 -4
- {cache_dit-0.2.21.dist-info → cache_dit-0.2.23.dist-info}/METADATA +19 -17
- cache_dit-0.2.23.dist-info/RECORD +33 -0
- cache_dit-0.2.21.dist-info/RECORD +0 -32
- {cache_dit-0.2.21.dist-info → cache_dit-0.2.23.dist-info}/WHEEL +0 -0
- {cache_dit-0.2.21.dist-info → cache_dit-0.2.23.dist-info}/entry_points.txt +0 -0
- {cache_dit-0.2.21.dist-info → cache_dit-0.2.23.dist-info}/licenses/LICENSE +0 -0
- {cache_dit-0.2.21.dist-info → cache_dit-0.2.23.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cache_dit
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.23
|
|
4
4
|
Summary: 🤗 CacheDiT: An Unified and Training-free Cache Acceleration Toolbox for Diffusion Transformers
|
|
5
5
|
Author: DefTruth, vipshop.com, etc.
|
|
6
6
|
Maintainer: DefTruth, vipshop.com, etc
|
|
@@ -173,17 +173,23 @@ But in some cases, you may have a **modified** Diffusion Pipeline or Transformer
|
|
|
173
173
|
```python
|
|
174
174
|
from cache_dit import ForwardPattern, BlockAdapter
|
|
175
175
|
|
|
176
|
-
#
|
|
176
|
+
# Use BlockAdapter with `auto` mode.
|
|
177
|
+
cache_dit.enable_cache(
|
|
178
|
+
BlockAdapter(pipe=pipe, auto=True), # Qwen-Image, etc.
|
|
179
|
+
# Check `📚Forward Pattern Matching` documentation and hack the code of
|
|
180
|
+
# of Qwen-Image, you will find that it has satisfied `FORWARD_PATTERN_1`.
|
|
181
|
+
forward_pattern=ForwardPattern.Pattern_1,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# Or, manualy setup transformer configurations.
|
|
177
185
|
cache_dit.enable_cache(
|
|
178
186
|
BlockAdapter(
|
|
179
187
|
pipe=pipe, # Qwen-Image, etc.
|
|
180
188
|
transformer=pipe.transformer,
|
|
181
189
|
blocks=pipe.transformer.transformer_blocks,
|
|
182
190
|
blocks_name="transformer_blocks",
|
|
183
|
-
),
|
|
184
|
-
|
|
185
|
-
# of Qwen-Image, you will find that it has satisfied `FORWARD_PATTERN_1`.
|
|
186
|
-
forward_pattern=ForwardPattern.Pattern_1,
|
|
191
|
+
),
|
|
192
|
+
forward_pattern=ForwardPattern.Pattern_1,
|
|
187
193
|
)
|
|
188
194
|
```
|
|
189
195
|
For such situations, **BlockAdapter** can help you quickly apply various cache acceleration features to your own Diffusion Pipelines and Transformers. Please check the [📚BlockAdapter.md](./docs/BlockAdapter.md) for more details.
|
|
@@ -200,7 +206,7 @@ You can set `details` param as `True` to show more details of cache stats. (mark
|
|
|
200
206
|
```python
|
|
201
207
|
⚡️Cache Steps and Residual Diffs Statistics: QwenImagePipeline
|
|
202
208
|
|
|
203
|
-
| Cache Steps | Diffs
|
|
209
|
+
| Cache Steps | Diffs Min | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Max |
|
|
204
210
|
|-------------|-----------|-----------|-----------|-----------|-----------|-----------|
|
|
205
211
|
| 23 | 0.045 | 0.084 | 0.114 | 0.147 | 0.241 | 0.297 |
|
|
206
212
|
```
|
|
@@ -209,7 +215,7 @@ You can set `details` param as `True` to show more details of cache stats. (mark
|
|
|
209
215
|
|
|
210
216
|
<div id="dbcache"></div>
|
|
211
217
|
|
|
212
|
-

|
|
213
219
|
|
|
214
220
|
**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 [DBCache.md](./docs/DBCache.md) docs for more design details.
|
|
215
221
|
|
|
@@ -314,7 +320,7 @@ cache_dit.enable_cache(
|
|
|
314
320
|
|
|
315
321
|
<div id="cfg"></div>
|
|
316
322
|
|
|
317
|
-
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 `
|
|
323
|
+
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 `do_separate_cfg` param to **False (default)**. Otherwise, set it to True. For examples:
|
|
318
324
|
|
|
319
325
|
```python
|
|
320
326
|
cache_dit.enable_cache(
|
|
@@ -322,10 +328,10 @@ cache_dit.enable_cache(
|
|
|
322
328
|
...,
|
|
323
329
|
# CFG: classifier free guidance or not
|
|
324
330
|
# For model that fused CFG and non-CFG into single forward step,
|
|
325
|
-
# should set
|
|
326
|
-
#
|
|
327
|
-
#
|
|
328
|
-
|
|
331
|
+
# should set do_separate_cfg as False. For example, set it as True
|
|
332
|
+
# for Wan 2.1/Qwen-Image and set it as False for FLUX.1, HunyuanVideo,
|
|
333
|
+
# CogVideoX, Mochi, etc.
|
|
334
|
+
do_separate_cfg=True, # Wan 2.1, Qwen-Image
|
|
329
335
|
# Compute cfg forward first or not, default False, namely,
|
|
330
336
|
# 0, 2, 4, ..., -> non-CFG step; 1, 3, 5, ... -> CFG step.
|
|
331
337
|
cfg_compute_first=False,
|
|
@@ -381,10 +387,6 @@ cache-dit-metrics-cli -h # show usage
|
|
|
381
387
|
# all: PSNR, FID, SSIM, MSE, ..., etc.
|
|
382
388
|
cache-dit-metrics-cli all -i1 true.png -i2 test.png # image
|
|
383
389
|
cache-dit-metrics-cli all -i1 true_dir -i2 test_dir # image dir
|
|
384
|
-
cache-dit-metrics-cli all -v1 true.mp4 -v2 test.mp4 # video
|
|
385
|
-
cache-dit-metrics-cli all -v1 true_dir -v2 test_dir # video dir
|
|
386
|
-
cache-dit-metrics-cli fid -i1 true_dir -i2 test_dir # FID
|
|
387
|
-
cache-dit-metrics-cli psnr -i1 true_dir -i2 test_dir # PSNR
|
|
388
390
|
```
|
|
389
391
|
|
|
390
392
|
## 👋Contribute
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
cache_dit/__init__.py,sha256=KwhX9NfYkWSvDFuuUVeVjcuiZiGS_22y386l8j4afMo,905
|
|
2
|
+
cache_dit/_version.py,sha256=6GZdGbiFdhndXqR5oFLOd8VGzUvRkESP-NyStAZWYUw,706
|
|
3
|
+
cache_dit/logger.py,sha256=0zsu42hN-3-rgGC_C29ms1IvVpV4_b4_SwJCKSenxBE,4304
|
|
4
|
+
cache_dit/primitives.py,sha256=A2iG9YLot3gOsZSPp-_gyjqjLgJvWQRx8aitD4JQ23Y,3877
|
|
5
|
+
cache_dit/utils.py,sha256=3UgVhfmTFG28w6CV-Rfxp5u1uzLrRozocHwLCTGiQ5M,5865
|
|
6
|
+
cache_dit/cache_factory/.gitignore,sha256=5Cb-qT9wsTUoMJ7vACDF7ZcLpAXhi5v-xdcWSRit988,23
|
|
7
|
+
cache_dit/cache_factory/__init__.py,sha256=evWenCin1kuBGa6W5BCKMrDZc1C1R2uVPSg0BjXgdXE,499
|
|
8
|
+
cache_dit/cache_factory/cache_adapters.py,sha256=QTSwjdCmHDeF80TLp6D3KhzQS_oMPna0_bESgJBrdkg,23978
|
|
9
|
+
cache_dit/cache_factory/cache_blocks.py,sha256=ZeazBsYvLIjI5M_OnLL2xP2W7zMeM0rxVfBBwIVHBRs,18661
|
|
10
|
+
cache_dit/cache_factory/cache_context.py,sha256=4thx9NYxVaYZ_Nr2quUVE8bsNmTsXhZK0F960rccOc8,39000
|
|
11
|
+
cache_dit/cache_factory/cache_interface.py,sha256=PohG_2oy747O37YSsWz_DwxxTXN7ORhQatyEbg_6fQs,8045
|
|
12
|
+
cache_dit/cache_factory/cache_types.py,sha256=FIFa6ZBfvvSMMHyBBhvarvgg2Y2wbRgITcG_uGylGe0,991
|
|
13
|
+
cache_dit/cache_factory/forward_pattern.py,sha256=B2YeqV2t_zo2Ar8m7qimPBjwQgoXHGp2grPZmEAhi8s,1286
|
|
14
|
+
cache_dit/cache_factory/taylorseer.py,sha256=WeK2WlAJa4Px_pnAKokmnZXeqQYylQkPw4-EDqBIqeQ,3770
|
|
15
|
+
cache_dit/cache_factory/utils.py,sha256=YGtn02O3fVlrfQ32gGV4WAtTRvzzwSXNxzP_FmnE2Uk,1867
|
|
16
|
+
cache_dit/cache_factory/patch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
cache_dit/cache_factory/patch/flux.py,sha256=iNQ-1RlOgXupZ4uPiEvJ__Ro6vKT_fOKja9JrpMrO78,8998
|
|
18
|
+
cache_dit/compile/__init__.py,sha256=FcTVzCeyypl-mxlc59_ehHL3lBNiDAFsXuRoJ-5Cfi0,56
|
|
19
|
+
cache_dit/compile/utils.py,sha256=53KPsMWHyGmHGtw0T4oP0VY4O60cVXOFwFGWTlZrUqI,3857
|
|
20
|
+
cache_dit/custom_ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
+
cache_dit/custom_ops/triton_taylorseer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
cache_dit/metrics/__init__.py,sha256=RaUhl5dieF40RqnizGzR30qoJJ9dyMUEADwgwMaMQrE,575
|
|
23
|
+
cache_dit/metrics/config.py,sha256=ieOgD9ayz722RjVzk24bSIqS2D6o7TZjGk8KeXV-OLQ,551
|
|
24
|
+
cache_dit/metrics/fid.py,sha256=9Ivtazl6mW0Bon2VXa-Ia5Xj2ewxRD3V1Qkd69zYM3Y,17066
|
|
25
|
+
cache_dit/metrics/inception.py,sha256=pBVe2X6ylLPIXTG4-GWDM9DWnCviMJbJ45R3ulhktR0,12759
|
|
26
|
+
cache_dit/metrics/lpips.py,sha256=I2qCNi6qJh5TRsaIsdxO0WoRX1DN7U_H3zS0oCSahYM,1032
|
|
27
|
+
cache_dit/metrics/metrics.py,sha256=8jvM1sF-nDxUuwCRy44QEoo4dYVLCQVh1QyAMs4eaQY,27840
|
|
28
|
+
cache_dit-0.2.23.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
|
|
29
|
+
cache_dit-0.2.23.dist-info/METADATA,sha256=Dq2f8TlyTmv36otIJ2F-fRGkJlZmpW2SY6O14P2AYKo,19772
|
|
30
|
+
cache_dit-0.2.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
31
|
+
cache_dit-0.2.23.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
|
|
32
|
+
cache_dit-0.2.23.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
|
|
33
|
+
cache_dit-0.2.23.dist-info/RECORD,,
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
cache_dit/__init__.py,sha256=lpJ4vUcWuMWE0KXMJpTMxUjkMixifj5jRlp2xPI3n0c,963
|
|
2
|
-
cache_dit/_version.py,sha256=ssMI60XkNnqSio7IM67x0S2AEvggFaGv48yM5LcifrI,706
|
|
3
|
-
cache_dit/logger.py,sha256=0zsu42hN-3-rgGC_C29ms1IvVpV4_b4_SwJCKSenxBE,4304
|
|
4
|
-
cache_dit/primitives.py,sha256=A2iG9YLot3gOsZSPp-_gyjqjLgJvWQRx8aitD4JQ23Y,3877
|
|
5
|
-
cache_dit/utils.py,sha256=UF_vDtOzUb0fbzDlj353amPQSdKYdMNuY_BpMewK-mg,4968
|
|
6
|
-
cache_dit/cache_factory/.gitignore,sha256=5Cb-qT9wsTUoMJ7vACDF7ZcLpAXhi5v-xdcWSRit988,23
|
|
7
|
-
cache_dit/cache_factory/__init__.py,sha256=r2JHx-vPe5eZ8pZFN0Fgl2ZZYO7rSN3MQtTrnuZyasQ,1863
|
|
8
|
-
cache_dit/cache_factory/cache_adapters.py,sha256=qrtRxI__xn2G127c47g-gfD5-s5v-vk291vYRPJGrgM,20775
|
|
9
|
-
cache_dit/cache_factory/cache_blocks.py,sha256=kMEOoNvygzeiM2yvUSAPkKpHeQTOpXQYH2qz34TqXzs,18457
|
|
10
|
-
cache_dit/cache_factory/cache_context.py,sha256=UwrRRGmh1-IuBXD83X7Jyyl7yli4LyHbjprURoE0xE4,39819
|
|
11
|
-
cache_dit/cache_factory/cache_types.py,sha256=vRAIrbtgzeWc9m28oXG9H6Qx8UD3z7aY9vYF2iiW6Jg,2123
|
|
12
|
-
cache_dit/cache_factory/forward_pattern.py,sha256=B2YeqV2t_zo2Ar8m7qimPBjwQgoXHGp2grPZmEAhi8s,1286
|
|
13
|
-
cache_dit/cache_factory/taylorseer.py,sha256=LKSNo2ode69EVo9xrxjxAMEjz0yDGiGADeDYnEqddA8,3987
|
|
14
|
-
cache_dit/cache_factory/utils.py,sha256=Fg55vEMFNXQKGmFBsWfGGm8DW7TjRPKInkb7HlK4naE,1790
|
|
15
|
-
cache_dit/cache_factory/patch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
cache_dit/cache_factory/patch/flux.py,sha256=iNQ-1RlOgXupZ4uPiEvJ__Ro6vKT_fOKja9JrpMrO78,8998
|
|
17
|
-
cache_dit/compile/__init__.py,sha256=FcTVzCeyypl-mxlc59_ehHL3lBNiDAFsXuRoJ-5Cfi0,56
|
|
18
|
-
cache_dit/compile/utils.py,sha256=ugHrv3QRieG1xKwcg_pi3yVZF6EpSOEJjRmbnfa7VG0,3779
|
|
19
|
-
cache_dit/custom_ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
-
cache_dit/custom_ops/triton_taylorseer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
cache_dit/metrics/__init__.py,sha256=RaUhl5dieF40RqnizGzR30qoJJ9dyMUEADwgwMaMQrE,575
|
|
22
|
-
cache_dit/metrics/config.py,sha256=ieOgD9ayz722RjVzk24bSIqS2D6o7TZjGk8KeXV-OLQ,551
|
|
23
|
-
cache_dit/metrics/fid.py,sha256=9Ivtazl6mW0Bon2VXa-Ia5Xj2ewxRD3V1Qkd69zYM3Y,17066
|
|
24
|
-
cache_dit/metrics/inception.py,sha256=pBVe2X6ylLPIXTG4-GWDM9DWnCviMJbJ45R3ulhktR0,12759
|
|
25
|
-
cache_dit/metrics/lpips.py,sha256=I2qCNi6qJh5TRsaIsdxO0WoRX1DN7U_H3zS0oCSahYM,1032
|
|
26
|
-
cache_dit/metrics/metrics.py,sha256=8jvM1sF-nDxUuwCRy44QEoo4dYVLCQVh1QyAMs4eaQY,27840
|
|
27
|
-
cache_dit-0.2.21.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
|
|
28
|
-
cache_dit-0.2.21.dist-info/METADATA,sha256=w-_o415q6fDdDw_LR8ZKZhyvdcsGuKAAfYseZ8vpDj0,19908
|
|
29
|
-
cache_dit-0.2.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
-
cache_dit-0.2.21.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
|
|
31
|
-
cache_dit-0.2.21.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
|
|
32
|
-
cache_dit-0.2.21.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|