cache-dit 0.2.4__py3-none-any.whl → 0.2.6__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 +2 -2
- cache_dit/cache_factory/dual_block_cache/cache_context.py +138 -33
- cache_dit/cache_factory/first_block_cache/cache_context.py +2 -2
- cache_dit/metrics/__init__.py +12 -0
- cache_dit/metrics/fid.py +409 -0
- cache_dit/metrics/inception.py +353 -0
- cache_dit/metrics/metrics.py +356 -0
- {cache_dit-0.2.4.dist-info → cache_dit-0.2.6.dist-info}/METADATA +59 -8
- {cache_dit-0.2.4.dist-info → cache_dit-0.2.6.dist-info}/RECORD +13 -8
- cache_dit-0.2.6.dist-info/entry_points.txt +2 -0
- {cache_dit-0.2.4.dist-info → cache_dit-0.2.6.dist-info}/WHEEL +0 -0
- {cache_dit-0.2.4.dist-info → cache_dit-0.2.6.dist-info}/licenses/LICENSE +0 -0
- {cache_dit-0.2.4.dist-info → cache_dit-0.2.6.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.6
|
|
4
4
|
Summary: 🤗 CacheDiT: A Training-free and Easy-to-use Cache Acceleration Toolbox for Diffusion Transformers
|
|
5
5
|
Author: DefTruth, vipshop.com, etc.
|
|
6
6
|
Maintainer: DefTruth, vipshop.com, etc
|
|
@@ -13,6 +13,8 @@ Requires-Dist: packaging
|
|
|
13
13
|
Requires-Dist: torch>=2.5.1
|
|
14
14
|
Requires-Dist: transformers>=4.51.3
|
|
15
15
|
Requires-Dist: diffusers>=0.33.1
|
|
16
|
+
Requires-Dist: scikit-image
|
|
17
|
+
Requires-Dist: scipy
|
|
16
18
|
Provides-Extra: all
|
|
17
19
|
Provides-Extra: dev
|
|
18
20
|
Requires-Dist: pre-commit; extra == "dev"
|
|
@@ -28,6 +30,8 @@ Requires-Dist: protobuf; extra == "dev"
|
|
|
28
30
|
Requires-Dist: sentencepiece; extra == "dev"
|
|
29
31
|
Requires-Dist: opencv-python-headless; extra == "dev"
|
|
30
32
|
Requires-Dist: ftfy; extra == "dev"
|
|
33
|
+
Requires-Dist: scikit-image; extra == "dev"
|
|
34
|
+
Requires-Dist: pytorch-fid; extra == "dev"
|
|
31
35
|
Dynamic: license-file
|
|
32
36
|
Dynamic: provides-extra
|
|
33
37
|
Dynamic: requires-dist
|
|
@@ -44,7 +48,7 @@ Dynamic: requires-python
|
|
|
44
48
|
<img src=https://img.shields.io/badge/PyPI-pass-brightgreen.svg >
|
|
45
49
|
<img src=https://static.pepy.tech/badge/cache-dit >
|
|
46
50
|
<img src=https://img.shields.io/badge/Python-3.10|3.11|3.12-9cf.svg >
|
|
47
|
-
<img src=https://img.shields.io/badge/Release-v0.2
|
|
51
|
+
<img src=https://img.shields.io/badge/Release-v0.2-brightgreen.svg >
|
|
48
52
|
</div>
|
|
49
53
|
<p align="center">
|
|
50
54
|
DeepCache is for UNet not DiT. Most DiT cache speedups are complex and not training-free. CacheDiT offers <br>a set of training-free cache accelerators for DiT: <b>🔥<a href="#dbcache">DBCache</a>, <a href="#dbprune">DBPrune</a>, <a href="#taylorseer">TaylorSeer</a>, <a href="#fbcache">FBCache</a></b>, etc🔥
|
|
@@ -159,6 +163,7 @@ The **CacheDiT** codebase is adapted from [FBCache](https://github.com/chengzeyi
|
|
|
159
163
|
- [⚡️Dynamic Block Prune](#dbprune)
|
|
160
164
|
- [🎉Context Parallelism](#context-parallelism)
|
|
161
165
|
- [🔥Torch Compile](#compile)
|
|
166
|
+
- [⚙️Metrics CLI](#metrics)
|
|
162
167
|
- [👋Contribute](#contribute)
|
|
163
168
|
- [©️License](#license)
|
|
164
169
|
|
|
@@ -169,7 +174,7 @@ The **CacheDiT** codebase is adapted from [FBCache](https://github.com/chengzeyi
|
|
|
169
174
|
You can install the stable release of `cache-dit` from PyPI:
|
|
170
175
|
|
|
171
176
|
```bash
|
|
172
|
-
pip3 install cache-dit
|
|
177
|
+
pip3 install -U cache-dit
|
|
173
178
|
```
|
|
174
179
|
Or you can install the latest develop version from GitHub:
|
|
175
180
|
|
|
@@ -181,11 +186,13 @@ pip3 install git+https://github.com/vipshop/cache-dit.git
|
|
|
181
186
|
|
|
182
187
|
<div id="supported"></div>
|
|
183
188
|
|
|
184
|
-
- [🚀FLUX.1](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
185
|
-
- [🚀
|
|
189
|
+
- [🚀FLUX.1-dev](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
190
|
+
- [🚀FLUX.1-Fill-dev](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
191
|
+
- [🚀mochi-1-preview](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
186
192
|
- [🚀CogVideoX](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
187
193
|
- [🚀CogVideoX1.5](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
188
|
-
- [🚀Wan2.1](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
194
|
+
- [🚀Wan2.1-T2V](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
195
|
+
- [🚀Wan2.1-FLF2V](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
189
196
|
- [🚀HunyuanVideo](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
190
197
|
|
|
191
198
|
|
|
@@ -281,7 +288,7 @@ cache_options = {
|
|
|
281
288
|
"taylorseer_kwargs": {
|
|
282
289
|
"n_derivatives": 2, # default is 2.
|
|
283
290
|
},
|
|
284
|
-
"warmup_steps": 3, # n_derivatives + 1
|
|
291
|
+
"warmup_steps": 3, # prefer: >= n_derivatives + 1
|
|
285
292
|
"residual_diff_threshold": 0.12,
|
|
286
293
|
}
|
|
287
294
|
```
|
|
@@ -304,12 +311,23 @@ cache_options = {
|
|
|
304
311
|
|
|
305
312
|
<div id="cfg"></div>
|
|
306
313
|
|
|
307
|
-
CacheDiT supports caching for CFG (classifier-free guidance)
|
|
314
|
+
CacheDiT 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_classifier_free_guidance` param to **False (default)**. Otherwise, set it to True. For examples:
|
|
308
315
|
|
|
309
316
|
```python
|
|
310
317
|
cache_options = {
|
|
318
|
+
# CFG: classifier free guidance or not
|
|
319
|
+
# For model that fused CFG and non-CFG into single forward step,
|
|
320
|
+
# should set do_separate_classifier_free_guidance as False.
|
|
321
|
+
# For example, set it as True for Wan 2.1 and set it as False
|
|
322
|
+
# for FLUX.1, HunyuanVideo, CogVideoX, Mochi.
|
|
311
323
|
"do_separate_classifier_free_guidance": True, # Wan 2.1
|
|
324
|
+
# Compute cfg forward first or not, default False, namely,
|
|
325
|
+
# 0, 2, 4, ..., -> non-CFG step; 1, 3, 5, ... -> CFG step.
|
|
312
326
|
"cfg_compute_first": False,
|
|
327
|
+
# Compute spearate diff values for CFG and non-CFG step,
|
|
328
|
+
# default True. If False, we will use the computed diff from
|
|
329
|
+
# current non-CFG transformer step for current CFG step.
|
|
330
|
+
"cfg_diff_compute_separate": True,
|
|
313
331
|
}
|
|
314
332
|
```
|
|
315
333
|
|
|
@@ -487,6 +505,39 @@ torch._dynamo.config.accumulated_recompile_limit = 2048 # default is 256
|
|
|
487
505
|
|
|
488
506
|
Please check [bench.py](./bench/bench.py) for more details.
|
|
489
507
|
|
|
508
|
+
|
|
509
|
+
## ⚙️Metrics CLI
|
|
510
|
+
|
|
511
|
+
<div id="metrics"></div>
|
|
512
|
+
|
|
513
|
+
You can utilize the APIs provided by CacheDiT to quickly evaluate the accuracy losses caused by different cache configurations. For example:
|
|
514
|
+
|
|
515
|
+
```python
|
|
516
|
+
from cache_dit.metrics import compute_psnr
|
|
517
|
+
from cache_dit.metrics import compute_video_psnr
|
|
518
|
+
from cache_dit.metrics import FrechetInceptionDistance # FID
|
|
519
|
+
|
|
520
|
+
FID = FrechetInceptionDistance()
|
|
521
|
+
image_psnr, n = compute_psnr("true.png", "test.png") # Num: n
|
|
522
|
+
image_fid, n = FID.compute_fid("true.png", "test.png")
|
|
523
|
+
video_psnr, n = compute_video_psnr("true.mp4", "test.mp4")
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Please check [test_metrics.py](./tests/test_metrics.py) for more details. Or, you can use `cache-dit-metrics-cli` tool. For examples:
|
|
527
|
+
|
|
528
|
+
```bash
|
|
529
|
+
cache-dit-metrics-cli -h # show usage
|
|
530
|
+
cache-dit-metrics-cli all -v1 true.mp4 -v2 test.mp4 # compare video
|
|
531
|
+
cache-dit-metrics-cli all -i1 true.png -i2 test.png # compare image
|
|
532
|
+
cache-dit-metrics-cli all -i1 true_dir -i2 test_dir # compare image dir
|
|
533
|
+
cache-dit-metrics-cli all -i1 BASELINE -i2 OPTIMIZED # compare image dir
|
|
534
|
+
|
|
535
|
+
INFO 07-09 20:59:40 [metrics.py:295] BASELINE vs OPTIMIZED, Num: 1000, PSNR: 38.742413478199005
|
|
536
|
+
INFO 07-09 21:00:32 [metrics.py:300] BASELINE vs OPTIMIZED, Num: 1000, SSIM: 0.9863484896791567
|
|
537
|
+
INFO 07-09 21:00:45 [metrics.py:305] BASELINE vs OPTIMIZED, Num: 1000, MSE: 12.287594770695606
|
|
538
|
+
INFO 07-09 21:01:04 [metrics.py:311] BASELINE vs OPTIMIZED, Num: 1000, FID: 5.983550108647762
|
|
539
|
+
```
|
|
540
|
+
|
|
490
541
|
## 👋Contribute
|
|
491
542
|
<div id="contribute"></div>
|
|
492
543
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
cache_dit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
cache_dit/_version.py,sha256=
|
|
2
|
+
cache_dit/_version.py,sha256=nObnONsicQ3YX6SG5MVBxmIp5dmRacXDauSqZijWQbY,511
|
|
3
3
|
cache_dit/logger.py,sha256=0zsu42hN-3-rgGC_C29ms1IvVpV4_b4_SwJCKSenxBE,4304
|
|
4
4
|
cache_dit/primitives.py,sha256=A2iG9YLot3gOsZSPp-_gyjqjLgJvWQRx8aitD4JQ23Y,3877
|
|
5
5
|
cache_dit/cache_factory/__init__.py,sha256=5RNuhWakvvqrOV4vkqrEBA7d-V1LwcNSsjtW14mkqK8,5255
|
|
6
6
|
cache_dit/cache_factory/taylorseer.py,sha256=LKSNo2ode69EVo9xrxjxAMEjz0yDGiGADeDYnEqddA8,3987
|
|
7
7
|
cache_dit/cache_factory/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
cache_dit/cache_factory/dual_block_cache/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
cache_dit/cache_factory/dual_block_cache/cache_context.py,sha256=
|
|
9
|
+
cache_dit/cache_factory/dual_block_cache/cache_context.py,sha256=wE_xYp7DRbgB-fD8dpr75o4Cvvl2s-jnT2fRyqWm_RM,71286
|
|
10
10
|
cache_dit/cache_factory/dual_block_cache/diffusers_adapters/__init__.py,sha256=krNAICf-aS3JLmSG8vOB9tpLa04uYRcABsC8PMbVUKY,1870
|
|
11
11
|
cache_dit/cache_factory/dual_block_cache/diffusers_adapters/cogvideox.py,sha256=fibkeU-FHa30BNT-uPV2Eqcd5IRli07EKb25tMDp23c,2270
|
|
12
12
|
cache_dit/cache_factory/dual_block_cache/diffusers_adapters/flux.py,sha256=fddSpTHXU24COMGAY-Z21EmHHAEArZBv_-XLRFD6ADU,2625
|
|
@@ -22,7 +22,7 @@ cache_dit/cache_factory/dynamic_block_prune/diffusers_adapters/hunyuan_video.py,
|
|
|
22
22
|
cache_dit/cache_factory/dynamic_block_prune/diffusers_adapters/mochi.py,sha256=zXgoRDDjus3a2WSjtNh4ERtQp20ceb6nzohHMDlo2zY,2265
|
|
23
23
|
cache_dit/cache_factory/dynamic_block_prune/diffusers_adapters/wan.py,sha256=PA7nuLgfAelnaI8usQx0Kxi8XATzMapyR1WndEdFoZA,2604
|
|
24
24
|
cache_dit/cache_factory/first_block_cache/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
-
cache_dit/cache_factory/first_block_cache/cache_context.py,sha256=
|
|
25
|
+
cache_dit/cache_factory/first_block_cache/cache_context.py,sha256=tTPwhPLEA7LqGupps1Zy2MycCtLzs22wsW0yUhiiF-U,23217
|
|
26
26
|
cache_dit/cache_factory/first_block_cache/diffusers_adapters/__init__.py,sha256=-FFgA2MoudEo7uDacg4aWgm1KwfLZFsEDTVxatgbq9M,2146
|
|
27
27
|
cache_dit/cache_factory/first_block_cache/diffusers_adapters/cogvideox.py,sha256=qO5CWyurtwW30mvOe6cxeQPTSXLDlPJcezm72zEjDq8,2375
|
|
28
28
|
cache_dit/cache_factory/first_block_cache/diffusers_adapters/flux.py,sha256=Dcd4OzABCtyQCZNX2KNnUTdVoO1E1ApM7P8gcVYzcK0,2733
|
|
@@ -33,8 +33,13 @@ cache_dit/compile/__init__.py,sha256=DfMdPleFFGADXLsr7zXui8BTz_y9futY6rNmNdh9y7k
|
|
|
33
33
|
cache_dit/compile/utils.py,sha256=KU60xc474Anbj7Y_FLRFmNxEjVYLLXkhbtCLXO7o_Tc,3699
|
|
34
34
|
cache_dit/custom_ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
cache_dit/custom_ops/triton_taylorseer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
|
-
cache_dit
|
|
37
|
-
cache_dit
|
|
38
|
-
cache_dit
|
|
39
|
-
cache_dit
|
|
40
|
-
cache_dit-0.2.
|
|
36
|
+
cache_dit/metrics/__init__.py,sha256=5yavk_6b50EhaHij0C-7nQegOA0uD79-qX96dI1i_8s,461
|
|
37
|
+
cache_dit/metrics/fid.py,sha256=RIC-wW0RFv6W9IW6nc6Ih4dAxunUTnzcugMbYZjdqRM,12891
|
|
38
|
+
cache_dit/metrics/inception.py,sha256=pBVe2X6ylLPIXTG4-GWDM9DWnCviMJbJ45R3ulhktR0,12759
|
|
39
|
+
cache_dit/metrics/metrics.py,sha256=FUrpc58ofg0LKyM3Y_7kfUVbevMfCFFcaeaxeOrj9iY,10498
|
|
40
|
+
cache_dit-0.2.6.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
|
|
41
|
+
cache_dit-0.2.6.dist-info/METADATA,sha256=aTTyx_2gM7Z-mcIYd3_LlGljiZOwIq9iadDXOFPDzwA,27848
|
|
42
|
+
cache_dit-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
43
|
+
cache_dit-0.2.6.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
|
|
44
|
+
cache_dit-0.2.6.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
|
|
45
|
+
cache_dit-0.2.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|