Skip to content

Instantly share code, notes, and snippets.

@niw
Last active December 6, 2024 03:36
Show Gist options
  • Save niw/c6c6b9b01ffeba548deaed32a4deb9a1 to your computer and use it in GitHub Desktop.
Save niw/c6c6b9b01ffeba548deaed32a4deb9a1 to your computer and use it in GitHub Desktop.
A quick patch to make Mochi VAE works on macOS
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