Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Fix potential tensors being on different devices issues.

comfyanonymous46dc050c9f5c
diff --git a/comfy/sd1_clip.py b/comfy/sd1_clip.py
index fbd87c569..c008e963a 100644
--- a/comfy/sd1_clip.py
+++ b/comfy/sd1_clip.py
@@ -32,7 +32,7 @@ class ClipTokenWeightEncoder:
output.append(z)
if (len(output) == 0):
- return z_empty, first_pooled
+ return z_empty.cpu(), first_pooled.cpu()
return torch.cat(output, dim=-2).cpu(), first_pooled.cpu()
class SD1ClipModel(torch.nn.Module, ClipTokenWeightEncoder):
@@ -139,7 +139,7 @@ class SD1ClipModel(torch.nn.Module, ClipTokenWeightEncoder):
pooled_output = outputs.pooler_output
if self.text_projection is not None:
- pooled_output = pooled_output @ self.text_projection
+ pooled_output = pooled_output.to(self.text_projection.device) @ self.text_projection
return z.float(), pooled_output.float()
def encode(self, tokens):