File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
test_quantization/lifecycle Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 28
28
apply_quantization_status ,
29
29
)
30
30
from compressed_tensors .quantization .utils import iter_named_leaf_modules
31
+ from tests .testing_utils import requires_accelerate
31
32
from transformers import AutoModelForCausalLM
32
33
33
34
@@ -224,6 +225,7 @@ def get_sample_tinyllama_quant_config(status: str = "frozen"):
224
225
return QuantizationConfig .parse_obj (config_dict )
225
226
226
227
228
+ @requires_accelerate ()
227
229
@pytest .mark .parametrize (
228
230
"ignore,should_raise_warning" ,
229
231
[
Original file line number Diff line number Diff line change @@ -26,8 +26,29 @@ def compressed_tensors_config_available():
26
26
return False
27
27
28
28
29
+ def accelerate_availabe ():
30
+ try :
31
+ import accelerate # noqa: F401
32
+
33
+ return True
34
+
35
+ except ImportError :
36
+ return False
37
+
38
+
39
+ _is_compressed_tensors_config_available = compressed_tensors_config_available ()
40
+ _is_accelerate_available = accelerate_availabe ()
41
+
42
+
29
43
def requires_hf_quantizer ():
30
44
return pytest .mark .skipif (
31
- not compressed_tensors_config_available () ,
45
+ not _is_compressed_tensors_config_available ,
32
46
reason = "requires transformers>=4.45 to support CompressedTensorsHfQuantizer" ,
33
47
)
48
+
49
+
50
+ def requires_accelerate ():
51
+ return pytest .mark .skipif (
52
+ not _is_accelerate_available ,
53
+ reason = "requires accelerate" ,
54
+ )
You can’t perform that action at this time.
0 commit comments