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

Files changed (29) hide show
  1. cache_dit/__init__.py +3 -0
  2. cache_dit/_version.py +2 -2
  3. cache_dit/cache_factory/__init__.py +8 -1
  4. cache_dit/cache_factory/cache_adapters/cache_adapter.py +90 -76
  5. cache_dit/cache_factory/cache_blocks/__init__.py +167 -17
  6. cache_dit/cache_factory/cache_blocks/pattern_0_1_2.py +10 -0
  7. cache_dit/cache_factory/cache_blocks/pattern_3_4_5.py +271 -36
  8. cache_dit/cache_factory/cache_blocks/pattern_base.py +286 -45
  9. cache_dit/cache_factory/cache_blocks/pattern_utils.py +55 -10
  10. cache_dit/cache_factory/cache_contexts/__init__.py +15 -2
  11. cache_dit/cache_factory/cache_contexts/cache_config.py +102 -0
  12. cache_dit/cache_factory/cache_contexts/cache_context.py +26 -89
  13. cache_dit/cache_factory/cache_contexts/cache_manager.py +7 -7
  14. cache_dit/cache_factory/cache_contexts/calibrators/taylorseer.py +78 -8
  15. cache_dit/cache_factory/cache_contexts/context_manager.py +29 -0
  16. cache_dit/cache_factory/cache_contexts/prune_config.py +69 -0
  17. cache_dit/cache_factory/cache_contexts/prune_context.py +155 -0
  18. cache_dit/cache_factory/cache_contexts/prune_manager.py +154 -0
  19. cache_dit/cache_factory/cache_interface.py +23 -14
  20. cache_dit/cache_factory/cache_types.py +19 -2
  21. cache_dit/cache_factory/params_modifier.py +7 -7
  22. cache_dit/cache_factory/utils.py +38 -27
  23. cache_dit/utils.py +191 -54
  24. {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/METADATA +14 -7
  25. {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/RECORD +29 -24
  26. {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/WHEEL +0 -0
  27. {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/entry_points.txt +0 -0
  28. {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/licenses/LICENSE +0 -0
  29. {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/top_level.txt +0 -0
cache_dit/utils.py CHANGED
@@ -39,12 +39,22 @@ def is_diffusers_at_least_0_3_5() -> bool:
39
39
  @dataclasses.dataclass
40
40
  class CacheStats:
41
41
  cache_options: dict = dataclasses.field(default_factory=dict)
42
+ # Dual Block Cache
42
43
  cached_steps: list[int] = dataclasses.field(default_factory=list)
43
44
  residual_diffs: dict[str, float] = dataclasses.field(default_factory=dict)
44
45
  cfg_cached_steps: list[int] = dataclasses.field(default_factory=list)
45
46
  cfg_residual_diffs: dict[str, float] = dataclasses.field(
46
47
  default_factory=dict
47
48
  )
49
+ # Dynamic Block Prune
50
+ pruned_steps: list[int] = dataclasses.field(default_factory=list)
51
+ pruned_blocks: list[int] = dataclasses.field(default_factory=list)
52
+ actual_blocks: list[int] = dataclasses.field(default_factory=list)
53
+ pruned_ratio: float = None
54
+ cfg_pruned_steps: list[int] = dataclasses.field(default_factory=list)
55
+ cfg_pruned_blocks: list[int] = dataclasses.field(default_factory=list)
56
+ cfg_actual_blocks: list[int] = dataclasses.field(default_factory=list)
57
+ cfg_pruned_ratio: float = None
48
58
 
49
59
 
50
60
  def summary(
@@ -165,7 +175,7 @@ def strify(
165
175
  cached_steps = len(stats.cached_steps)
166
176
  elif isinstance(adapter_or_others, dict):
167
177
 
168
- # Assume cache_context_kwargs
178
+ # Assume context_kwargs
169
179
  cache_options = adapter_or_others
170
180
  cached_steps = None
171
181
  cache_type = cache_options.get("cache_type", CacheType.NONE)
@@ -181,10 +191,18 @@ def strify(
181
191
  if not cache_options:
182
192
  return "NONE"
183
193
 
184
- def basic_cache_str():
194
+ def cache_str():
185
195
  cache_config: BasicCacheConfig = cache_options.get("cache_config", None)
186
196
  if cache_config is not None:
187
- return cache_config.strify()
197
+ if cache_config.cache_type == CacheType.NONE:
198
+ return "NONE"
199
+ elif cache_config.cache_type == CacheType.DBCache:
200
+ return cache_config.strify()
201
+ elif cache_config.cache_type == CacheType.DBPrune:
202
+ pruned_ratio = stats.pruned_ratio
203
+ if pruned_ratio is not None:
204
+ return f"{cache_config.strify()}_P{round(pruned_ratio * 100, 2)}"
205
+ return cache_config.strify()
188
206
  return "NONE"
189
207
 
190
208
  def calibrator_str():
@@ -195,7 +213,7 @@ def strify(
195
213
  return calibrator_config.strify()
196
214
  return "T0O0"
197
215
 
198
- cache_type_str = f"{basic_cache_str()}_{calibrator_str()}"
216
+ cache_type_str = f"{cache_str()}_{calibrator_str()}"
199
217
 
200
218
  if cached_steps:
201
219
  cache_type_str += f"_S{cached_steps}"
@@ -225,23 +243,42 @@ def _summary(
225
243
  if isinstance(module, torch.nn.ModuleList):
226
244
  cls_name = module[0].__class__.__name__
227
245
 
228
- if hasattr(module, "_cache_context_kwargs"):
229
- cache_options = module._cache_context_kwargs
246
+ if hasattr(module, "_context_kwargs"):
247
+ cache_options = module._context_kwargs
230
248
  cache_stats.cache_options = cache_options
231
249
  if logging:
232
- print(f"\n🤗Cache Options: {cls_name}\n\n{cache_options}")
250
+ print(f"\n🤗Context Options: {cls_name}\n\n{cache_options}")
233
251
  else:
234
252
  if logging:
235
- logger.warning(f"Can't find Cache Options for: {cls_name}")
253
+ logger.warning(f"Can't find Context Options for: {cls_name}")
236
254
 
237
255
  if hasattr(module, "_cached_steps"):
238
256
  cached_steps: list[int] = module._cached_steps
239
- residual_diffs: dict[str, float] = dict(module._residual_diffs)
257
+ residual_diffs: dict[str, list | float] = dict(module._residual_diffs)
258
+
259
+ if hasattr(module, "_pruned_steps"):
260
+ pruned_steps: list[int] = module._pruned_steps
261
+ pruned_blocks: list[int] = module._pruned_blocks
262
+ actual_blocks: list[int] = module._actual_blocks
263
+ pruned_ratio: float = module._pruned_ratio
264
+ else:
265
+ pruned_steps = []
266
+ pruned_blocks = []
267
+ actual_blocks = []
268
+ pruned_ratio = None
269
+
240
270
  cache_stats.cached_steps = cached_steps
241
271
  cache_stats.residual_diffs = residual_diffs
242
272
 
273
+ cache_stats.pruned_steps = pruned_steps
274
+ cache_stats.pruned_blocks = pruned_blocks
275
+ cache_stats.actual_blocks = actual_blocks
276
+ cache_stats.pruned_ratio = pruned_ratio
277
+
243
278
  if residual_diffs and logging:
244
279
  diffs_values = list(residual_diffs.values())
280
+ if isinstance(diffs_values[0], list):
281
+ diffs_values = [v for sublist in diffs_values for v in sublist]
245
282
  qmin = np.min(diffs_values)
246
283
  q0 = np.percentile(diffs_values, 0)
247
284
  q1 = np.percentile(diffs_values, 25)
@@ -250,41 +287,103 @@ def _summary(
250
287
  q4 = np.percentile(diffs_values, 95)
251
288
  qmax = np.max(diffs_values)
252
289
 
253
- print(
254
- f"\n⚡️Cache Steps and Residual Diffs Statistics: {cls_name}\n"
255
- )
290
+ if pruned_ratio is not None:
291
+ print(
292
+ f"\n⚡️Pruned Blocks and Residual Diffs Statistics: {cls_name}\n"
293
+ )
256
294
 
257
- print(
258
- "| Cache Steps | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Min | Diffs Max |"
259
- )
260
- print(
261
- "|-------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|"
262
- )
263
- print(
264
- f"| {len(cached_steps):<11} | {round(q0, 3):<9} | {round(q1, 3):<9} "
265
- f"| {round(q2, 3):<9} | {round(q3, 3):<9} | {round(q4, 3):<9} "
266
- f"| {round(qmin, 3):<9} | {round(qmax, 3):<9} |"
267
- )
268
- print("")
295
+ print(
296
+ "| Pruned Blocks | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Min | Diffs Max |"
297
+ )
298
+ print(
299
+ "|---------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|"
300
+ )
301
+ print(
302
+ f"| {sum(pruned_blocks):<13} | {round(q0, 3):<9} | {round(q1, 3):<9} "
303
+ f"| {round(q2, 3):<9} | {round(q3, 3):<9} | {round(q4, 3):<9} "
304
+ f"| {round(qmin, 3):<9} | {round(qmax, 3):<9} |"
305
+ )
306
+ print("")
307
+ else:
308
+ print(
309
+ f"\n⚡️Cache Steps and Residual Diffs Statistics: {cls_name}\n"
310
+ )
269
311
 
270
- if details:
271
- print(f"📚Cache Steps and Residual Diffs Details: {cls_name}\n")
272
- pprint(
273
- f"Cache Steps: {len(cached_steps)}, {cached_steps}",
312
+ print(
313
+ "| Cache Steps | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Min | Diffs Max |"
314
+ )
315
+ print(
316
+ "|-------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|"
274
317
  )
275
- pprint(
276
- f"Residual Diffs: {len(residual_diffs)}, {residual_diffs}",
277
- compact=True,
318
+ print(
319
+ f"| {len(cached_steps):<11} | {round(q0, 3):<9} | {round(q1, 3):<9} "
320
+ f"| {round(q2, 3):<9} | {round(q3, 3):<9} | {round(q4, 3):<9} "
321
+ f"| {round(qmin, 3):<9} | {round(qmax, 3):<9} |"
322
+ )
323
+ print("")
324
+
325
+ if pruned_ratio is not None:
326
+ print(
327
+ f"Dynamic Block Prune Ratio: {round(pruned_ratio * 100, 2)}% ({sum(pruned_blocks)}/{sum(actual_blocks)})\n"
278
328
  )
279
329
 
330
+ if details:
331
+ if pruned_ratio is not None:
332
+ print(
333
+ f"📚Pruned Blocks and Residual Diffs Details: {cls_name}\n"
334
+ )
335
+ pprint(
336
+ f"Pruned Blocks: {len(pruned_blocks)}, {pruned_blocks}",
337
+ )
338
+ pprint(
339
+ f"Actual Blocks: {len(actual_blocks)}, {actual_blocks}",
340
+ )
341
+ pprint(
342
+ f"Residual Diffs: {len(residual_diffs)}, {residual_diffs}",
343
+ compact=True,
344
+ )
345
+ else:
346
+ print(
347
+ f"📚Cache Steps and Residual Diffs Details: {cls_name}\n"
348
+ )
349
+ pprint(
350
+ f"Cache Steps: {len(cached_steps)}, {cached_steps}",
351
+ )
352
+ pprint(
353
+ f"Residual Diffs: {len(residual_diffs)}, {residual_diffs}",
354
+ compact=True,
355
+ )
356
+
280
357
  if hasattr(module, "_cfg_cached_steps"):
281
358
  cfg_cached_steps: list[int] = module._cfg_cached_steps
282
- cfg_residual_diffs: dict[str, float] = dict(module._cfg_residual_diffs)
359
+ cfg_residual_diffs: dict[str, list | float] = dict(
360
+ module._cfg_residual_diffs
361
+ )
362
+
363
+ if hasattr(module, "_cfg_pruned_steps"):
364
+ cfg_pruned_steps: list[int] = module._cfg_pruned_steps
365
+ cfg_pruned_blocks: list[int] = module._cfg_pruned_blocks
366
+ cfg_actual_blocks: list[int] = module._cfg_actual_blocks
367
+ cfg_pruned_ratio: float = module._cfg_pruned_ratio
368
+ else:
369
+ cfg_pruned_steps = []
370
+ cfg_pruned_blocks = []
371
+ cfg_actual_blocks = []
372
+ cfg_pruned_ratio = None
373
+
283
374
  cache_stats.cfg_cached_steps = cfg_cached_steps
284
375
  cache_stats.cfg_residual_diffs = cfg_residual_diffs
376
+ cache_stats.cfg_pruned_steps = cfg_pruned_steps
377
+ cache_stats.cfg_pruned_blocks = cfg_pruned_blocks
378
+ cache_stats.cfg_actual_blocks = cfg_actual_blocks
379
+ cache_stats.cfg_pruned_ratio = cfg_pruned_ratio
285
380
 
286
381
  if cfg_residual_diffs and logging:
287
382
  cfg_diffs_values = list(cfg_residual_diffs.values())
383
+ if isinstance(cfg_diffs_values[0], list):
384
+ cfg_diffs_values = [
385
+ v for sublist in cfg_diffs_values for v in sublist
386
+ ]
288
387
  qmin = np.min(cfg_diffs_values)
289
388
  q0 = np.percentile(cfg_diffs_values, 0)
290
389
  q1 = np.percentile(cfg_diffs_values, 25)
@@ -293,33 +392,71 @@ def _summary(
293
392
  q4 = np.percentile(cfg_diffs_values, 95)
294
393
  qmax = np.max(cfg_diffs_values)
295
394
 
296
- print(
297
- f"\n⚡️CFG Cache Steps and Residual Diffs Statistics: {cls_name}\n"
298
- )
395
+ if cfg_pruned_ratio is not None:
396
+ print(
397
+ f"\n⚡️CFG Pruned Blocks and Residual Diffs Statistics: {cls_name}\n"
398
+ )
299
399
 
300
- print(
301
- "| CFG Cache Steps | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Min | Diffs Max |"
302
- )
303
- print(
304
- "|-----------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|"
305
- )
306
- print(
307
- f"| {len(cfg_cached_steps):<15} | {round(q0, 3):<9} | {round(q1, 3):<9} "
308
- f"| {round(q2, 3):<9} | {round(q3, 3):<9} | {round(q4, 3):<9} "
309
- f"| {round(qmin, 3):<9} | {round(qmax, 3):<9} |"
310
- )
311
- print("")
400
+ print(
401
+ "| CFG Pruned Blocks | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Min | Diffs Max |"
402
+ )
403
+ print(
404
+ "|-------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|"
405
+ )
406
+ print(
407
+ f"| {sum(cfg_pruned_blocks):<18} | {round(q0, 3):<9} | {round(q1, 3):<9} "
408
+ f"| {round(q2, 3):<9} | {round(q3, 3):<9} | {round(q4, 3):<9} "
409
+ f"| {round(qmin, 3):<9} | {round(qmax, 3):<9} |"
410
+ )
411
+ print("")
412
+ else:
413
+ print(
414
+ f"\n⚡️CFG Cache Steps and Residual Diffs Statistics: {cls_name}\n"
415
+ )
312
416
 
313
- if details:
314
417
  print(
315
- f"📚CFG Cache Steps and Residual Diffs Details: {cls_name}\n"
418
+ "| CFG Cache Steps | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Min | Diffs Max |"
316
419
  )
317
- pprint(
318
- f"CFG Cache Steps: {len(cfg_cached_steps)}, {cfg_cached_steps}",
420
+ print(
421
+ "|-----------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|"
319
422
  )
320
- pprint(
321
- f"CFG Residual Diffs: {len(cfg_residual_diffs)}, {cfg_residual_diffs}",
322
- compact=True,
423
+ print(
424
+ f"| {len(cfg_cached_steps):<15} | {round(q0, 3):<9} | {round(q1, 3):<9} "
425
+ f"| {round(q2, 3):<9} | {round(q3, 3):<9} | {round(q4, 3):<9} "
426
+ f"| {round(qmin, 3):<9} | {round(qmax, 3):<9} |"
323
427
  )
428
+ print("")
429
+
430
+ if cfg_pruned_ratio is not None:
431
+ print(
432
+ f"CFG Dynamic Block Prune Ratio: {round(cfg_pruned_ratio * 100, 2)}% ({sum(cfg_pruned_blocks)}/{sum(cfg_actual_blocks)})\n"
433
+ )
434
+
435
+ if details:
436
+ if cfg_pruned_ratio is not None:
437
+ print(
438
+ f"📚CFG Pruned Blocks and Residual Diffs Details: {cls_name}\n"
439
+ )
440
+ pprint(
441
+ f"CFG Pruned Blocks: {len(cfg_pruned_blocks)}, {cfg_pruned_blocks}",
442
+ )
443
+ pprint(
444
+ f"CFG Actual Blocks: {len(cfg_actual_blocks)}, {cfg_actual_blocks}",
445
+ )
446
+ pprint(
447
+ f"CFG Residual Diffs: {len(cfg_residual_diffs)}, {cfg_residual_diffs}",
448
+ compact=True,
449
+ )
450
+ else:
451
+ print(
452
+ f"📚CFG Cache Steps and Residual Diffs Details: {cls_name}\n"
453
+ )
454
+ pprint(
455
+ f"CFG Cache Steps: {len(cfg_cached_steps)}, {cfg_cached_steps}",
456
+ )
457
+ pprint(
458
+ f"CFG Residual Diffs: {len(cfg_residual_diffs)}, {cfg_residual_diffs}",
459
+ compact=True,
460
+ )
324
461
 
325
462
  return cache_stats
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cache_dit
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: A Unified, Flexible and Training-free Cache Acceleration Framework for 🤗Diffusers.
5
5
  Author: DefTruth, vipshop.com, etc.
6
6
  Maintainer: DefTruth, vipshop.com, etc
@@ -171,7 +171,7 @@ Dynamic: requires-python
171
171
  ## 🔥Hightlight <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit"><img src=https://img.shields.io/badge/🤗Diffusers-ecosystem-yellow.svg ></a>
172
172
 
173
173
  We are excited to announce that the **first API-stable version (v1.0.0)** of cache-dit has finally been released!
174
- **[cache-dit](https://github.com/vipshop/cache-dit)** is a **Unified**, **Flexible**, and **Training-free** cache acceleration framework for 🤗 Diffusers, enabling cache acceleration with just **one line** of code. Key features include **Unified Cache APIs**, **Forward Pattern Matching**, **Automatic Block Adapter**, **Hybrid Forward Pattern**, **DBCache**, **TaylorSeer Calibrator**, and **Cache CFG**.
174
+ **[cache-dit](https://github.com/vipshop/cache-dit)** is a **Unified**, **Flexible**, and **Training-free** cache acceleration framework for 🤗 Diffusers, enabling cache acceleration with just **one line** of code. Key features: **Unified Cache APIs**, **Forward Pattern Matching**, **Automatic Block Adapter**, **Hybrid Forward Pattern**, **DBCache**, **DBPrune**, **TaylorSeer Calibrator**, and **Cache CFG**.
175
175
 
176
176
  ```bash
177
177
  pip3 install -U cache-dit # pip3 install git+https://github.com/vipshop/cache-dit.git
@@ -189,19 +189,20 @@ You can install the stable release of cache-dit from PyPI, or the latest develop
189
189
 
190
190
  ### 📚Core Features
191
191
 
192
- - **[🎉Full 🤗Diffusers Support](./docs/User_Guide.md#supported-pipelines)**: Notably, **[cache-dit](https://github.com/vipshop/cache-dit)** now supports nearly **all** of Diffusers' **DiT-based** pipelines, such as Qwen-Image, FLUX.1, Qwen-Image-Lightning, HunyuanImage-2.1, HunyuanVideo, HunyuanDiT, Wan 2.1/2.2, HiDream, AuraFlow, CogView3Plus, CogView4, LTXVideo, CogVideoX 1.5, ConsisID, SkyReelsV2, VisualCloze, OmniGen, Lumina, PixArt, Chroma, Sana, Allegro, Mochi, SD 3.5, Amused, and DiT-XL.
192
+ - **[🎉Full 🤗Diffusers Support](./docs/User_Guide.md#supported-pipelines)**: Notably, **[cache-dit](https://github.com/vipshop/cache-dit)** now supports nearly **all** of Diffusers' **DiT-based** pipelines, include **[30+](./examples/pipeline/)** series, nearly **[100+](./examples/pipeline/)** pipelines, such as FLUX.1, Qwen-Image, Qwen-Image-Lightning, Wan 2.1/2.2, HunyuanImage-2.1, HunyuanVideo, HiDream, AuraFlow, CogView3Plus, CogView4, CogVideoX, LTXVideo, ConsisID, SkyReelsV2, VisualCloze, PixArt, Chroma, Mochi, SD 3.5, DiT-XL, etc.
193
193
  - **[🎉Extremely Easy to Use](./docs/User_Guide.md#unified-cache-apis)**: In most cases, you only need **one line** of code: `cache_dit.enable_cache(...)`. After calling this API, just use the pipeline as normal.
194
194
  - **[🎉Easy New Model Integration](./docs/User_Guide.md#automatic-block-adapter)**: Features like **Unified Cache APIs**, **Forward Pattern Matching**, **Automatic Block Adapter**, **Hybrid Forward Pattern**, and **Patch Functor** make it highly functional and flexible. For example, we achieved 🎉 Day 1 support for [HunyuanImage-2.1](https://github.com/Tencent-Hunyuan/HunyuanImage-2.1) with 1.7x speedup w/o precision loss—even before it was available in the Diffusers library.
195
- - **[🎉State-of-the-Art Performance](./bench/)**: Compared with algorithms including Δ-DiT, Chipmunk, FORA, DuCa, TaylorSeer and FoCa, cache-dit achieves the best accuracy when the speedup ratio is below 4x.
195
+ - **[🎉State-of-the-Art Performance](./bench/)**: Compared with algorithms including Δ-DiT, Chipmunk, FORA, DuCa, TaylorSeer and FoCa, cache-dit achieved the **SOTA** performance w/ **7.4x↑🎉** speedup on ClipScore!
196
196
  - **[🎉Support for 4/8-Steps Distilled Models](./bench/)**: Surprisingly, cache-dit's **DBCache** works for extremely few-step distilled models—something many other methods fail to do.
197
197
  - **[🎉Compatibility with Other Optimizations](./docs/User_Guide.md#️torch-compile)**: Designed to work seamlessly with torch.compile, model CPU offload, sequential CPU offload, group offloading, etc.
198
- - **[🎉Hybrid Cache Acceleration](./docs/User_Guide.md#taylorseer-calibrator)**: Now supports hybrid **DBCache + Calibrator** schemes (e.g., DBCache + TaylorSeerCalibrator). DBCache acts as the **Indicator** to decide *when* to cache, while the Calibrator decides *how* to cache. More mainstream cache acceleration algorithms (e.g., FoCa) will be supported in the future, along with additional benchmarks—stay tuned for updates!
198
+ - **[🎉Hybrid Cache Acceleration](./docs/User_Guide.md#taylorseer-calibrator)**: Now supports hybrid **Block-wise Cache + Calibrator** schemes (e.g., DBCache or DBPrune + TaylorSeerCalibrator). DBCache or DBPrune acts as the **Indicator** to decide *when* to cache, while the Calibrator decides *how* to cache. More mainstream cache acceleration algorithms (e.g., FoCa) will be supported in the future, along with additional benchmarks—stay tuned for updates!
199
199
  - **[🤗Diffusers Ecosystem Integration](https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit)**: 🔥**cache-dit** has joined the Diffusers community ecosystem as the **first** DiT-specific cache acceleration framework! Check out the documentation here: <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit"><img src=https://img.shields.io/badge/🤗Diffusers-ecosystem-yellow.svg ></a>
200
200
 
201
- ![image-reward-bench](https://github.com/vipshop/cache-dit/raw/main/assets/image-reward-bench.png)
201
+ ![](https://github.com/vipshop/cache-dit/raw/main/assets/clip-score-bench.png)
202
202
 
203
203
  ## 🔥Important News
204
204
 
205
+ - 2025.10.13: 🎉cache-dit achieved the **SOTA** performance w/ **7.4x↑🎉** speedup on ClipScore!
205
206
  - 2025.10.10: 🔥[**Qwen-Image-ControlNet-Inpainting**](https://huggingface.co/InstantX/Qwen-Image-ControlNet-Inpainting) **2.3x↑🎉** speedup! Check the [example](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image_controlnet_inpaint.py).
206
207
  - 2025.09.26: 🔥[**Qwen-Image-Edit-Plus(2509)**](https://github.com/QwenLM/Qwen-Image) **2.1x↑🎉** speedup! Please check the [example](https://github.com/vipshop/cache-dit/blob/main/examples/pipeline/run_qwen_image_edit_plus.py).
207
208
  - 2025.09.25: 🎉The **first API-stable version (v1.0.0)** of cache-dit has finally been released!
@@ -240,7 +241,8 @@ For more advanced features such as **Unified Cache APIs**, **Forward Pattern Mat
240
241
  - [📚Hybird Forward Pattern](./docs/User_Guide.md#hybird-forward-pattern)
241
242
  - [📚Implement Patch Functor](./docs/User_Guide.md#implement-patch-functor)
242
243
  - [🤖Cache Acceleration Stats](./docs/User_Guide.md#cache-acceleration-stats-summary)
243
- - [⚡️Dual Block Cache](./docs/User_Guide.md#️dbcache-dual-block-cache)
244
+ - [⚡️DBCache: Dual Block Cache](./docs/User_Guide.md#️dbcache-dual-block-cache)
245
+ - [⚡️DBPrune: Dynamic Block Prune](./docs/User_Guide.md#️dbprune-dynamic-block-prune)
244
246
  - [🔥TaylorSeer Calibrator](./docs/User_Guide.md#taylorseer-calibrator)
245
247
  - [⚡️Hybrid Cache CFG](./docs/User_Guide.md#️hybrid-cache-cfg)
246
248
  - [🛠Metrics CLI](./docs/User_Guide.md#metrics-cli)
@@ -260,8 +262,13 @@ How to contribute? Star ⭐️ this repo to support us or check [CONTRIBUTE.md](
260
262
  <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=vipshop/cache-dit&type=Date" width=400px />
261
263
  </picture>
262
264
  </a>
265
+
263
266
  </div>
264
267
 
268
+ ## 🎉Projects Using CacheDiT
269
+
270
+ Here is a curated list of open-source projects integrating **CacheDiT**, including popular repositories like [jetson-containers](https://github.com/dusty-nv/jetson-containers/blob/master/packages/diffusion/cache_edit/build.sh) ![](https://img.shields.io/github/stars/dusty-nv/jetson-containers.svg), [flux-fast](https://github.com/huggingface/flux-fast) ![](https://img.shields.io/github/stars/huggingface/flux-fast.svg), and [sdnext](https://github.com/vladmandic/sdnext/blob/dev/modules/cachedit.py) ![](https://img.shields.io/github/stars/vladmandic/sdnext.svg). **CacheDiT** has also been **recommended** by [Wan2.2](https://github.com/Wan-Video/Wan2.2) ![](https://img.shields.io/github/stars/Wan-Video/Wan2.2.svg), [Qwen-Image-Lightning](https://github.com/ModelTC/Qwen-Image-Lightning) ![](https://img.shields.io/github/stars/ModelTC/Qwen-Image-Lightning.svg), [Qwen-Image](https://github.com/QwenLM/Qwen-Image) ![](https://img.shields.io/github/stars/QwenLM/Qwen-Image.svg), and <a href="https://huggingface.co/docs/diffusers/main/en/optimization/cache_dit"><img src="https://img.shields.io/badge/🤗Diffusers-ecosystem-yellow.svg"></a> ![](https://img.shields.io/github/stars/huggingface/diffusers.svg), among others. We would be grateful if you could let us know if you have used CacheDiT.
271
+
265
272
  ## ©️Acknowledgements
266
273
 
267
274
  <div id="Acknowledgements"></div>
@@ -1,32 +1,37 @@
1
- cache_dit/__init__.py,sha256=sHRg0swXZZiw6lvSQ53fcVtN9JRayx0az2lXAz5OOGI,1510
2
- cache_dit/_version.py,sha256=ZTgKq8LPNy3l9uR2ke-VtLhvvl5l71frQ9wO76n1L5k,704
1
+ cache_dit/__init__.py,sha256=JQLxwr5aqoMFp-BNR58J0i6NutbRmNXKsaRJKCZQDCg,1638
2
+ cache_dit/_version.py,sha256=jp1Oow7okdi1HqeKIp8SmyysmUf-oq2X9syICfrgATI,704
3
3
  cache_dit/logger.py,sha256=0zsu42hN-3-rgGC_C29ms1IvVpV4_b4_SwJCKSenxBE,4304
4
- cache_dit/utils.py,sha256=AyYRwi5XBxYBH4GaXxOxv9-X24Te_IYOYwh54t_1d3A,10674
4
+ cache_dit/utils.py,sha256=0YNFr84pxYoHOCZvnONKKXYN3PZY4kao9Tq2yEfHHR8,16986
5
5
  cache_dit/cache_factory/.gitignore,sha256=5Cb-qT9wsTUoMJ7vACDF7ZcLpAXhi5v-xdcWSRit988,23
6
- cache_dit/cache_factory/__init__.py,sha256=vy9I6Ofkj9jWeUoOvh-cY5a9QlDDKfj2FVPlVTf7BeA,1390
7
- cache_dit/cache_factory/cache_interface.py,sha256=KseSPyZ9D3m6pmpE7k-uYr0wfBI-hhscG1Nw54GCHxk,12316
8
- cache_dit/cache_factory/cache_types.py,sha256=ooukxQRG55uTLmaZ0SKw6gIeY6SQHhMxkbv55uj2Sqk,991
6
+ cache_dit/cache_factory/__init__.py,sha256=5UjrpxLVlmjHttTL0O14fD5oU5uKI3FKYevL613ibFQ,1848
7
+ cache_dit/cache_factory/cache_interface.py,sha256=spiE7pWF80G3Y06_TKVvrmKufbAvQmyvshZZVsmb-nM,12714
8
+ cache_dit/cache_factory/cache_types.py,sha256=QnWfaS52UOXQtnoCUOwwz4ziY0dyBta6vQ6hvgtdV44,1404
9
9
  cache_dit/cache_factory/forward_pattern.py,sha256=FumlCuZ-TSmSYH0hGBHctSJ-oGLCftdZjLygqhsmdR4,2258
10
- cache_dit/cache_factory/params_modifier.py,sha256=zYJJsInTYCaYHBZ7mZJOP-PZnkSg3iN1WPewNOayXos,3628
11
- cache_dit/cache_factory/utils.py,sha256=XkVM9AXcB9zYq8-S8QKAsGz80r3tA6U3lBNGDGeHOe4,1871
10
+ cache_dit/cache_factory/params_modifier.py,sha256=2T98IbepAolWW6GwQsqUDsRzu0k65vo7BOrN3V8mKog,3606
11
+ cache_dit/cache_factory/utils.py,sha256=S3SD6Zhexzhkqnmfo830v6oNLm8stZe32nF4VdxD_bA,2497
12
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=HTyZdspd34G6QiJ2qPNoLmGwcxmAnCwpAf91NTIQtl4,21442
17
- cache_dit/cache_factory/cache_blocks/__init__.py,sha256=mivvm8YOfqT7YHs8y_MzGOGztPw8LxAqKGXuSRXxCv0,3032
16
+ cache_dit/cache_factory/cache_adapters/cache_adapter.py,sha256=Za9HixVkEKldYzyDA57xvF91fm9dao2S-Fz5QBIT02M,22123
17
+ cache_dit/cache_factory/cache_blocks/__init__.py,sha256=cpxzmDcUhbXcReHqaKSnWyEEbIg1H91Pz5hE3z9Xj3k,9984
18
18
  cache_dit/cache_factory/cache_blocks/offload_utils.py,sha256=wusgcqaCrwEjvv7Guy-6VXhNOgPPUrBV2sSVuRmGuvo,3513
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=rfq5-WEt-ErY28vcB4ur9E-uCb6BKP0S8v5lTw61ROk,10555
21
- cache_dit/cache_factory/cache_blocks/pattern_base.py,sha256=StNW2PyDiXEIxZd30byPUrZZ8jgSiuC_yrly2w7X2LQ,16176
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=N3SxFnluXk5q09nhSqKIJCVzEGWzySJWm-vic6dH79E,412
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=X99XnmiY-Us8D2pqJGPKxWcXAhQQpk3xdEWOOOYXIZ4,30465
19
+ cache_dit/cache_factory/cache_blocks/pattern_0_1_2.py,sha256=j4bTafqU5DLQhzP_X5XwOk-QUVLWkGrX-Q6JZvBGHh0,666
20
+ cache_dit/cache_factory/cache_blocks/pattern_3_4_5.py,sha256=2qPnXVZwpQIm2oJ-Yrn3Avqi3BcXtE2133jPIL_LhK8,19595
21
+ cache_dit/cache_factory/cache_blocks/pattern_base.py,sha256=9H87qBRpa6UWRkUKXLVO0_9NJgxCVKkFSzaQxM9YPw8,25487
22
+ cache_dit/cache_factory/cache_blocks/pattern_utils.py,sha256=qOxoVTlYPQzPMrR06-7_Ce_lwNg6n5pt1KQrvxzAJhE,3124
23
+ cache_dit/cache_factory/cache_contexts/__init__.py,sha256=7uY8fX9uhpC71VNm1HH4aDIicYn-dD3kRpPQhvc9-EI,853
24
+ cache_dit/cache_factory/cache_contexts/cache_config.py,sha256=WBHU2XVuYSFUSkrrJk8c4952LTeqvgetdkdtch_uSmg,5238
25
+ cache_dit/cache_factory/cache_contexts/cache_context.py,sha256=fjZMEHaT1DZvUKnzY41GP0Ep8tmPEZTOsCSvG-5it5k,11269
26
+ cache_dit/cache_factory/cache_contexts/cache_manager.py,sha256=tKtP35GDwZDoxGrQ_Okg_enlh3L-t-iqpytx8TFO_fw,30519
27
+ cache_dit/cache_factory/cache_contexts/context_manager.py,sha256=j5zP_kwZAKla3EXbfr6JKI1vIxZuUEbZVhAPrtC4COw,853
28
+ cache_dit/cache_factory/cache_contexts/prune_config.py,sha256=efFO_tu6AFJxIDp0OxExWKPzOFj95-NSrLGXggimBMA,3407
29
+ cache_dit/cache_factory/cache_contexts/prune_context.py,sha256=ywiT9P0w_GjIFLowzUDa6jhTohNsSGfTbanZcs9wMic,6359
30
+ cache_dit/cache_factory/cache_contexts/prune_manager.py,sha256=rZG7HD9ATqgH4VZdMq1XtP_h2pokaotFOVx1svB3J7E,5478
26
31
  cache_dit/cache_factory/cache_contexts/calibrators/__init__.py,sha256=mzYXO8tbytGpJJ9rpPu20kMoj1Iu_7Ym9tjfzV8rA98,5574
27
32
  cache_dit/cache_factory/cache_contexts/calibrators/base.py,sha256=mn6ZBkChGpGwN5csrHTUGMoX6BBPvqHXSLbIExiW-EU,748
28
33
  cache_dit/cache_factory/cache_contexts/calibrators/foca.py,sha256=nhHGs_hxwW1M942BQDMJb9-9IuHdnOxp774Jrna1bJI,891
29
- cache_dit/cache_factory/cache_contexts/calibrators/taylorseer.py,sha256=aGxr9SpytYznTepDWGPAxWDnuVMSuNyn6uNXnLh2acQ,4001
34
+ cache_dit/cache_factory/cache_contexts/calibrators/taylorseer.py,sha256=l1QSNaBwtGtpZZFAgCE7Hu8Nf1oL4QAcYu7lShpFGyw,5850
30
35
  cache_dit/cache_factory/patch_functors/__init__.py,sha256=IJZrvSkeHbR_xW-6IzY7sqEhApBsOfPyorQGJutvWH0,652
31
36
  cache_dit/cache_factory/patch_functors/functor_base.py,sha256=Ahk0fTfrHgNdEl-9JSkACvfyyv9G-Ei5OSz7XBIlX5o,357
32
37
  cache_dit/cache_factory/patch_functors/functor_chroma.py,sha256=xD0Q96VArp1vYBLQ0pcjRIyFB1i_Y7muZ2q07Hz8Oqs,13430
@@ -50,9 +55,9 @@ cache_dit/metrics/metrics.py,sha256=AZbQyoavE-djvyRUZ_EfCIrWSQbiWQFo7n2dhn7XptE,
50
55
  cache_dit/quantize/__init__.py,sha256=kWYoMAyZgBXu9BJlZjTQ0dRffW9GqeeY9_iTkXrb70A,59
51
56
  cache_dit/quantize/quantize_ao.py,sha256=Pr3u3Qr6qLvFkd8k-_rfcz4Mkjlg36U9BHG2t6Bl-6M,6301
52
57
  cache_dit/quantize/quantize_interface.py,sha256=2s_R7xPSKuJeFpEGeLwRxnq_CqJcBG3a3lzyW5wh-UM,1241
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,,
58
+ cache_dit-1.0.4.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
59
+ cache_dit-1.0.4.dist-info/METADATA,sha256=f04uCgApjgfHTC7Ll9aPejXCFFXbFTpTy-rjd5I_iwM,28376
60
+ cache_dit-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
61
+ cache_dit-1.0.4.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
62
+ cache_dit-1.0.4.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
63
+ cache_dit-1.0.4.dist-info/RECORD,,