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.

Use stream for casting if enabled. (#7833)

comfyanonymousc8cd7ad795ec
diff --git a/comfy/model_management.py b/comfy/model_management.py
index d118f6b91..516b6e2f1 100644
--- a/comfy/model_management.py
+++ b/comfy/model_management.py
@@ -980,6 +980,9 @@ def cast_to(weight, dtype=None, device=None, non_blocking=False, copy=False, str
if not copy:
if dtype is None or weight.dtype == dtype:
return weight
+ if stream is not None:
+ with stream:
+ return weight.to(dtype=dtype, copy=copy)
return weight.to(dtype=dtype, copy=copy)
if stream is not None: