From c8cd7ad795ec4ecc5256bdfe2c12c352eef26e3b Mon Sep 17 00:00:00 2001 From: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Date: Sun, 27 Apr 2025 02:38:11 -0700 Subject: [PATCH] Use stream for casting if enabled. (#7833) --- comfy/model_management.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/comfy/model_management.py b/comfy/model_management.py index d118f6b9..516b6e2f 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: