Skip to content

Commit 484c8ef

Browse files
authored
[tests] skip dynamo tests when python is 3.12. (huggingface#7458)
skip dynamo tests when python is 3.12.
1 parent 0dd0528 commit 484c8ef

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

src/diffusers/utils/testing_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,15 @@ def deprecate_after_peft_backend(test_case):
339339
return unittest.skipUnless(not USE_PEFT_BACKEND, "test skipped in favor of PEFT backend")(test_case)
340340

341341

342+
def get_python_version():
343+
sys_info = sys.version_info
344+
major, minor = sys_info.major, sys_info.minor
345+
return major, minor
346+
347+
342348
def require_python39_or_higher(test_case):
343349
def python39_available():
344-
sys_info = sys.version_info
345-
major, minor = sys_info.major, sys_info.minor
350+
major, minor = get_python_version()
346351
return major == 3 and minor >= 9
347352

348353
return unittest.skipUnless(python39_available(), "test requires Python 3.9 or higher")(test_case)

tests/models/test_modeling_common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from diffusers.utils import is_xformers_available, logging
3535
from diffusers.utils.testing_utils import (
3636
CaptureLogger,
37+
get_python_version,
3738
require_python39_or_higher,
3839
require_torch_2,
3940
require_torch_accelerator_with_training,
@@ -431,6 +432,10 @@ def test_from_save_pretrained_variant(self, expected_max_diff=5e-5):
431432

432433
@require_python39_or_higher
433434
@require_torch_2
435+
@unittest.skipIf(
436+
get_python_version == (3, 12),
437+
reason="Torch Dynamo isn't yet supported for Python 3.12.",
438+
)
434439
def test_from_save_pretrained_dynamo(self):
435440
init_dict, _ = self.prepare_init_args_and_inputs_for_common()
436441
inputs = [init_dict, self.model_class]

tests/pipelines/controlnet/test_controlnet.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from diffusers.utils.import_utils import is_xformers_available
3636
from diffusers.utils.testing_utils import (
3737
enable_full_determinism,
38+
get_python_version,
3839
load_image,
3940
load_numpy,
4041
numpy_cosine_similarity_distance,
@@ -992,6 +993,10 @@ def test_canny_guess_mode_euler(self):
992993

993994
@require_python39_or_higher
994995
@require_torch_2
996+
@unittest.skipIf(
997+
get_python_version == (3, 12),
998+
reason="Torch Dynamo isn't yet supported for Python 3.12.",
999+
)
9951000
def test_stable_diffusion_compile(self):
9961001
run_test_in_subprocess(test_case=self, target_func=_test_stable_diffusion_compile, inputs=None)
9971002

tests/pipelines/test_pipelines.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
CaptureLogger,
6767
enable_full_determinism,
6868
floats_tensor,
69+
get_python_version,
6970
get_tests_dir,
7071
load_numpy,
7172
nightly,
@@ -1748,6 +1749,10 @@ def test_from_save_pretrained(self):
17481749

17491750
@require_python39_or_higher
17501751
@require_torch_2
1752+
@unittest.skipIf(
1753+
get_python_version == (3, 12),
1754+
reason="Torch Dynamo isn't yet supported for Python 3.12.",
1755+
)
17511756
def test_from_save_pretrained_dynamo(self):
17521757
run_test_in_subprocess(test_case=self, target_func=_test_from_save_pretrained_dynamo, inputs=None)
17531758

0 commit comments

Comments
 (0)