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.
- cache_dit/__init__.py +3 -0
- cache_dit/_version.py +2 -2
- cache_dit/cache_factory/__init__.py +8 -1
- cache_dit/cache_factory/cache_adapters/cache_adapter.py +90 -76
- cache_dit/cache_factory/cache_blocks/__init__.py +167 -17
- cache_dit/cache_factory/cache_blocks/pattern_0_1_2.py +10 -0
- cache_dit/cache_factory/cache_blocks/pattern_3_4_5.py +271 -36
- cache_dit/cache_factory/cache_blocks/pattern_base.py +286 -45
- cache_dit/cache_factory/cache_blocks/pattern_utils.py +55 -10
- cache_dit/cache_factory/cache_contexts/__init__.py +15 -2
- cache_dit/cache_factory/cache_contexts/cache_config.py +102 -0
- cache_dit/cache_factory/cache_contexts/cache_context.py +26 -89
- cache_dit/cache_factory/cache_contexts/cache_manager.py +7 -7
- cache_dit/cache_factory/cache_contexts/calibrators/taylorseer.py +78 -8
- cache_dit/cache_factory/cache_contexts/context_manager.py +29 -0
- cache_dit/cache_factory/cache_contexts/prune_config.py +69 -0
- cache_dit/cache_factory/cache_contexts/prune_context.py +155 -0
- cache_dit/cache_factory/cache_contexts/prune_manager.py +154 -0
- cache_dit/cache_factory/cache_interface.py +23 -14
- cache_dit/cache_factory/cache_types.py +19 -2
- cache_dit/cache_factory/params_modifier.py +7 -7
- cache_dit/cache_factory/utils.py +38 -27
- cache_dit/utils.py +191 -54
- {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/METADATA +14 -7
- {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/RECORD +29 -24
- {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/WHEEL +0 -0
- {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/entry_points.txt +0 -0
- {cache_dit-1.0.2.dist-info → cache_dit-1.0.4.dist-info}/licenses/LICENSE +0 -0
- {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
|
|
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
|
|
194
|
+
def cache_str():
|
|
185
195
|
cache_config: BasicCacheConfig = cache_options.get("cache_config", None)
|
|
186
196
|
if cache_config is not None:
|
|
187
|
-
|
|
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"{
|
|
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, "
|
|
229
|
-
cache_options = module.
|
|
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🤗
|
|
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
|
|
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
|
-
|
|
254
|
-
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
276
|
-
f"
|
|
277
|
-
|
|
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(
|
|
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
|
-
|
|
297
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
-
|
|
418
|
+
"| CFG Cache Steps | Diffs P00 | Diffs P25 | Diffs P50 | Diffs P75 | Diffs P95 | Diffs Min | Diffs Max |"
|
|
316
419
|
)
|
|
317
|
-
|
|
318
|
-
|
|
420
|
+
print(
|
|
421
|
+
"|-----------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|"
|
|
319
422
|
)
|
|
320
|
-
|
|
321
|
-
f"
|
|
322
|
-
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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 **
|
|
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
|
-

|
|
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) , [flux-fast](https://github.com/huggingface/flux-fast) , and [sdnext](https://github.com/vladmandic/sdnext/blob/dev/modules/cachedit.py) . **CacheDiT** has also been **recommended** by [Wan2.2](https://github.com/Wan-Video/Wan2.2) , [Qwen-Image-Lightning](https://github.com/ModelTC/Qwen-Image-Lightning) , [Qwen-Image](https://github.com/QwenLM/Qwen-Image) , 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> , 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=
|
|
2
|
-
cache_dit/_version.py,sha256=
|
|
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=
|
|
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=
|
|
7
|
-
cache_dit/cache_factory/cache_interface.py,sha256=
|
|
8
|
-
cache_dit/cache_factory/cache_types.py,sha256=
|
|
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=
|
|
11
|
-
cache_dit/cache_factory/utils.py,sha256=
|
|
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=
|
|
17
|
-
cache_dit/cache_factory/cache_blocks/__init__.py,sha256=
|
|
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=
|
|
20
|
-
cache_dit/cache_factory/cache_blocks/pattern_3_4_5.py,sha256=
|
|
21
|
-
cache_dit/cache_factory/cache_blocks/pattern_base.py,sha256=
|
|
22
|
-
cache_dit/cache_factory/cache_blocks/pattern_utils.py,sha256=
|
|
23
|
-
cache_dit/cache_factory/cache_contexts/__init__.py,sha256=
|
|
24
|
-
cache_dit/cache_factory/cache_contexts/
|
|
25
|
-
cache_dit/cache_factory/cache_contexts/
|
|
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=
|
|
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.
|
|
54
|
-
cache_dit-1.0.
|
|
55
|
-
cache_dit-1.0.
|
|
56
|
-
cache_dit-1.0.
|
|
57
|
-
cache_dit-1.0.
|
|
58
|
-
cache_dit-1.0.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|