cache-dit 1.0.7__py3-none-any.whl → 1.0.8__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 CHANGED
@@ -26,12 +26,24 @@ from cache_dit.cache_factory import FoCaCalibratorConfig
26
26
  from cache_dit.cache_factory import supported_pipelines
27
27
  from cache_dit.cache_factory import get_adapter
28
28
  from cache_dit.compile import set_compile_configs
29
- from cache_dit.quantize import quantize
30
29
  from cache_dit.parallelism import ParallelismBackend
31
30
  from cache_dit.parallelism import ParallelismConfig
32
31
  from cache_dit.utils import summary
33
32
  from cache_dit.utils import strify
34
33
 
34
+ try:
35
+ from cache_dit.quantize import quantize
36
+ except ImportError as e: # noqa: F841
37
+ err_msg = str(e)
38
+
39
+ def quantize(*args, **kwargs):
40
+ raise ImportError(
41
+ "Quantization requires additional dependencies. "
42
+ "Please install cache-dit[quantization] or cache-dit[all] "
43
+ f"to use this feature. Error message: {err_msg}"
44
+ )
45
+
46
+
35
47
  NONE = CacheType.NONE
36
48
  DBCache = CacheType.DBCache
37
49
  DBPrune = CacheType.DBPrune
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 = '1.0.7'
32
- __version_tuple__ = version_tuple = (1, 0, 7)
31
+ __version__ = version = '1.0.8'
32
+ __version_tuple__ = version_tuple = (1, 0, 8)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -1,3 +1,14 @@
1
+ try:
2
+ import ImageReward
3
+ import lpips
4
+ import skimage
5
+ import scipy
6
+ except ImportError:
7
+ raise ImportError(
8
+ "Metrics functionality requires the 'metrics' extra dependencies. "
9
+ "Install with:\npip install cache-dit[metrics]"
10
+ )
11
+
1
12
  from cache_dit.metrics.metrics import compute_psnr
2
13
  from cache_dit.metrics.metrics import compute_ssim
3
14
  from cache_dit.metrics.metrics import compute_mse
@@ -0,0 +1,6 @@
1
+ from cache_dit.parallelism.backends.native_diffusers.parallel_difffusers import (
2
+ maybe_enable_parallelism,
3
+ )
4
+ from cache_dit.parallelism.backends.native_diffusers.parallel_difffusers import (
5
+ native_diffusers_parallelism_available,
6
+ )
@@ -63,8 +63,16 @@ def maybe_enable_parallelism(
63
63
  "Set attention backend to _native_cudnn for parallelism because of "
64
64
  "the issue: https://github.com/huggingface/diffusers/pull/12443"
65
65
  )
66
-
67
- transformer.enable_parallelism(config=cp_config)
66
+ cp_plan = parallelism_config.parallel_kwargs.get(
67
+ "cp_plan", None
68
+ )
69
+ if cp_plan is not None:
70
+ logger.info(
71
+ f"Using custom context parallelism plan: {cp_plan}"
72
+ )
73
+ transformer.enable_parallelism(
74
+ config=cp_config, cp_plan=cp_plan
75
+ )
68
76
  else:
