cache-dit 0.2.18__py3-none-any.whl → 0.2.19__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/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.2.18'
32
- __version_tuple__ = version_tuple = (0, 2, 18)
31
+ __version__ = version = '0.2.19'
32
+ __version_tuple__ = version_tuple = (0, 2, 19)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -631,7 +631,8 @@ class UnifiedCacheAdapter:
631
631
  pattern_id = list(unique_pattern_ids)[0]
632
632
  pattern = selected_patterns[pattern_id]
633
633
  logger.info(
634
- f"Match cache pattern: IN({pattern['IN']}, OUT({pattern['OUT']}))"
634
+ f"Match Block Forward Pattern: {transformer_blocks[0].__class__.__name__}"
635
+ f"\n IN({pattern['IN']}, \nOUT({pattern['OUT']}))"
635
636
  )
636
637
 
637
638
  return pattern_matched
@@ -230,7 +230,7 @@ def maybe_patch_flux_transformer(
230
230
  for block in blocks:
231
231
  if isinstance(block, FluxSingleTransformerBlock):
232
232
  forward_parameters = inspect.signature(
233
- blocks.forward
233
+ block.forward
234
234
  ).parameters.keys()
235
235
  if "encoder_hidden_states" not in forward_parameters:
236
236
  block.forward = __patch_single_forward__.__get__(block)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cache_dit
3
- Version: 0.2.18
3
+ Version: 0.2.19
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
@@ -61,16 +61,15 @@ Dynamic: requires-python
61
61
  </p>
62
62
  </div>
63
63
 
64
-
65
64
  ## 🔥News
66
65
 
67
- - [2025-08-19] 🔥[**Qwen-Image-Edit**](https://github.com/QwenLM/Qwen-Image) **~2x⚡️** speedup! Check example [run_qwen_image_edit.py](./examples/run_qwen_image_edit.py).
66
+ - [2025-08-19] 🔥[**Qwen-Image-Edit**](https://github.com/QwenLM/Qwen-Image) **2x⚡️** speedup! Check example [run_qwen_image_edit.py](./examples/run_qwen_image_edit.py).
68
67
  - [2025-08-18] 🎉Early **[Unified Cache APIs](#unified)** released! Check [Qwen-Image w/ UAPI](./examples/run_qwen_image_uapi.py) as an example.
69
68
  - [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 the [PR](https://github.com/QwenLM/Qwen-Image/pull/61).
70
- - [2025-08-11] 🔥[**Qwen-Image**](https://github.com/QwenLM/Qwen-Image) **~1.8x⚡️** speedup! Please refer [run_qwen_image.py](./examples/run_qwen_image.py) as an example.
71
- - [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](./examples/run_flux_kontext.py) as an example.
69
+ - [2025-08-11] 🔥[**Qwen-Image**](https://github.com/QwenLM/Qwen-Image) **1.8x⚡️** speedup! Please refer [run_qwen_image.py](./examples/run_qwen_image.py) as an example.
70
+ - [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](./examples/run_flux_kontext.py) as an example.
72
71
  - [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).
73
- - [2025-07-13] **[🤗flux-faster](https://github.com/xlite-dev/flux-faster)** is released! **3.3x** speedup for FLUX.1 on NVIDIA L20 with `cache-dit`.
72
+ - [2025-07-13] **[🤗flux-faster](https://github.com/xlite-dev/flux-faster)** is released! **3.3x** speedup for FLUX.1 on NVIDIA L20 with **[cache-dit](https://github.com/vipshop/cache-dit)**.
74
73
 
75
74
  ## 📖Contents
76
75
 
@@ -130,28 +129,28 @@ Currently, **cache-dit** library supports almost **Any** Diffusion Transformers
130
129
 
131
130
  <div id="unified"></div>
132
131
 
132
+ Currently, for any **Diffusion** models with **Transformer Blocks** that match the specific **Input/Output patterns**, we can use the **Unified Cache APIs** from **cache-dit**, namely, the `cache_dit.enable_cache(...)` API. The supported patterns are listed as follows:
133
133
 
134
- Currently, for any **Diffusion** models with **Transformer Blocks** that match the specific **Input/Output pattern**, we can use the **Unified Cache APIs** from **cache-dit**. The supported patterns are listed as follows:
135
-
136
- ```bash
134
+ ```python
137
135
  (IN: hidden_states, encoder_hidden_states, ...) -> (OUT: hidden_states, encoder_hidden_states)
138
136
  (IN: hidden_states, encoder_hidden_states, ...) -> (OUT: encoder_hidden_states, hidden_states)
139
137
  (IN: hidden_states, encoder_hidden_states, ...) -> (OUT: hidden_states)
140
138
  (IN: hidden_states, ...) -> (OUT: hidden_states) # TODO, DiT, Lumina2, etc.
141
139
  ```
142
140
 
143
- Please refer to [Qwen-Image w/ UAPI](./examples/run_qwen_image_uapi.py) as an example. The `pipe` parameter can be **Any** Diffusion Pipelines. The **Unified Cache APIs** are currently in the experimental phase, please stay tuned for updates.
141
+ After the `cache_dit.enable_cache(...)` 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](./examples/run_qwen_image_uapi.py) as an example. The **Unified Cache APIs** are currently in the experimental phase; please stay tuned for updates.
144
142
 
145
143
  ```python
146
144
  import cache_dit
147
- from diffusers import DiffusionPipeline # Can be [Any] Diffusion Pipeline
145
+ from diffusers import DiffusionPipeline
148
146
 
147
+ # can be any diffusion pipeline
149
148
  pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image")
150
149
 
151
- # One line code with default cache options.
150
+ # one line code with default cache options.
152
151
  cache_dit.enable_cache(pipe)
153
152
 
154
- # Or, enable cache with custom setting.
153
+ # or, enable cache with custom settings.
155
154
  cache_dit.enable_cache(
156
155
  pipe, transformer=pipe.transformer,
157
156
  blocks=pipe.transformer.transformer_blocks,
@@ -159,28 +158,22 @@ cache_dit.enable_cache(
159
158
  **cache_dit.default_options(),
160
159
  )
161
160
 
162
- # summary cache stats.
163
- cache_dit.summary(pipe)
164
- ```
165
-
166
- After finishing each inference of `pipe(...)`, you can call the `cache_dict.summary` API on pipe to get the details of the cache stats for the current inference (markdown table format). You can set `details` param as `True` to show more details of cache stats.
161
+ # just call the pipe as normal.
162
+ output = pipe(...)
167
163
 
168
- ```bash
169
- 🤗Cache Options: QwenImagePipeline
164
+ # then, summary the cache stats.
165
+ stats = cache_dit.summary(pipe)
166
+ ```
170
167
 
171
- {'Fn_compute_blocks': 8, 'Bn_compute_blocks': 0, 'non_compute_blocks_diff_threshold': 0.08, 'max_Fn_compute_blocks': -1, 'max_Bn_compute_blocks': -1, 'residual_diff_threshold': 0.12, 'l1_hidden_states_diff_threshold': None, 'important_condition_threshold': 0.0, 'enable_alter_cache': False, 'is_alter_cache': True, 'alter_residual_diff_threshold': 1.0, 'downsample_factor': 1, 'num_inference_steps': -1, 'warmup_steps': 8, 'max_cached_steps': -1, 'executed_steps': 0, 'transformer_executed_steps': 0, 'enable_taylorseer': True, 'enable_encoder_taylorseer': True, 'taylorseer_cache_type': 'residual', 'taylorseer': None, 'encoder_tarlorseer': None, 'do_separate_classifier_free_guidance': True, 'cfg_compute_first': False, 'cfg_diff_compute_separate': True, 'cfg_taylorseer': None, 'cfg_encoder_taylorseer': None, 'Fn_compute_blocks_ids': [], 'Bn_compute_blocks_ids': [], 'taylorseer_kwargs': {'n_derivatives': 4, 'warmup_steps': 8}}
168
+ After finishing each inference of `pipe(...)`, you can call the `cache_dit.summary(...)` API on pipe to get the details of the cache stats for the current inference (markdown table format). You can set `details` param as `True` to show more details of cache stats.
172
169
 
170
+ ```python
173
171
  ⚡️Cache Steps and Residual Diffs Statistics: QwenImagePipeline
174
172
 
175
173
  | Cache Steps | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 |
176
174
  |-------------|-----------|-----------|-----------|-----------|-----------|
177
175
  | 23 | 0.04 | 0.082 | 0.115 | 0.152 | 0.245 |
178
-
179
- ⚡️CFG Cache Steps and Residual Diffs Statistics: QwenImagePipeline
180
-
181
- | CFG Cache Steps | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 |
182
- |-----------------|-----------|-----------|-----------|-----------|-----------|
183
- | 22 | 0.045 | 0.077 | 0.112 | 0.148 | 0.245 |
176
+ ...
184
177
  ```
185
178
 
186
179
  ## ⚡️DBCache: Dual Block Cache
@@ -1,17 +1,17 @@
1
1
  cache_dit/__init__.py,sha256=TvZI861ipGnYaOEHJA0Og-ksRUGNCld-PGy_NgjcKZE,641
2
- cache_dit/_version.py,sha256=dCdYCOiddErhHj0N8E7eGD9CFxW2AjdU7N-JosKZW0o,706
2
+ cache_dit/_version.py,sha256=32XF9c5EeiOUdyiWeKcwkXTWZQBgtvbmKx8wZoDEW0o,706
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/utils.py,sha256=yybhUTGPfeCoIVZzpoefZ2ypvH8de-10UhPls81ceG4,4800
6
6
  cache_dit/cache_factory/.gitignore,sha256=5Cb-qT9wsTUoMJ7vACDF7ZcLpAXhi5v-xdcWSRit988,23
7
7
  cache_dit/cache_factory/__init__.py,sha256=f4IUOgEALTEBb9UOHtXoGwqKrDb2ZhI_dHkiIrni1Xc,1586
8
- cache_dit/cache_factory/cache_adapters.py,sha256=twzxe6VYB-9iRwU1Fct15mm5pdPNOyqBoLRBscnYZHA,23508
8
+ cache_dit/cache_factory/cache_adapters.py,sha256=-bFMOfIPdfWKTAfF533PuLYaDl1wq8RNUAXJn--Rm7I,23587
9
9
  cache_dit/cache_factory/cache_blocks.py,sha256=9jgK2IT0Y_AlbhJLnhgA47lOxQNwNizDgHve45818gg,18390
10
10
  cache_dit/cache_factory/cache_context.py,sha256=f-ihx14NXIZNakN2b_dduegRpJr5SwcPtc2PqnpDdUY,39818
11
11
  cache_dit/cache_factory/taylorseer.py,sha256=LKSNo2ode69EVo9xrxjxAMEjz0yDGiGADeDYnEqddA8,3987
12
12
  cache_dit/cache_factory/utils.py,sha256=iQg3dqBfQTGkvMdKeO5-YmzkQO5LBSoZ8sYKwQA_7_I,1805
13
13
  cache_dit/cache_factory/patch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- cache_dit/cache_factory/patch/flux.py,sha256=eTdq-3limKHgwtVCILkZTwt9FwYUhH7_VlhKnfu55BU,8999
14
+ cache_dit/cache_factory/patch/flux.py,sha256=iNQ-1RlOgXupZ4uPiEvJ__Ro6vKT_fOKja9JrpMrO78,8998
15
15
  cache_dit/compile/__init__.py,sha256=FcTVzCeyypl-mxlc59_ehHL3lBNiDAFsXuRoJ-5Cfi0,56
16
16
  cache_dit/compile/utils.py,sha256=ugHrv3QRieG1xKwcg_pi3yVZF6EpSOEJjRmbnfa7VG0,3779
17
17
  cache_dit/custom_ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -22,9 +22,9 @@ cache_dit/metrics/fid.py,sha256=9Ivtazl6mW0Bon2VXa-Ia5Xj2ewxRD3V1Qkd69zYM3Y,1706
22
22
  cache_dit/metrics/inception.py,sha256=pBVe2X6ylLPIXTG4-GWDM9DWnCviMJbJ45R3ulhktR0,12759
23
23
  cache_dit/metrics/lpips.py,sha256=I2qCNi6qJh5TRsaIsdxO0WoRX1DN7U_H3zS0oCSahYM,1032
24
24
  cache_dit/metrics/metrics.py,sha256=8jvM1sF-nDxUuwCRy44QEoo4dYVLCQVh1QyAMs4eaQY,27840
25
- cache_dit-0.2.18.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
26
- cache_dit-0.2.18.dist-info/METADATA,sha256=8U_a77k97X2b_nV1X7VDjusKLAAnAbHA-6eYhJ4wiqA,21940
27
- cache_dit-0.2.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
- cache_dit-0.2.18.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
29
- cache_dit-0.2.18.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
30
- cache_dit-0.2.18.dist-info/RECORD,,
25
+ cache_dit-0.2.19.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
26
+ cache_dit-0.2.19.dist-info/METADATA,sha256=cCnv_b_F06xdttqdHhnbmPDpF_xRgz-O03tYfvzGGrI,20910
27
+ cache_dit-0.2.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
+ cache_dit-0.2.19.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
29
+ cache_dit-0.2.19.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
30
+ cache_dit-0.2.19.dist-info/RECORD,,