cache-dit 0.1.3__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 CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.1.3'
21
- __version_tuple__ = version_tuple = (0, 1, 3)
20
+ __version__ = version = '0.1.5'
21
+ __version_tuple__ = version_tuple = (0, 1, 5)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cache_dit
3
- Version: 0.1.3
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
@@ -44,7 +44,7 @@ Dynamic: requires-python
44
44
  <img src=https://img.shields.io/badge/PyPI-pass-brightgreen.svg >
45
45
  <img src=https://static.pepy.tech/badge/cache-dit >
46
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.3-brightgreen.svg >
47
+ <img src=https://img.shields.io/badge/Release-v0.1.5-brightgreen.svg >
48
48
  </div>
49
49
  <p align="center">
50
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.
@@ -167,7 +167,7 @@ pip3 install git+https://github.com/vipshop/cache-dit.git
167
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.
168
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.
169
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.
170
- - **max_cached_steps**: (default: -1) DBCache disables the caching strategy when the running steps exceed this value to prevent precision degradation.
170
+ - **max_cached_steps**: (default: -1) DBCache disables the caching strategy when the previous cached steps exceed this value to prevent precision degradation.
171
171
  - **residual_diff_threshold**: The value of residual diff threshold, a higher value leads to faster performance at the cost of lower precision.
172
172
 
173
173
  For a good balance between performance and precision, DBCache is configured by default with **F8B8**, 8 warmup steps, and unlimited cached steps.
@@ -261,12 +261,47 @@ pipe = FluxPipeline.from_pretrained(
261
261
  torch_dtype=torch.bfloat16,
262
262
  ).to("cuda")
263
263
 
264
- # Using DBPrune
264
+ # Using DBPrune with default options
265
265
  cache_options = CacheType.default_options(CacheType.DBPrune)
266
266
 
267
267
  apply_cache_on_pipe(pipe, **cache_options)
268
268
  ```
269
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
+
270
305
  <div align="center">
271
306
  <p align="center">
272
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=NIzzV8ZM0W-CSLuEs1weG4zPrn_-8yr1AwwI1iuS6yo,511
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.3.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
28
- cache_dit-0.1.3.dist-info/METADATA,sha256=PkDyfGzvMzMinTNlqCX_B3VGbNsPUvLdBQTyEywQ8zE,16806
29
- cache_dit-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- cache_dit-0.1.3.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
31
- cache_dit-0.1.3.dist-info/RECORD,,
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,,