From 3c3eba6b203b62fb4b0ab344a2d7cc52a765da1d Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Thu, 10 Jul 2025 09:55:36 +0530 Subject: [PATCH 1/2] account for MPS when available in get_device(). --- src/diffusers/utils/torch_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/diffusers/utils/torch_utils.py b/src/diffusers/utils/torch_utils.py index 61a5d95b6926..3f20f2beb466 100644 --- a/src/diffusers/utils/torch_utils.py +++ b/src/diffusers/utils/torch_utils.py @@ -175,6 +175,8 @@ def get_device(): return "npu" elif hasattr(torch, "xpu") and torch.xpu.is_available(): return "xpu" + elif torch.backends.mps.is_available() and hasattr(torch, "mps"): + return "mps" else: return "cpu" From 406a9ceb28e26e0339a15f28adb3a636080fb3ed Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Thu, 10 Jul 2025 13:12:55 +0530 Subject: [PATCH 2/2] fix --- src/diffusers/utils/torch_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffusers/utils/torch_utils.py b/src/diffusers/utils/torch_utils.py index 3f20f2beb466..c1fc1242bb10 100644 --- a/src/diffusers/utils/torch_utils.py +++ b/src/diffusers/utils/torch_utils.py @@ -175,7 +175,7 @@ def get_device(): return "npu" elif hasattr(torch, "xpu") and torch.xpu.is_available(): return "xpu" - elif torch.backends.mps.is_available() and hasattr(torch, "mps"): + elif torch.backends.mps.is_available(): return "mps" else: return "cpu"