cache-dit 0.1.2__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cache-dit might be problematic. Click here for more details.
- cache_dit/_version.py +2 -2
- {cache_dit-0.1.2.dist-info → cache_dit-0.1.5.dist-info}/METADATA +48 -11
- {cache_dit-0.1.2.dist-info → cache_dit-0.1.5.dist-info}/RECORD +6 -6
- {cache_dit-0.1.2.dist-info → cache_dit-0.1.5.dist-info}/WHEEL +0 -0
- {cache_dit-0.1.2.dist-info → cache_dit-0.1.5.dist-info}/licenses/LICENSE +0 -0
- {cache_dit-0.1.2.dist-info → cache_dit-0.1.5.dist-info}/top_level.txt +0 -0
cache_dit/_version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cache_dit
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: 🤗 CacheDiT: A Training-free and Easy-to-use Cache Acceleration Toolbox for Diffusion Transformers
|
|
5
5
|
Author: DefTruth, vipshop.com, etc.
|
|
6
6
|
Maintainer: DefTruth, vipshop.com, etc
|
|
@@ -37,13 +37,14 @@ Dynamic: requires-python
|
|
|
37
37
|
<p align="center">
|
|
38
38
|
<h3>🤗 CacheDiT: A Training-free and Easy-to-use Cache Acceleration <br>Toolbox for Diffusion Transformers</h3>
|
|
39
39
|
</p>
|
|
40
|
-
<img src=https://github.com/vipshop/cache-dit/raw/
|
|
40
|
+
<img src=https://github.com/vipshop/cache-dit/raw/main/assets/cache-dit.png >
|
|
41
41
|
<div align='center'>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
<img src=https://img.shields.io/badge/Language-Python-brightgreen.svg >
|
|
43
|
+
<img src=https://img.shields.io/badge/PRs-welcome-9cf.svg >
|
|
44
|
+
<img src=https://img.shields.io/badge/PyPI-pass-brightgreen.svg >
|
|
45
|
+
<img src=https://static.pepy.tech/badge/cache-dit >
|
|
46
|
+
<img src=https://img.shields.io/badge/Python-3.10|3.11|3.12-9cf.svg >
|
|
47
|
+
<img src=https://img.shields.io/badge/Release-v0.1.5-brightgreen.svg >
|
|
47
48
|
</div>
|
|
48
49
|
<p align="center">
|
|
49
50
|
DeepCache is for UNet not DiT. Most DiT cache speedups are complex and not training-free. CacheDiT provides <br>a series of training-free, UNet-style cache accelerators for DiT: DBCache, DBPrune, FBCache, etc.
|
|
@@ -166,7 +167,7 @@ pip3 install git+https://github.com/vipshop/cache-dit.git
|
|
|
166
167
|
- **Fn**: Specifies that DBCache uses the **first n** Transformer blocks to fit the information at time step t, enabling the calculation of a more stable L1 diff and delivering more accurate information to subsequent blocks.
|
|
167
168
|
- **Bn**: Further fuses approximate information in the **last n** Transformer blocks to enhance prediction accuracy. These blocks act as an auto-scaler for approximate hidden states that use residual cache.
|
|
168
169
|
- **warmup_steps**: (default: 0) DBCache does not apply the caching strategy when the number of running steps is less than or equal to this value, ensuring the model sufficiently learns basic features during warmup.
|
|
169
|
-
- **max_cached_steps**: (default: -1) DBCache disables the caching strategy when the
|
|
170
|
+
- **max_cached_steps**: (default: -1) DBCache disables the caching strategy when the previous cached steps exceed this value to prevent precision degradation.
|
|
170
171
|
- **residual_diff_threshold**: The value of residual diff threshold, a higher value leads to faster performance at the cost of lower precision.
|
|
171
172
|
|
|
172
173
|
For a good balance between performance and precision, DBCache is configured by default with **F8B8**, 8 warmup steps, and unlimited cached steps.
|
|
@@ -202,8 +203,9 @@ Moreover, users configuring higher **Bn** values (e.g., **F8B16**) while aiming
|
|
|
202
203
|
cache_options = {
|
|
203
204
|
# 0, 2, 4, ..., 14, 15, etc. [0,16)
|
|
204
205
|
"Bn_compute_blocks_ids": CacheType.range(0, 16, 2),
|
|
205
|
-
#
|
|
206
|
-
#
|
|
206
|
+
# If the L1 difference is below this threshold, skip Bn blocks
|
|
207
|
+
# not in `Bn_compute_blocks_ids`(1, 3,..., etc), Otherwise,
|
|
208
|
+
# compute these blocks.
|
|
207
209
|
"non_compute_blocks_diff_threshold": 0.08,
|
|
208
210
|
}
|
|
209
211
|
```
|
|
@@ -259,12 +261,47 @@ pipe = FluxPipeline.from_pretrained(
|
|
|
259
261
|
torch_dtype=torch.bfloat16,
|
|
260
262
|
).to("cuda")
|
|
261
263
|
|
|
262
|
-
# Using DBPrune
|
|
264
|
+
# Using DBPrune with default options
|
|
263
265
|
cache_options = CacheType.default_options(CacheType.DBPrune)
|
|
264
266
|
|
|
265
267
|
apply_cache_on_pipe(pipe, **cache_options)
|
|
266
268
|
```
|
|
267
269
|
|
|
270
|
+
We have also brought the designs from DBCache to DBPrune to make it a more general and customizable block prune algorithm. You can specify the values of **Fn** and **Bn** for higher precision, or set up the non-prune blocks list **non_prune_blocks_ids** to avoid aggressive pruning. For example:
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
# Custom options for DBPrune
|
|
274
|
+
cache_options = {
|
|
275
|
+
"cache_type": CacheType.DBPrune,
|
|
276
|
+
"residual_diff_threshold": 0.05,
|
|
277
|
+
# Never prune the first `Fn` and last `Bn` blocks.
|
|
278
|
+
"Fn_compute_blocks": 8, # default 1
|
|
279
|
+
"Bn_compute_blocks": 8, # default 0
|
|
280
|
+
"warmup_steps": 8, # default -1
|
|
281
|
+
# Disables the pruning strategy when the previous
|
|
282
|
+
# pruned steps greater than this value.
|
|
283
|
+
"max_pruned_steps": 12, # default, -1 means no limit
|
|
284
|
+
# Enable dynamic prune threshold within step, higher
|
|
285
|
+
# `max_dynamic_prune_threshold` value may introduce a more
|
|
286
|
+
# ageressive pruning strategy.
|
|
287
|
+
"enable_dynamic_prune_threshold": True,
|
|
288
|
+
"max_dynamic_prune_threshold": 2 * 0.05,
|
|
289
|
+
# (New thresh) = mean(previous_block_diffs_within_step) * 1.25
|
|
290
|
+
# (New thresh) = ((New thresh) if (New thresh) <
|
|
291
|
+
# max_dynamic_prune_threshold else residual_diff_threshold)
|
|
292
|
+
"dynamic_prune_threshold_relax_ratio": 1.25,
|
|
293
|
+
# The step interval to update residual cache. For example,
|
|
294
|
+
# 2: means the update steps will be [0, 2, 4, ...].
|
|
295
|
+
"residual_cache_update_interval": 1,
|
|
296
|
+
# You can set non-prune blocks to avoid ageressive pruning.
|
|
297
|
+
# For example, FLUX.1 has 19 + 38 blocks, so we can set it
|
|
298
|
+
# to 0, 2, 4, ..., 56, etc.
|
|
299
|
+
"non_prune_blocks_ids": [],
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
apply_cache_on_pipe(pipe, **cache_options)
|
|
303
|
+
```
|
|
304
|
+
|
|
268
305
|
<div align="center">
|
|
269
306
|
<p align="center">
|
|
270
307
|
DBPrune, <b> L20x1 </b>, Steps: 28, "A cat holding a sign that says hello world with complex background"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
cache_dit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
cache_dit/_version.py,sha256=
|
|
2
|
+
cache_dit/_version.py,sha256=Y4jy4bEMmwl_qNPCmiMFnlQ2ofMoqyG37hp8uwI3m10,511
|
|
3
3
|
cache_dit/logger.py,sha256=dKfNe_RRk9HJwfgHGeRR1f0LbskJpKdGmISCbL9roQs,3443
|
|
4
4
|
cache_dit/primitives.py,sha256=A2iG9YLot3gOsZSPp-_gyjqjLgJvWQRx8aitD4JQ23Y,3877
|
|
5
5
|
cache_dit/cache_factory/__init__.py,sha256=5RNuhWakvvqrOV4vkqrEBA7d-V1LwcNSsjtW14mkqK8,5255
|
|
@@ -24,8 +24,8 @@ cache_dit/cache_factory/first_block_cache/diffusers_adapters/cogvideox.py,sha256
|
|
|
24
24
|
cache_dit/cache_factory/first_block_cache/diffusers_adapters/flux.py,sha256=Dcd4OzABCtyQCZNX2KNnUTdVoO1E1ApM7P8gcVYzcK0,2733
|
|
25
25
|
cache_dit/cache_factory/first_block_cache/diffusers_adapters/mochi.py,sha256=lQTClo52OwPbNEE4jiBZQhfC7hbtYqnYIABp_vbm_dk,2363
|
|
26
26
|
cache_dit/cache_factory/first_block_cache/diffusers_adapters/wan.py,sha256=IVH-lroOzvYb4XKLk9MOw54EtijBtuzVaKcVGz0KlBA,2656
|
|
27
|
-
cache_dit-0.1.
|
|
28
|
-
cache_dit-0.1.
|
|
29
|
-
cache_dit-0.1.
|
|
30
|
-
cache_dit-0.1.
|
|
31
|
-
cache_dit-0.1.
|
|
27
|
+
cache_dit-0.1.5.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
|
|
28
|
+
cache_dit-0.1.5.dist-info/METADATA,sha256=87hqiy00L-lsW4yktOKTnWAnk7jHCVhxYKOkxaK2K48,18478
|
|
29
|
+
cache_dit-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
cache_dit-0.1.5.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
|
|
31
|
+
cache_dit-0.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|