Skip to content

Commit f09adee

Browse files
[Tests] Skip layerwise casting tests on devices without float8_e4m3fn support (#14073)
* Skip layerwise casting tests on devices without float8_e4m3fn support * Xfail float8 layerwise casting tests on MPS --------- Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
1 parent ea80295 commit f09adee

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

tests/lora/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,6 +2105,11 @@ def test_correct_lora_configs_with_different_ranks(self):
21052105
self.assertTrue(not np.allclose(original_output, lora_output_diff_alpha, atol=1e-3, rtol=1e-3))
21062106
self.assertTrue(not np.allclose(lora_output_diff_alpha, lora_output_same_rank, atol=1e-3, rtol=1e-3))
21072107

2108+
@pytest.mark.xfail(
2109+
condition=torch_device == "mps",
2110+
reason="MPS does not support float8 casting.",
2111+
strict=True,
2112+
)
21082113
def test_layerwise_casting_inference_denoiser(self):
21092114
from diffusers.hooks._common import _GO_LC_SUPPORTED_PYTORCH_LAYERS
21102115
from diffusers.hooks.layerwise_casting import DEFAULT_SKIP_MODULES_PATTERN
@@ -2149,6 +2154,11 @@ def initialize_pipeline(storage_dtype=None, compute_dtype=torch.float32):
21492154
pipe_float8_e4m3_bf16 = initialize_pipeline(storage_dtype=torch.float8_e4m3fn, compute_dtype=torch.bfloat16)
21502155
pipe_float8_e4m3_bf16(**inputs, generator=torch.manual_seed(0))[0]
21512156

2157+
@pytest.mark.xfail(
2158+
condition=torch_device == "mps",
2159+
reason="MPS does not support float8 casting.",
2160+
strict=True,
2161+
)
21522162
@require_peft_version_greater("0.14.0")
21532163
def test_layerwise_casting_peft_input_autocast_denoiser(self):
21542164
r"""

tests/models/testing_utils/memory.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ class LayerwiseCastingTesterMixin:
383383
- get_dummy_inputs(): Returns dict of inputs to pass to the model forward pass
384384
"""
385385

386+
@pytest.mark.xfail(
387+
condition=torch_device == "mps",
388+
reason="MPS does not support float8 casting.",
389+
strict=True,
390+
)
386391
@torch.no_grad()
387392
def test_layerwise_casting_memory(self):
388393
MB_TOLERANCE = 0.2
@@ -436,6 +441,11 @@ def get_memory_usage(storage_dtype, compute_dtype):
436441
or abs(fp8_e4m3_fp32_max_memory - fp32_max_memory) < MB_TOLERANCE
437442
), "Peak memory should be lower or within tolerance with fp8 storage"
438443

444+
@pytest.mark.xfail(
445+
condition=torch_device == "mps",
446+
reason="MPS does not support float8 casting.",
447+
strict=True,
448+
)
439449
def test_layerwise_casting_training(self):
440450
def test_fn(storage_dtype, compute_dtype):
441451
if torch.device(torch_device).type == "cpu" and compute_dtype == torch.bfloat16:

tests/pipelines/test_pipelines_common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,11 @@ def test_save_load_dduf(self, atol=1e-4, rtol=1e-4):
22922292
elif isinstance(pipeline_out, torch.Tensor) and isinstance(loaded_pipeline_out, torch.Tensor):
22932293
assert torch.allclose(pipeline_out, loaded_pipeline_out, atol=atol, rtol=rtol)
22942294

2295+
@pytest.mark.xfail(
2296+
condition=torch_device == "mps",
2297+
reason="MPS does not support float8 casting.",
2298+
strict=True,
2299+
)
22952300
def test_layerwise_casting_inference(self):
22962301
if not self.test_layerwise_casting:
22972302
return

0 commit comments

Comments
 (0)