Skip to content

Commit 2db86b4

Browse files
Slightly faster lora applying.
1 parent e134547 commit 2db86b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

comfy/model_management.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,12 @@ def cast_to_device(tensor, device, dtype, copy=False):
550550
if device_supports_cast:
551551
if copy:
552552
if tensor.device == device:
553-
return tensor.to(dtype, copy=copy)
554-
return tensor.to(device, copy=copy).to(dtype)
553+
return tensor.to(dtype, copy=copy, non_blocking=True)
554+
return tensor.to(device, copy=copy, non_blocking=True).to(dtype, non_blocking=True)
555555
else:
556-
return tensor.to(device).to(dtype)
556+
return tensor.to(device, non_blocking=True).to(dtype, non_blocking=True)
557557
else:
558-
return tensor.to(dtype).to(device, copy=copy)
558+
return tensor.to(device, dtype, copy=copy, non_blocking=True)
559559

560560
def xformers_enabled():
561561
global directml_enabled

0 commit comments

Comments
 (0)