cache-dit 0.2.33__py3-none-any.whl → 0.2.36__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.
- cache_dit/__init__.py +5 -3
- cache_dit/_version.py +2 -2
- cache_dit/cache_factory/block_adapters/__init__.py +14 -20
- cache_dit/cache_factory/block_adapters/block_adapters.py +46 -2
- cache_dit/cache_factory/block_adapters/block_registers.py +3 -2
- cache_dit/cache_factory/cache_adapters.py +8 -8
- cache_dit/cache_factory/cache_contexts/cache_context.py +11 -11
- cache_dit/cache_factory/cache_contexts/cache_manager.py +5 -5
- cache_dit/cache_factory/cache_contexts/taylorseer.py +12 -6
- cache_dit/cache_factory/cache_interface.py +9 -9
- cache_dit/cache_factory/patch_functors/__init__.py +1 -0
- cache_dit/cache_factory/patch_functors/functor_chroma.py +142 -52
- cache_dit/cache_factory/patch_functors/functor_dit.py +130 -0
- cache_dit/metrics/clip_score.py +135 -0
- cache_dit/metrics/fid.py +42 -0
- cache_dit/metrics/image_reward.py +177 -0
- cache_dit/metrics/lpips.py +2 -14
- cache_dit/metrics/metrics.py +420 -76
- cache_dit/utils.py +15 -0
- {cache_dit-0.2.33.dist-info → cache_dit-0.2.36.dist-info}/METADATA +261 -52
- {cache_dit-0.2.33.dist-info → cache_dit-0.2.36.dist-info}/RECORD +25 -22
- {cache_dit-0.2.33.dist-info → cache_dit-0.2.36.dist-info}/WHEEL +0 -0
- {cache_dit-0.2.33.dist-info → cache_dit-0.2.36.dist-info}/entry_points.txt +0 -0
- {cache_dit-0.2.33.dist-info → cache_dit-0.2.36.dist-info}/licenses/LICENSE +0 -0
- {cache_dit-0.2.33.dist-info → cache_dit-0.2.36.dist-info}/top_level.txt +0 -0
cache_dit/utils.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import torch
|
|
2
2
|
import dataclasses
|
|
3
3
|
import diffusers
|
|
4
|
+
import builtins as __builtin__
|
|
5
|
+
import contextlib
|
|
6
|
+
|
|
4
7
|
import numpy as np
|
|
5
8
|
from pprint import pprint
|
|
6
9
|
from diffusers import DiffusionPipeline
|
|
@@ -13,6 +16,18 @@ from cache_dit.logger import init_logger
|
|
|
13
16
|
logger = init_logger(__name__)
|
|
14
17
|
|
|
15
18
|
|
|
19
|
+
def dummy_print(*args, **kwargs):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@contextlib.contextmanager
|
|
24
|
+
def disable_print():
|
|
25
|
+
origin_print = __builtin__.print
|
|
26
|
+
__builtin__.print = dummy_print
|
|
27
|
+
yield
|
|
28
|
+
__builtin__.print = origin_print
|
|
29
|
+
|
|
30
|
+
|
|
16
31
|
@torch.compiler.disable
|
|
17
32
|
def is_diffusers_at_least_0_3_5() -> bool:
|
|
18
33
|
return diffusers.__version__ >= "0.35.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cache_dit
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.36
|
|
4
4
|
Summary: 🤗 A Unified and Training-free Cache Acceleration Toolbox for Diffusion Transformers
|
|
5
5
|
Author: DefTruth, vipshop.com, etc.
|
|
6
6
|
Maintainer: DefTruth, vipshop.com, etc
|
|
@@ -18,7 +18,12 @@ Requires-Dist: scikit-image
|
|
|
18
18
|
Requires-Dist: scipy
|
|
19
19
|
Requires-Dist: lpips==0.1.4
|
|
20
20
|
Requires-Dist: torchao>=0.12.0
|
|
21
|
+
Requires-Dist: image-reward
|
|
21
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"
|
|
22
27
|
Provides-Extra: dev
|
|
23
28
|
Requires-Dist: pre-commit; extra == "dev"
|
|
24
29
|
Requires-Dist: pytest<8.0.0,>=7.0.0; extra == "dev"
|
|
@@ -56,44 +61,102 @@ Dynamic: requires-python
|
|
|
56
61
|
<img src=https://img.shields.io/badge/Release-v0.2-brightgreen.svg >
|
|
57
62
|
</div>
|
|
58
63
|
<p align="center">
|
|
59
|
-
|
|
64
|
+
<b><a href="#unified">📚Unified Cache APIs</a></b> | <a href="#forward-pattern-matching">📚Forward Pattern Matching</a> | <a href="#automatic-block-adapter">📚Automatic Block Adapter</a><br>
|
|
65
|
+
<a href="#hybird-forward-pattern">📚Hybrid Forward Pattern</a> | <a href="#dbcache">📚DBCache</a> | <a href="#taylorseer">📚Hybrid TaylorSeer</a> | <a href="#cfg">📚Cache CFG</a>
|
|
60
66
|
</p>
|
|
61
67
|
<p align="center">
|
|
62
68
|
🎉Now, <b>cache-dit</b> covers <b>most</b> mainstream Diffusers' <b>DiT</b> Pipelines🎉<br>
|
|
63
|
-
🔥<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
|
|
64
|
-
🔥<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">
|
|
65
|
-
🔥<a href="#supported">CogView3Plus</a> | <a href="#supported">CogView4</a> | <a href="#supported">
|
|
66
|
-
🔥<a href="#supported">Cosmos</a> | <a href="#supported">SkyReelsV2</a> | <a href="#supported">VisualCloze</a> | <a href="#supported">
|
|
67
|
-
🔥<a href="#supported">Allegro</a> | <a href="#supported">
|
|
69
|
+
🔥<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>
|
|
70
|
+
🔥<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>
|
|
71
|
+
🔥<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>
|
|
72
|
+
🔥<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>
|
|
73
|
+
🔥<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>🔥
|
|
68
74
|
</p>
|
|
69
75
|
</div>
|
|
70
76
|
<div align='center'>
|
|
71
77
|
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/wan2.2.C0_Q0_NONE.gif width=124px>
|
|
72
78
|
<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>
|
|
73
|
-
<img src
|
|
74
|
-
<img src
|
|
79
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/hunyuan_video.C0_L0_Q0_NONE.gif width=126px>
|
|
80
|
+
<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>
|
|
75
81
|
<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>
|
|
76
82
|
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image.C0_Q0_NONE.png width=160px>
|
|
77
83
|
<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>
|
|
78
|
-
<img src
|
|
79
|
-
<img src
|
|
84
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux.C0_Q0_NONE_T23.69s.png width=90px>
|
|
85
|
+
<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>
|
|
80
86
|
<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>
|
|
87
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext-cat.C0_L0_Q0_NONE.png width=100px>
|
|
88
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/flux-kontext.C0_L0_Q0_NONE.png width=100px>
|
|
89
|
+
<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>
|
|
90
|
+
<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>
|
|
91
|
+
<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>
|
|
92
|
+
<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>
|
|
81
93
|
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-lightning.4steps.C0_L1_Q0_NONE.png width=160px>
|
|
82
94
|
<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>
|
|
83
|
-
<img src
|
|
84
|
-
<img src
|
|
85
|
-
<p><b>🔥Qwen
|
|
86
|
-
<img src
|
|
87
|
-
<img src
|
|
88
|
-
<img src
|
|
89
|
-
<img src
|
|
90
|
-
<
|
|
95
|
+
<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>
|
|
96
|
+
<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>
|
|
97
|
+
<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>
|
|
98
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/bear.png width=125px>
|
|
99
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/qwen-image-edit.C0_L0_Q0_NONE.png width=125px>
|
|
100
|
+
<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>
|
|
101
|
+
<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>
|
|
102
|
+
<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>
|
|
103
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/hidream.C0_L0_Q0_NONE.png width=100px>
|
|
104
|
+
<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>
|
|
105
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview4.C0_L0_Q0_NONE.png width=100px>
|
|
106
|
+
<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>
|
|
107
|
+
<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>
|
|
91
108
|
<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>
|
|
92
|
-
<img src
|
|
93
|
-
<img src
|
|
94
|
-
<img src
|
|
95
|
-
<img src
|
|
96
|
-
<
|
|
109
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/cogview3_plus.C0_L0_Q0_NONE.png width=100px>
|
|
110
|
+
<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>
|
|
111
|
+
<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>
|
|
112
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/chroma1-hd.C0_L0_Q0_NONE.png width=100px>
|
|
113
|
+
<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>
|
|
114
|
+
<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>
|
|
115
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/mochi.C0_L0_Q0_NONE.gif width=125px>
|
|
116
|
+
<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>
|
|
117
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/skyreels_v2.C0_L0_Q0_NONE.gif width=125px>
|
|
118
|
+
<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>
|
|
119
|
+
<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>
|
|
120
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/visualcloze/00555_00.jpg width=100px>
|
|
121
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/examples/data/visualcloze/12265_00.jpg width=100px>
|
|
122
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/visualcloze-512.C0_L0_Q0_NONE.png width=100px>
|
|
123
|
+
<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>
|
|
124
|
+
<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>
|
|
125
|
+
<p><b>🔥VisualCloze-512</b> | Model | Cloth | Baseline | <a href="https://github.com/vipshop/cache-dit">+cache-dit</a>:1.4x↑🎉 | 1.7x↑🎉 </p>
|
|
126
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/ltx-video.C0_L0_Q0_NONE.gif width=144px>
|
|
127
|
+
<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>
|
|
128
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/cogvideox1.5.C0_L0_Q0_NONE.gif width=105px>
|
|
129
|
+
<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>
|
|
130
|
+
<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>
|
|
131
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/omingen-v1.C0_L0_Q0_NONE.png width=100px>
|
|
132
|
+
<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>
|
|
133
|
+
<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>
|
|
134
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/lumina2.C0_L0_Q0_NONE.png width=100px>
|
|
135
|
+
<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>
|
|
136
|
+
<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>
|
|
137
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/gifs/allegro.C0_L0_Q0_NONE.gif width=117px>
|
|
138
|
+
<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>
|
|
139
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/auraflow.C0_L0_Q0_NONE.png width=133px>
|
|
140
|
+
<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>
|
|
141
|
+
<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>
|
|
142
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/sana.C0_L0_Q0_NONE.png width=100px>
|
|
143
|
+
<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>
|
|
144
|
+
<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>
|
|
145
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-sigma.C0_L0_Q0_NONE.png width=100px>
|
|
146
|
+
<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>
|
|
147
|
+
<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>
|
|
148
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/pixart-alpha.C0_L0_Q0_NONE.png width=100px>
|
|
149
|
+
<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>
|
|
150
|
+
<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>
|
|
151
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/sd_3_5.C0_L0_Q0_NONE.png width=100px>
|
|
152
|
+
<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>
|
|
153
|
+
<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>
|
|
154
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/amused.C0_L0_Q0_NONE.png width=100px>
|
|
155
|
+
<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>
|
|
156
|
+
<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>
|
|
157
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/dit-xl.C0_L0_Q0_NONE.png width=100px>
|
|
158
|
+
<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>
|
|
159
|
+
<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↑🎉
|
|
97
160
|
<br>♥️ Please consider to leave a <b>⭐️ Star</b> to support us ~ ♥️</p>
|
|
98
161
|
</div>
|
|
99
162
|
|
|
@@ -123,13 +186,15 @@ Dynamic: requires-python
|
|
|
123
186
|
<div id="contents"></div>
|
|
124
187
|
|
|
125
188
|
- [⚙️Installation](#️installation)
|
|
126
|
-
- [🔥
|
|
189
|
+
- [🔥Benchmarks](#benchmarks)
|
|
190
|
+
- [🔥Supported Pipelines](#supported)
|
|
127
191
|
- [🎉Unified Cache APIs](#unified)
|
|
128
|
-
- [📚Forward Pattern Matching](#
|
|
129
|
-
- [
|
|
130
|
-
- [🔥Automatic Block Adapter](#
|
|
131
|
-
- [📚Hybird Forward Pattern](#
|
|
132
|
-
- [
|
|
192
|
+
- [📚Forward Pattern Matching](#forward-pattern-matching)
|
|
193
|
+
- [♥️Cache with One-line Code](#%EF%B8%8Fcache-acceleration-with-one-line-code)
|
|
194
|
+
- [🔥Automatic Block Adapter](#automatic-block-adapter)
|
|
195
|
+
- [📚Hybird Forward Pattern](#automatic-block-adapter)
|
|
196
|
+
- [📚Implement Patch Functor](#implement-patch-functor)
|
|
197
|
+
- [🤖Cache Acceleration Stats](#cache-acceleration-stats-summary)
|
|
133
198
|
- [⚡️Dual Block Cache](#dbcache)
|
|
134
199
|
- [🔥Hybrid TaylorSeer](#taylorseer)
|
|
135
200
|
- [⚡️Hybrid Cache CFG](#cfg)
|
|
@@ -151,36 +216,105 @@ Or you can install the latest develop version from GitHub:
|
|
|
151
216
|
pip3 install git+https://github.com/vipshop/cache-dit.git
|
|
152
217
|
```
|
|
153
218
|
|
|
154
|
-
## 🔥Supported
|
|
219
|
+
## 🔥Supported Pipelines
|
|
155
220
|
|
|
156
221
|
<div id="supported"></div>
|
|
157
222
|
|
|
158
|
-
Currently, **cache-dit** library supports almost **Any** Diffusion Transformers (with **Transformer Blocks** that match the specific Input and Output **patterns**). Please check [🎉
|
|
223
|
+
Currently, **cache-dit** library supports almost **Any** Diffusion Transformers (with **Transformer Blocks** that match the specific Input and Output **patterns**). Please check [🎉Examples](./examples/pipeline) for more details. Here are just some of the tested models listed.
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
>>> import cache_dit
|
|
227
|
+
>>> cache_dit.supported_pipelines()
|
|
228
|
+
(30, ['Flux*', 'Mochi*', 'CogVideoX*', 'Wan*', 'HunyuanVideo*', 'QwenImage*', 'LTX*', 'Allegro*',
|
|
229
|
+
'CogView3Plus*', 'CogView4*', 'Cosmos*', 'EasyAnimate*', 'SkyReelsV2*', 'StableDiffusion3*',
|
|
230
|
+
'ConsisID*', 'DiT*', 'Amused*', 'Bria*', 'Lumina*', 'OmniGen*', 'PixArt*', 'Sana*', 'StableAudio*',
|
|
231
|
+
'VisualCloze*', 'AuraFlow*', 'Chroma*', 'ShapE*', 'HiDream*', 'HunyuanDiT*', 'HunyuanDiTPAG*'])
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
<details>
|
|
235
|
+
<summary> Show all pipelines </summary>
|
|
159
236
|
|
|
160
237
|
- [🚀HunyuanImage-2.1](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
161
|
-
- [🚀Qwen-Image-Lightning](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
238
|
+
- [🚀Qwen-Image-Lightning](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
162
239
|
- [🚀Qwen-Image-Edit](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
163
240
|
- [🚀Qwen-Image](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
164
241
|
- [🚀FLUX.1-dev](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
165
242
|
- [🚀FLUX.1-Fill-dev](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
166
|
-
- [🚀FLUX.1-Kontext-dev](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
167
|
-
- [🚀CogVideoX](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
168
|
-
- [🚀CogVideoX1.5](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
169
|
-
- [🚀CogView3-Plus](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
243
|
+
- [🚀FLUX.1-Kontext-dev](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
170
244
|
- [🚀CogView4](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
171
245
|
- [🚀Wan2.2-T2V](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
246
|
+
- [🚀HunyuanVideo](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
247
|
+
- [🚀HiDream-I1-Full](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
248
|
+
- [🚀HunyuanDiT](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
172
249
|
- [🚀Wan2.1-T2V](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
173
250
|
- [🚀Wan2.1-FLF2V](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
251
|
+
- [🚀SkyReelsV2](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
252
|
+
- [🚀Chroma1-HD](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
253
|
+
- [🚀CogVideoX1.5](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
254
|
+
- [🚀CogView3-Plus](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
255
|
+
- [🚀CogVideoX](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
256
|
+
- [🚀VisualCloze](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
257
|
+
- [🚀LTXVideo](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
258
|
+
- [🚀OmniGen](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
259
|
+
- [🚀Lumina2](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
174
260
|
- [🚀mochi-1-preview](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
175
|
-
- [🚀
|
|
176
|
-
- [🚀HunyuanDiT](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
177
|
-
- [🚀HiDream-I1-Full](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
261
|
+
- [🚀AuraFlow-v0.3](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
178
262
|
- [🚀PixArt-Alpha](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
179
263
|
- [🚀PixArt-Sigma](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
264
|
+
- [🚀NVIDIA Sana](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
180
265
|
- [🚀SD-3/3.5](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
266
|
+
- [🚀ConsisID](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
267
|
+
- [🚀Allegro](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
268
|
+
- [🚀Amused](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
269
|
+
- [🚀DiT-XL](https://github.com/vipshop/cache-dit/raw/main/examples)
|
|
270
|
+
- ...
|
|
181
271
|
|
|
182
272
|
</details>
|
|
183
273
|
|
|
274
|
+
## 🔥Benchmarks
|
|
275
|
+
|
|
276
|
+
<div id="benchmarks"></div>
|
|
277
|
+
|
|
278
|
+
Take FLUX.1-dev as an example. Here, only the results of some precision and performance benchmarks are presented. The test dataset is DrawBench. For a complete benchmark, please refer to [benchmarks](./bench/). **Device**: NVIDIA L20. **F**: Fn_compute_blocks, **B**: Bn_compute_blocks.
|
|
279
|
+
|
|
280
|
+
| Config | Clip Score(↑) | ImageReward(↑) | PSNR(↑) | TFLOPs(↑) | SpeedUp(↑) |
|
|
281
|
+
| --- | --- | --- | --- | --- | --- |
|
|
282
|
+
| [**FLUX.1**-dev]: 50 steps | 32.9217 | 1.0412 | INF | 3726.87 | 1.00 |
|
|
283
|
+
| F8B0_W8MC0_R0.08 | 33.0070 | 1.0333 | 35.2008 | 2162.19 | 1.72x |
|
|
284
|
+
| F8B0_W4MC0_R0.08 | 32.9871 | 1.0370 | 33.8317 | 2064.81 | 1.80x |
|
|
285
|
+
| F4B0_W4MC2_R0.12 | 32.9718 | 1.0301 | 31.9394 | 1678.98 | 2.22x |
|
|
286
|
+
| F8B0_W8MC3_R0.12 | 32.9613 | 1.0270 | 34.2834 | 1977.69 | 1.88x |
|
|
287
|
+
| F8B0_W4MC2_R0.12 | 32.9535 | 1.0185 | 32.7346 | 1935.73 | 1.93x |
|
|
288
|
+
| F8B0_W8MC2_R0.12 | 32.9302 | 1.0227 | 34.7449 | 2072.18 | 1.80x |
|
|
289
|
+
| F8B0_W4MC3_R0.12 | 32.9234 | 1.0085 | 32.5385 | 1816.58 | 2.05x |
|
|
290
|
+
| F8B0_W8MC4_R0.12 | 32.9041 | 1.0140 | 33.9466 | 1897.61 | 1.96x |
|
|
291
|
+
| F4B0_W4MC3_R0.12 | 32.8981 | 1.0130 | 31.8031 | 1507.83 | 2.47x |
|
|
292
|
+
| F4B0_W4MC0_R0.08 | 32.8544 | 1.0065 | 32.3555 | 1654.72 | 2.25x |
|
|
293
|
+
| F8B0_W4MC4_R0.12 | 32.8443 | 1.0102 | 32.4231 | 1753.48 | 2.13x |
|
|
294
|
+
| F4B0_W4MC4_R0.12 | 32.8384 | 1.0065 | 31.5292 | 1400.08 | 2.66x |
|
|
295
|
+
| F1B0_W4MC4_R0.12 | 32.8291 | 1.0181 | 32.9462 | 1401.61 | 2.66x |
|
|
296
|
+
| F1B0_W4MC3_R0.12 | 32.8236 | 1.0166 | 33.0037 | 1457.62 | 2.56x |
|
|
297
|
+
|
|
298
|
+
The comparison between 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. Please check [📚How to Reproduce?](./bench/) for more details.
|
|
299
|
+
|
|
300
|
+
| Method | TFLOPs(↓) | SpeedUp(↑) | ImageReward(↑) | Clip Score(↑) |
|
|
301
|
+
| --- | --- | --- | --- | --- |
|
|
302
|
+
| [**FLUX.1**-dev]: 50 steps | 3726.87 | 1.00× | 0.9898 | 32.404 |
|
|
303
|
+
| [**FLUX.1**-dev]: 60% steps | 2231.70 | 1.67× | 0.9663 | 32.312 |
|
|
304
|
+
| Δ-DiT (N=2) | 2480.01 | 1.50× | 0.9444 | 32.273 |
|
|
305
|
+
| Δ-DiT (N=3) | 1686.76 | 2.21× | 0.8721 | 32.102 |
|
|
306
|
+
| [**FLUX.1**-dev]: 34% steps | 1264.63 | 3.13× | 0.9453 | 32.114 |
|
|
307
|
+
| Chipmunk | 1505.87 | 2.47× | 0.9936 | 32.776 |
|
|
308
|
+
| FORA (N=3) | 1320.07 | 2.82× | 0.9776 | 32.266 |
|
|
309
|
+
| **[DBCache (F=4, B=0)](https://github.com/vipshop/cache-dit)** | **1400.08** | **2.66×** | **1.0065** | **32.838** |
|
|
310
|
+
| **[DBCache + TaylorSeer (F=4, B=0)](https://github.com/vipshop/cache-dit)** | **1388.30** | **2.68×** | **1.0287** | **32.914** |
|
|
311
|
+
| DuCa(N=5) | 978.76 | 3.80× | 0.9955 | 32.241 |
|
|
312
|
+
| TaylorSeer (N=4, O=2) | 1042.27 | 3.57× | 0.9857 | 32.413 |
|
|
313
|
+
| **[FoCa (N=5) arxiv.2508.16211](https://arxiv.org/pdf/2508.16211)** | **893.54** | **4.16×** | **1.0029** | **32.948** |
|
|
314
|
+
|
|
315
|
+
cache-dit will support more mainstream Cache acceleration algorithms in the future. More benchmarks will be released, please stay tuned for update.
|
|
316
|
+
|
|
317
|
+
|
|
184
318
|
## 🎉Unified Cache APIs
|
|
185
319
|
|
|
186
320
|
<div id="unified"></div>
|
|
@@ -265,6 +399,75 @@ cache_dit.enable_cache(
|
|
|
265
399
|
)
|
|
266
400
|
```
|
|
267
401
|
|
|
402
|
+
Even sometimes you have more complex cases, such as **Wan 2.2 MoE**, which has more than one Transformer (namely `transformer` and `transformer_2`) in its structure. Fortunately, **cache-dit** can also handle this situation very well. Please refer to [📚Wan 2.2 MoE](./examples/pipeline/run_wan_2.2.py) as an example.
|
|
403
|
+
|
|
404
|
+
```python
|
|
405
|
+
from cache_dit import ForwardPattern, BlockAdapter, ParamsModifier
|
|
406
|
+
|
|
407
|
+
cache_dit.enable_cache(
|
|
408
|
+
BlockAdapter(
|
|
409
|
+
pipe=pipe,
|
|
410
|
+
transformer=[
|
|
411
|
+
pipe.transformer,
|
|
412
|
+
pipe.transformer_2,
|
|
413
|
+
],
|
|
414
|
+
blocks=[
|
|
415
|
+
pipe.transformer.blocks,
|
|
416
|
+
pipe.transformer_2.blocks,
|
|
417
|
+
],
|
|
418
|
+
forward_pattern=[
|
|
419
|
+
ForwardPattern.Pattern_2,
|
|
420
|
+
ForwardPattern.Pattern_2,
|
|
421
|
+
],
|
|
422
|
+
# Setup different cache params for each 'blocks'. You can
|
|
423
|
+
# pass any specific cache params to ParamModifier, the old
|
|
424
|
+
# value will be overwrite by the new one.
|
|
425
|
+
params_modifiers=[
|
|
426
|
+
ParamsModifier(
|
|
427
|
+
max_warmup_steps=4,
|
|
428
|
+
max_cached_steps=8,
|
|
429
|
+
),
|
|
430
|
+
ParamsModifier(
|
|
431
|
+
max_warmup_steps=2,
|
|
432
|
+
max_cached_steps=20,
|
|
433
|
+
),
|
|
434
|
+
],
|
|
435
|
+
has_separate_cfg=True,
|
|
436
|
+
),
|
|
437
|
+
)
|
|
438
|
+
```
|
|
439
|
+
### 📚Implement Patch Functor
|
|
440
|
+
|
|
441
|
+
For any PATTERN not {0...5}, we introduced the simple abstract concept of **Patch Functor**. Users can implement a subclass of Patch Functor to convert an unknown Pattern into a known PATTERN, and for some models, users may also need to fuse the operations within the blocks for loop into block forward.
|
|
442
|
+
|
|
443
|
+

|
|
444
|
+
|
|
445
|
+
Some Patch functors have already been provided in cache-dit: [📚HiDreamPatchFunctor](./src/cache_dit/cache_factory/patch_functors/functor_hidream.py), [📚ChromaPatchFunctor](./src/cache_dit/cache_factory/patch_functors/functor_chroma.py), etc. After implementing Patch Functor, users need to set the `patch_functor` property of **BlockAdapter**.
|
|
446
|
+
|
|
447
|
+
```python
|
|
448
|
+
@BlockAdapterRegistry.register("HiDream")
|
|
449
|
+
def hidream_adapter(pipe, **kwargs) -> BlockAdapter:
|
|
450
|
+
from diffusers import HiDreamImageTransformer2DModel
|
|
451
|
+
from cache_dit.cache_factory.patch_functors import HiDreamPatchFunctor
|
|
452
|
+
|
|
453
|
+
assert isinstance(pipe.transformer, HiDreamImageTransformer2DModel)
|
|
454
|
+
return BlockAdapter(
|
|
455
|
+
pipe=pipe,
|
|
456
|
+
transformer=pipe.transformer,
|
|
457
|
+
blocks=[
|
|
458
|
+
pipe.transformer.double_stream_blocks,
|
|
459
|
+
pipe.transformer.single_stream_blocks,
|
|
460
|
+
],
|
|
461
|
+
forward_pattern=[
|
|
462
|
+
ForwardPattern.Pattern_0,
|
|
463
|
+
ForwardPattern.Pattern_3,
|
|
464
|
+
],
|
|
465
|
+
# NOTE: Setup your custom patch functor here.
|
|
466
|
+
patch_functor=HiDreamPatchFunctor(),
|
|
467
|
+
**kwargs,
|
|
468
|
+
)
|
|
469
|
+
```
|
|
470
|
+
|
|
268
471
|
### 🤖Cache Acceleration Stats Summary
|
|
269
472
|
|
|
270
473
|
After finishing each inference of `pipe(...)`, you can call the `cache_dit.summary()` API on pipe to get the details of the **Cache Acceleration Stats** for the current inference.
|
|
@@ -348,7 +551,7 @@ cache_dit.enable_cache(
|
|
|
348
551
|
# Taylorseer cache type cache be hidden_states or residual.
|
|
349
552
|
taylorseer_cache_type="residual",
|
|
350
553
|
# Higher values of order will lead to longer computation time
|
|
351
|
-
taylorseer_order=
|
|
554
|
+
taylorseer_order=1, # default is 1.
|
|
352
555
|
max_warmup_steps=3, # prefer: >= order + 1
|
|
353
556
|
residual_diff_threshold=0.12
|
|
354
557
|
)s
|
|
@@ -372,7 +575,7 @@ cache_dit.enable_cache(
|
|
|
372
575
|
|
|
373
576
|
<div id="cfg"></div>
|
|
374
577
|
|
|
375
|
-
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 `
|
|
578
|
+
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` param to **False (default, None)**. Otherwise, set it to True. For examples:
|
|
376
579
|
|
|
377
580
|
```python
|
|
378
581
|
cache_dit.enable_cache(
|
|
@@ -380,14 +583,14 @@ cache_dit.enable_cache(
|
|
|
380
583
|
...,
|
|
381
584
|
# CFG: classifier free guidance or not
|
|
382
585
|
# For model that fused CFG and non-CFG into single forward step,
|
|
383
|
-
# should set
|
|
586
|
+
# should set enable_separate_cfg as False. For example, set it as True
|
|
384
587
|
# for Wan 2.1/Qwen-Image and set it as False for FLUX.1, HunyuanVideo,
|
|
385
588
|
# CogVideoX, Mochi, LTXVideo, Allegro, CogView3Plus, EasyAnimate, SD3, etc.
|
|
386
|
-
|
|
589
|
+
enable_separate_cfg=True, # Wan 2.1, Qwen-Image, CogView4, Cosmos, SkyReelsV2, etc.
|
|
387
590
|
# Compute cfg forward first or not, default False, namely,
|
|
388
591
|
# 0, 2, 4, ..., -> non-CFG step; 1, 3, 5, ... -> CFG step.
|
|
389
592
|
cfg_compute_first=False,
|
|
390
|
-
# Compute
|
|
593
|
+
# Compute separate diff values for CFG and non-CFG step,
|
|
391
594
|
# default True. If False, we will use the computed diff from
|
|
392
595
|
# current non-CFG transformer step for current CFG step.
|
|
393
596
|
cfg_diff_compute_separate=True,
|
|
@@ -423,13 +626,19 @@ You can utilize the APIs provided by cache-dit to quickly evaluate the accuracy
|
|
|
423
626
|
|
|
424
627
|
```python
|
|
425
628
|
from cache_dit.metrics import compute_psnr
|
|
426
|
-
from cache_dit.metrics import
|
|
427
|
-
from cache_dit.metrics import
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
629
|
+
from cache_dit.metrics import compute_ssim
|
|
630
|
+
from cache_dit.metrics import compute_fid
|
|
631
|
+
from cache_dit.metrics import compute_lpips
|
|
632
|
+
from cache_dit.metrics import compute_clip_score
|
|
633
|
+
from cache_dit.metrics import compute_image_reward
|
|
634
|
+
|
|
635
|
+
psnr, n = compute_psnr("true.png", "test.png") # Num: n
|
|
636
|
+
psnr, n = compute_psnr("true_dir", "test_dir")
|
|
637
|
+
ssim, n = compute_ssim("true_dir", "test_dir")
|
|
638
|
+
fid, n = compute_fid("true_dir", "test_dir")
|
|
639
|
+
lpips, n = compute_lpips("true_dir", "test_dir")
|
|
640
|
+
clip_score, n = compute_clip_score("DrawBench200.txt", "test_dir")
|
|
641
|
+
reward, n = compute_image_reward("DrawBench200.txt", "test_dir")
|
|
433
642
|
```
|
|
434
643
|
|
|
435
644
|
Please check [test_metrics.py](./tests/test_metrics.py) for more details. Or, you can use `cache-dit-metrics-cli` tool. For examples:
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
cache_dit/__init__.py,sha256=
|
|
2
|
-
cache_dit/_version.py,sha256=
|
|
1
|
+
cache_dit/__init__.py,sha256=hzaexC1VQ0TxiWY6TJ1lTm-04e65WOTNHOfYryu1vFA,1284
|
|
2
|
+
cache_dit/_version.py,sha256=y3W4kIzeljZ6sUAtO8hW9y1LA6HKsN9jWHCm6JjF5gw,706
|
|
3
3
|
cache_dit/logger.py,sha256=0zsu42hN-3-rgGC_C29ms1IvVpV4_b4_SwJCKSenxBE,4304
|
|
4
|
-
cache_dit/utils.py,sha256=
|
|
4
|
+
cache_dit/utils.py,sha256=nuHHr6NB286qE9u6klLNfhAVRMOGipihOhM8LRqznmU,10775
|
|
5
5
|
cache_dit/cache_factory/.gitignore,sha256=5Cb-qT9wsTUoMJ7vACDF7ZcLpAXhi5v-xdcWSRit988,23
|
|
6
6
|
cache_dit/cache_factory/__init__.py,sha256=Iw6-iJLFbdzCsIDZXXOw371L-HPmoeZO_P9a3sDjP5s,1103
|
|
7
|
-
cache_dit/cache_factory/cache_adapters.py,sha256=
|
|
8
|
-
cache_dit/cache_factory/cache_interface.py,sha256=
|
|
7
|
+
cache_dit/cache_factory/cache_adapters.py,sha256=OFJlxxyODhoZstN4EfPgC7tE8M1ZdQFcE25gDNrW7NA,18212
|
|
8
|
+
cache_dit/cache_factory/cache_interface.py,sha256=tHQv7i8Hp6nfbjZWHwDx3nEvCfxLeBw26aMYjyu6nMw,8541
|
|
9
9
|
cache_dit/cache_factory/cache_types.py,sha256=ooukxQRG55uTLmaZ0SKw6gIeY6SQHhMxkbv55uj2Sqk,991
|
|
10
10
|
cache_dit/cache_factory/forward_pattern.py,sha256=FumlCuZ-TSmSYH0hGBHctSJ-oGLCftdZjLygqhsmdR4,2258
|
|
11
11
|
cache_dit/cache_factory/utils.py,sha256=XkVM9AXcB9zYq8-S8QKAsGz80r3tA6U3lBNGDGeHOe4,1871
|
|
12
|
-
cache_dit/cache_factory/block_adapters/__init__.py,sha256=
|
|
13
|
-
cache_dit/cache_factory/block_adapters/block_adapters.py,sha256=
|
|
14
|
-
cache_dit/cache_factory/block_adapters/block_registers.py,sha256=
|
|
12
|
+
cache_dit/cache_factory/block_adapters/__init__.py,sha256=33geXMz56TxFWMp0c-H4__MY5SGRzKMKj3TXnUYOMlc,17512
|
|
13
|
+
cache_dit/cache_factory/block_adapters/block_adapters.py,sha256=zZbbsZYWbUClfa6He69w_Wdf8ZLhKwMAb9gURYEUmgQ,23725
|
|
14
|
+
cache_dit/cache_factory/block_adapters/block_registers.py,sha256=2L7QeM4ygnaKQpC9PoJod0QRYyxidUKU2AYpysDCUwE,2572
|
|
15
15
|
cache_dit/cache_factory/cache_blocks/__init__.py,sha256=08Ox7kD05lkRKCOsVTdEZeKAWBheqpxfrAT1Nz7eclI,2916
|
|
16
16
|
cache_dit/cache_factory/cache_blocks/pattern_0_1_2.py,sha256=ElMps6_7uI74tSF9GDR_dEI0bZEhdzcepM29xFWnYo8,428
|
|
17
17
|
cache_dit/cache_factory/cache_blocks/pattern_3_4_5.py,sha256=Bv56qETXhsREvCrNvnZpSqDIIHsi6Ze3FJW4Yk2x3uI,8597
|
|
18
18
|
cache_dit/cache_factory/cache_blocks/pattern_base.py,sha256=d4H9kEB0AgnVMT8aF0Y54SUMUQUxw5HQ8gRkoCuTQ_A,14577
|
|
19
19
|
cache_dit/cache_factory/cache_blocks/utils.py,sha256=dGOC1tMMOvcbvEgx44eTESKn_jsv-0RZ3tRHPa3wmQ4,1315
|
|
20
20
|
cache_dit/cache_factory/cache_contexts/__init__.py,sha256=rqnJ5__zqnpVHK5A1OqWILpNh5Ss-0ZDTGgtxZMKGGo,250
|
|
21
|
-
cache_dit/cache_factory/cache_contexts/cache_context.py,sha256=
|
|
22
|
-
cache_dit/cache_factory/cache_contexts/cache_manager.py,sha256=
|
|
23
|
-
cache_dit/cache_factory/cache_contexts/taylorseer.py,sha256=
|
|
24
|
-
cache_dit/cache_factory/patch_functors/__init__.py,sha256=
|
|
21
|
+
cache_dit/cache_factory/cache_contexts/cache_context.py,sha256=FWdgInClWY8VZBsZIevtYk--rX-RL8c3QfNOJtqR8a4,11855
|
|
22
|
+
cache_dit/cache_factory/cache_contexts/cache_manager.py,sha256=Ig5VKoQ46iG3lKmsaMulYxd2vCm__2rY8NBvERwexwM,32719
|
|
23
|
+
cache_dit/cache_factory/cache_contexts/taylorseer.py,sha256=4nxgSEZvDy-w-7XuJYzsyzdtF1_uFrDwlF06XBDFVKQ,3922
|
|
24
|
+
cache_dit/cache_factory/patch_functors/__init__.py,sha256=oI6F3N9ezahRHaFUOZ1GfrAw1qFdKrxFXXmlwwehHj4,530
|
|
25
25
|
cache_dit/cache_factory/patch_functors/functor_base.py,sha256=Ahk0fTfrHgNdEl-9JSkACvfyyv9G-Ei5OSz7XBIlX5o,357
|
|
26
|
-
cache_dit/cache_factory/patch_functors/functor_chroma.py,sha256=
|
|
26
|
+
cache_dit/cache_factory/patch_functors/functor_chroma.py,sha256=xD0Q96VArp1vYBLQ0pcjRIyFB1i_Y7muZ2q07Hz8Oqs,13430
|
|
27
|
+
cache_dit/cache_factory/patch_functors/functor_dit.py,sha256=SDjhzCWa6PoFNN4_upoQEf6DHvW1yJ7zuXMS2VvyJco,3904
|
|
27
28
|
cache_dit/cache_factory/patch_functors/functor_flux.py,sha256=UMkyuEYjO7UO_zmXi9Djd-nD-XMgCUgE-qkYA3plWSM,9559
|
|
28
29
|
cache_dit/cache_factory/patch_functors/functor_hidream.py,sha256=pi_vvpDy1lsgQHxu3eK3v93rdJL7oNwkt3WakRP8pbw,15375
|
|
29
30
|
cache_dit/cache_factory/patch_functors/functor_hunyuan_dit.py,sha256=iSo5dD5uKnjQQeysDUIkKt0wdnK5bzXTc_F_lfHG70w,6401
|
|
@@ -32,17 +33,19 @@ cache_dit/compile/utils.py,sha256=nN2OIrSdwRR5zGxJinKDqb07pXpvTNTF3g_OgLkeeBU,38
|
|
|
32
33
|
cache_dit/custom_ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
34
|
cache_dit/custom_ops/triton_taylorseer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
35
|
cache_dit/metrics/__init__.py,sha256=RaUhl5dieF40RqnizGzR30qoJJ9dyMUEADwgwMaMQrE,575
|
|
36
|
+
cache_dit/metrics/clip_score.py,sha256=ERNCFQFJKzJdbIX9OAg-1LiSPuXUVHLOFxbf2gcENpc,3938
|
|
35
37
|
cache_dit/metrics/config.py,sha256=ieOgD9ayz722RjVzk24bSIqS2D6o7TZjGk8KeXV-OLQ,551
|
|
36
|
-
cache_dit/metrics/fid.py,sha256=
|
|
38
|
+
cache_dit/metrics/fid.py,sha256=ZM_FM0XERtpnkMUfphmw2aOdljrh1uba-pnYItu0q6M,18219
|
|
39
|
+
cache_dit/metrics/image_reward.py,sha256=N8HalJo1T1js0dsNb2V1KRv4kIdcm3nhx7iOXJuqcns,5421
|
|
37
40
|
cache_dit/metrics/inception.py,sha256=pBVe2X6ylLPIXTG4-GWDM9DWnCviMJbJ45R3ulhktR0,12759
|
|
38
|
-
cache_dit/metrics/lpips.py,sha256=
|
|
39
|
-
cache_dit/metrics/metrics.py,sha256=
|
|
41
|
+
cache_dit/metrics/lpips.py,sha256=hrHrmdM-f2B4TKDs0xLqJO5JFaYcCjq2qNIR8oCrVkc,811
|
|
42
|
+
cache_dit/metrics/metrics.py,sha256=RADSUUMYKBMkABsYFCEr_9PV8cDXLuxe2xuQ-mRBs4Y,39691
|
|
40
43
|
cache_dit/quantize/__init__.py,sha256=kWYoMAyZgBXu9BJlZjTQ0dRffW9GqeeY9_iTkXrb70A,59
|
|
41
44
|
cache_dit/quantize/quantize_ao.py,sha256=Fx1KW4l3gdEkdrcAYtPoDW7WKBJWrs3glOHiEwW_TgE,6160
|
|
42
45
|
cache_dit/quantize/quantize_interface.py,sha256=2s_R7xPSKuJeFpEGeLwRxnq_CqJcBG3a3lzyW5wh-UM,1241
|
|
43
|
-
cache_dit-0.2.
|
|
44
|
-
cache_dit-0.2.
|
|
45
|
-
cache_dit-0.2.
|
|
46
|
-
cache_dit-0.2.
|
|
47
|
-
cache_dit-0.2.
|
|
48
|
-
cache_dit-0.2.
|
|
46
|
+
cache_dit-0.2.36.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
|
|
47
|
+
cache_dit-0.2.36.dist-info/METADATA,sha256=2WIwYYezSUUk0rnIutttA2-s6_yTSCz1BwiAfO9cbQI,42706
|
|
48
|
+
cache_dit-0.2.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
49
|
+
cache_dit-0.2.36.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
|
|
50
|
+
cache_dit-0.2.36.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
|
|
51
|
+
cache_dit-0.2.36.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|