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 ernie on devices that don't support fp64. (#13414)

comfyanonymouscb0bbde402cf
diff --git a/comfy/ldm/ernie/model.py b/comfy/ldm/ernie/model.py
index 3dbab8dc0..f7cdb51e6 100644
--- a/comfy/ldm/ernie/model.py
+++ b/comfy/ldm/ernie/model.py
@@ -15,7 +15,7 @@ def rope(pos: torch.Tensor, dim: int, theta: int) -> torch.Tensor:
scale = torch.arange(0, dim, 2, dtype=torch.float64, device=device) / dim
omega = 1.0 / (theta**scale)
- out = torch.einsum("...n,d->...nd", pos, omega)
+ out = torch.einsum("...n,d->...nd", pos.to(device), omega)
out = torch.stack([torch.cos(out), torch.sin(out)], dim=0)
return out.to(dtype=torch.float32, device=pos.device)