Use stream for casting if enabled. (#7833)

This commit is contained in:
comfyanonymous 2025-04-27 02:38:11 -07:00 committed by GitHub
parent 542b4b36b6
commit c8cd7ad795
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: