Describe the bug
When running the unit test suite on Apple Silicon (macOS) using the MPS backend (torch_device = "mps"), tests checking enable_layerwise_casting fail. This occurs because the MPS backend does not support the torch.float8_e4m3fn dtype.
Several test cases unconditionally configure layerwise casting with storage_dtype=torch.float8_e4m3fn, leading to a TypeError: Trying to convert Float8_e4m3fn to the MPS backend but it does not have support for that dtype. on MPS.
I intend to submit a pull request to fix this by dynamically skipping the tests when the active device doesn't support the float8_e4m3fn dtype.
Reproduction
On an Apple Silicon Mac:
python3 -m pytest tests/pipelines/krea2/test_krea2.py -k test_layerwise_casting_inference
Logs
=================================== FAILURES ===================================
___________ Krea2PipelineFastTests.test_layerwise_casting_inference ____________
self = <tests.pipelines.krea2.test_krea2.Krea2PipelineFastTests testMethod=test_layerwise_casting_inference>
def test_layerwise_casting_inference(self):
if not self.test_layerwise_casting:
return
components = self.get_dummy_components()
pipe = self.pipeline_class(**components)
pipe.to(torch_device, dtype=torch.bfloat16)
pipe.set_progress_bar_config(disable=None)
denoiser = pipe.transformer if hasattr(pipe, "transformer") else pipe.unet
> denoiser.enable_layerwise_casting(storage_dtype=torch.float8_e4m3fn, compute_dtype=torch.bfloat16)
tests/pipelines/test_pipelines_common.py:2305:
...
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py:1370: TypeError
E TypeError: Trying to convert Float8_e4m3fn to the MPS backend but it does not have support for that dtype.
System Info
- Diffusers version: 0.39.0.dev0
- Platform: macOS (Apple Silicon)
- Python version: 3.11.9
- PyTorch version: 2.11.0
- MPS available: True
Who can help?
@DN6 @sayakpaul @yiyixuxu
Describe the bug
When running the unit test suite on Apple Silicon (macOS) using the MPS backend (
torch_device = "mps"), tests checkingenable_layerwise_castingfail. This occurs because the MPS backend does not support thetorch.float8_e4m3fndtype.Several test cases unconditionally configure layerwise casting with
storage_dtype=torch.float8_e4m3fn, leading to aTypeError: Trying to convert Float8_e4m3fn to the MPS backend but it does not have support for that dtype.on MPS.I intend to submit a pull request to fix this by dynamically skipping the tests when the active device doesn't support the
float8_e4m3fndtype.Reproduction
On an Apple Silicon Mac:
Logs
System Info
Who can help?
@DN6 @sayakpaul @yiyixuxu