69
77
  raise ValueError(
70
78
  f"{transformer.__class__.__name__} does not support context parallelism."
@@ -1,4 +1,5 @@
1
1
  import dataclasses
2
+ from typing import Optional, Dict, Any
2
3
  from cache_dit.parallelism.parallel_backend import ParallelismBackend
3
4
  from cache_dit.logger import init_logger
4
5
 
@@ -20,6 +21,13 @@ class ParallelismConfig:
20
21
  # tp_size (`int`, *optional*):
21
22
  # The degree of tensor parallelism.
22
23
  tp_size: int = None
24
+ # parallel_kwargs (`dict`, *optional*):
25
+ # Additional kwargs for parallelism backends. For example, for
26
+ # NATIVE_DIFFUSER backend, it can include `cp_plan` and other
27
+ # arguments for `Context Parallelism`.
28
+ parallel_kwargs: Optional[Dict[str, Any]] = dataclasses.field(
29
+ default_factory=dict
30
+ )
23
31
 
24
32
  def __post_init__(self):
25
33
  assert ParallelismBackend.is_supported(self.backend), (
@@ -22,7 +22,7 @@ def enable_parallelism(
22
22
  return transformer
23
23
 
24
24
  if parallelism_config.backend == ParallelismBackend.NATIVE_DIFFUSER:
25
- from cache_dit.parallelism.backends.parallel_difffusers import (
25
+ from cache_dit.parallelism.backends.native_diffusers import (
26
26
  maybe_enable_parallelism,
27
27
  native_diffusers_parallelism_available,
28
28
  )
@@ -1 +1,8 @@
1
+ try:
2
+ import torchao
3
+ except ImportError:
4
+ raise ImportError(
5
+ "Quantization functionality requires the 'quantization' extra dependencies. "
6
+ "Install with: pip install cache-dit[quantization]"
7
+ )
1
8
  from cache_dit.quantize.quantize_interface import quantize
@@ -1,37 +1,33 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cache_dit
3
- Version: 1.0.7
3
+ Version: 1.0.8
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
7
- Project-URL: Repository, https://github.com/vipshop/cache-dit.git
8
- Project-URL: Homepage, https://github.com/vipshop/cache-dit.git
7
+ Project-URL: Repository, https://github.com/vipshop/cache-dit
8
+ Project-URL: Homepage, https://github.com/vipshop/cache-dit
9
+ Project-URL: GitHub, https://github.com/vipshop/cache-dit
9
10
  Requires-Python: >=3.10
10
11
  Description-Content-Type: text/markdown
11
12
  License-File: LICENSE
12
- Requires-Dist: packaging
13
13
  Requires-Dist: pyyaml
14
14
  Requires-Dist: torch>=2.7.1
15
- Requires-Dist: transformers>=4.55.2
16
15
  Requires-Dist: diffusers>=0.35.1
17
- Requires-Dist: scikit-image
18
- Requires-Dist: scipy
19
- Requires-Dist: lpips==0.1.4
20
- Requires-Dist: torchao>=0.12.0
21
- Requires-Dist: image-reward
22
- Provides-Extra: all
16
+ Requires-Dist: transformers>=4.55.2
17
+ Provides-Extra: quantization
18
+ Requires-Dist: torchao>=0.12.0; extra == "quantization"
23
19
  Provides-Extra: metrics
20
+ Requires-Dist: scipy; extra == "metrics"
21
+ Requires-Dist: scikit-image; extra == "metrics"
24
22
  Requires-Dist: image-reward; extra == "metrics"
25
- Requires-Dist: pytorch-fid; extra == "metrics"
26
23
  Requires-Dist: lpips==0.1.4; extra == "metrics"
27
24
  Provides-Extra: dev
25
+ Requires-Dist: packaging; extra == "dev"
28
26
  Requires-Dist: pre-commit; extra == "dev"
29
27
  Requires-Dist: pytest<8.0.0,>=7.0.0; extra == "dev"
30
28
  Requires-Dist: pytest-html; extra == "dev"
31
29
  Requires-Dist: expecttest; extra == "dev"
32
30
  Requires-Dist: hypothesis; extra == "dev"
33
- Requires-Dist: transformers; extra == "dev"
34
- Requires-Dist: diffusers; extra == "dev"
35
31
  Requires-Dist: accelerate; extra == "dev"
36
32
  Requires-Dist: peft; extra == "dev"
37
33
  Requires-Dist: protobuf; extra == "dev"
@@ -39,10 +35,10 @@ Requires-Dist: sentencepiece; extra == "dev"
39
35
  Requires-Dist: opencv-python-headless; extra == "dev"
40
36
  Requires-Dist: ftfy; extra == "dev"
41
37
  Requires-Dist: scikit-image; extra == "dev"
42
- Requires-Dist: pytorch-fid; extra == "dev"
38
+ Provides-Extra: all
39
+ Requires-Dist: cache-dit[quantization]; extra == "all"
40
+ Requires-Dist: cache-dit[metrics]; extra == "all"
43
41
  Dynamic: license-file
44
- Dynamic: provides-extra
45
- Dynamic: requires-dist
46
42
  Dynamic: requires-python
47
43
 
48
44
  📚English | <a href="./README_CN.md">📚中文阅读 </a>
@@ -1,5 +1,5 @@
1
- cache_dit/__init__.py,sha256=HZb04M7AHCfk9DaEAGApGJ2lCM-rsP6pbsNQxsQudi0,1743
2
- cache_dit/_version.py,sha256=xUX1oSOk6hTPREy9SfhUBjaOBMJucMgoQViQ3e2Ce9A,704
1
+ cache_dit/__init__.py,sha256=Azqj-3QMQK4HZDTGgyUtAfatUwuU-YQ4w8erJSyrsbE,2082
2
+ cache_dit/_version.py,sha256=09KGe_qkXH8vhvX180khtkldtbrAX-u8refqVsC-Ky4,704
3
3
  cache_dit/logger.py,sha256=0zsu42hN-3-rgGC_C29ms1IvVpV4_b4_SwJCKSenxBE,4304
4
4
  cache_dit/utils.py,sha256=3NcEb324fNY0NYnrBTjsLURKQuckKeFe3V9Dfc_g4sc,17851
5
5
  cache_dit/cache_factory/.gitignore,sha256=5Cb-qT9wsTUoMJ7vACDF7ZcLpAXhi5v-xdcWSRit988,23
@@ -44,7 +44,7 @@ cache_dit/compile/__init__.py,sha256=FcTVzCeyypl-mxlc59_ehHL3lBNiDAFsXuRoJ-5Cfi0
44
44
  cache_dit/compile/utils.py,sha256=nN2OIrSdwRR5zGxJinKDqb07pXpvTNTF3g_OgLkeeBU,3858
45
45
  cache_dit/custom_ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  cache_dit/custom_ops/triton_taylorseer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
- cache_dit/metrics/__init__.py,sha256=UjPJ69DyyjZDfERTpKAjZKOxOTx58aWnkze7VfH3en8,673
47
+ cache_dit/metrics/__init__.py,sha256=Y_JrBr9XE6NKXwyXc7d_-PaX9c_rk5FKms-IYgCyHmY,936
48
48
  cache_dit/metrics/clip_score.py,sha256=ERNCFQFJKzJdbIX9OAg-1LiSPuXUVHLOFxbf2gcENpc,3938
49
49
  cache_dit/metrics/config.py,sha256=ieOgD9ayz722RjVzk24bSIqS2D6o7TZjGk8KeXV-OLQ,551
50
50
  cache_dit/metrics/fid.py,sha256=ZM_FM0XERtpnkMUfphmw2aOdljrh1uba-pnYItu0q6M,18219
@@ -54,15 +54,17 @@ cache_dit/metrics/lpips.py,sha256=hrHrmdM-f2B4TKDs0xLqJO5JFaYcCjq2qNIR8oCrVkc,81
54
54
  cache_dit/metrics/metrics.py,sha256=AZbQyoavE-djvyRUZ_EfCIrWSQbiWQFo7n2dhn7XptE,40466
55
55
  cache_dit/parallelism/__init__.py,sha256=dheBG5_TZCuwctviMslpAEgB-B3N8F816bE51qsw_fU,210
56
56
  cache_dit/parallelism/parallel_backend.py,sha256=js1soTMenLeAyPMsBgdI3gWcdXoqjWgBD-PuFEywMr0,508
57
- cache_dit/parallelism/parallel_config.py,sha256=bu24sRSzJMmH7FZqzUPTcT6tAzQ20-FAqAEvGV3Q1Fw,1733
58
- cache_dit/parallelism/parallel_interface.py,sha256=tsiIdHosTmRbeRg0z9q0eMQlx-7vefmSIlc56OWnuMg,2205
59
- cache_dit/parallelism/backends/parallel_difffusers.py,sha256=YQkCJ1yq1OomZLyRLtGMaPSNWbDeAWGx9XuObVJ_85I,2499
60
- cache_dit/quantize/__init__.py,sha256=kWYoMAyZgBXu9BJlZjTQ0dRffW9GqeeY9_iTkXrb70A,59
57
+ cache_dit/parallelism/parallel_config.py,sha256=cOAXaniGf4CDPG5sbVktZy2rTZe49jSsnUIW2IBerGM,2106
58
+ cache_dit/parallelism/parallel_interface.py,sha256=WPPYYaodo0PCYrn6-Haz8GcNZ2RK3EG7q6P_cH51Qj0,2202
59
+ cache_dit/parallelism/backends/native_diffusers/__init__.py,sha256=T_6GeBA7TRiVbvtqGLLH2flkRiK0o7JBREt2xhS_-YE,242
60
+ cache_dit/parallelism/backends/native_diffusers/parallel_difffusers.py,sha256=wHRjxRWK5E92cdSwDkZJpKQCQGZfxY53woW47rMFH2I,2844
61
+ cache_dit/parallelism/backends/native_pytorch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
+ cache_dit/quantize/__init__.py,sha256=rUu0V9VRjOgwXuIUHHAI-osivNjAdUsi-jpkDbFp6Gk,278
61
63
  cache_dit/quantize/quantize_ao.py,sha256=bbEUwsrMp3bMuRw8qJZREIvCHaJRQoZyfMjlu4ImRMI,6315
62
64
  cache_dit/quantize/quantize_interface.py,sha256=2s_R7xPSKuJeFpEGeLwRxnq_CqJcBG3a3lzyW5wh-UM,1241
63
- cache_dit-1.0.7.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
64
- cache_dit-1.0.7.dist-info/METADATA,sha256=I0Vb-ZqUHblKOWwXyCyZVfcllq1lLm7ML2X7U6TJs4s,29475
65
- cache_dit-1.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
66
- cache_dit-1.0.7.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
67
- cache_dit-1.0.7.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
68
- cache_dit-1.0.7.dist-info/RECORD,,
65
+ cache_dit-1.0.8.dist-info/licenses/LICENSE,sha256=Dqb07Ik2dV41s9nIdMUbiRWEfDqo7-dQeRiY7kPO8PE,3769
66
+ cache_dit-1.0.8.dist-info/METADATA,sha256=cs6CuqsbXQ8w69_kg2e7yALeczPAZjd5hz8odNrsvZA,29462
67
+ cache_dit-1.0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
68
+ cache_dit-1.0.8.dist-info/entry_points.txt,sha256=FX2gysXaZx6NeK1iCLMcIdP8Q4_qikkIHtEmi3oWn8o,65
69
+ cache_dit-1.0.8.dist-info/top_level.txt,sha256=ZJDydonLEhujzz0FOkVbO-BqfzO9d_VqRHmZU-3MOZo,10
70
+ cache_dit-1.0.8.dist-info/RECORD,,