Last active
December 6, 2024 03:36
-
-
Save niw/c6c6b9b01ffeba548deaed32a4deb9a1 to your computer and use it in GitHub Desktop.
A quick patch to make Mochi VAE works on macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/comfy/ldm/genmo/vae/model.py b/comfy/ldm/genmo/vae/model.py | |
index b68d48a..694b33a 100644 | |
--- a/comfy/ldm/genmo/vae/model.py | |
+++ b/comfy/ldm/genmo/vae/model.py | |
@@ -78,7 +78,12 @@ class PConv3d(ops.Conv3d): | |
# Apply padding. | |
assert self.padding_mode == "replicate" # DEBUG | |
mode = "constant" if self.padding_mode == "zeros" else self.padding_mode | |
+ is_mps_device = x.device.type == "mps" | |
+ if is_mps_device: | |
+ x = x.to("cpu") | |
x = F.pad(x, (0, 0, 0, 0, pad_front, pad_back), mode=mode) | |
+ if is_mps_device: | |
+ x = x.to("mps") | |
return super().forward(x) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment