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.

ops: Put weight cast on the offload stream (#10697)

rattusc350009236e5
diff --git a/comfy/ops.py b/comfy/ops.py
index 733bff99d..96dffa85d 100644
--- a/comfy/ops.py
+++ b/comfy/ops.py
@@ -110,9 +110,9 @@ def cast_bias_weight(s, input=None, dtype=None, device=None, bias_dtype=None, of
for f in s.bias_function:
bias = f(bias)
- weight = weight.to(dtype=dtype)
- if weight_has_function:
+ if weight_has_function or weight.dtype != dtype:
with wf_context:
+ weight = weight.to(dtype=dtype)
for f in s.weight_function:
weight = f(weight)