|
2 | 2 |
|
3 | 3 | from typing import TYPE_CHECKING |
4 | 4 |
|
5 | | -from diffusers.quantizers import quantization_config |
6 | | -from diffusers.utils import dummy_gguf_objects |
7 | | -from diffusers.utils.import_utils import ( |
8 | | - is_bitsandbytes_available, |
9 | | - is_gguf_available, |
10 | | - is_optimum_quanto_version, |
11 | | - is_torchao_available, |
12 | | -) |
13 | | - |
14 | 5 | from .utils import ( |
15 | 6 | DIFFUSERS_SLOW_IMPORT, |
16 | 7 | OptionalDependencyNotAvailable, |
17 | 8 | _LazyModule, |
| 9 | + is_accelerate_available, |
| 10 | + is_bitsandbytes_available, |
18 | 11 | is_flax_available, |
| 12 | + is_gguf_available, |
19 | 13 | is_k_diffusion_available, |
20 | 14 | is_librosa_available, |
21 | 15 | is_note_seq_available, |
|
24 | 18 | is_scipy_available, |
25 | 19 | is_sentencepiece_available, |
26 | 20 | is_torch_available, |
| 21 | + is_torchao_available, |
27 | 22 | is_torchsde_available, |
28 | 23 | is_transformers_available, |
29 | 24 | ) |
|
65 | 60 | } |
66 | 61 |
|
67 | 62 | try: |
68 | | - if not is_bitsandbytes_available(): |
| 63 | + if not is_torch_available() and not is_accelerate_available() and not is_bitsandbytes_available(): |
69 | 64 | raise OptionalDependencyNotAvailable() |
70 | 65 | except OptionalDependencyNotAvailable: |
71 | 66 | from .utils import dummy_bitsandbytes_objects |
|
77 | 72 | _import_structure["quantizers.quantization_config"].append("BitsAndBytesConfig") |
78 | 73 |
|
79 | 74 | try: |
80 | | - if not is_gguf_available(): |
| 75 | + if not is_torch_available() and not is_accelerate_available() and not is_gguf_available(): |
81 | 76 | raise OptionalDependencyNotAvailable() |
82 | 77 | except OptionalDependencyNotAvailable: |
83 | 78 | from .utils import dummy_gguf_objects |
|
89 | 84 | _import_structure["quantizers.quantization_config"].append("GGUFQuantizationConfig") |
90 | 85 |
|
91 | 86 | try: |
92 | | - if not is_torchao_available(): |
| 87 | + if not is_torch_available() and not is_accelerate_available() and not is_torchao_available(): |
93 | 88 | raise OptionalDependencyNotAvailable() |
94 | 89 | except OptionalDependencyNotAvailable: |
95 | 90 | from .utils import dummy_torchao_objects |
|
101 | 96 | _import_structure["quantizers.quantization_config"].append("TorchAoConfig") |
102 | 97 |
|
103 | 98 | try: |
104 | | - if not is_optimum_quanto_available(): |
| 99 | + if not is_torch_available() and not is_accelerate_available() and not is_optimum_quanto_available(): |
105 | 100 | raise OptionalDependencyNotAvailable() |
106 | 101 | except OptionalDependencyNotAvailable: |
107 | 102 | from .utils import dummy_optimum_quanto_objects |
|
112 | 107 | else: |
113 | 108 | _import_structure["quantizers.quantization_config"].append("QuantoConfig") |
114 | 109 |
|
115 | | - |
116 | 110 | try: |
117 | 111 | if not is_onnx_available(): |
118 | 112 | raise OptionalDependencyNotAvailable() |
|
0 commit comments