The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Small speed improvements to --async-offload (#10593)
rattus135fa49ec233
diff --git a/comfy/ops.py b/comfy/ops.pyindex 279f6b1a7..0c8f23848 100644--- a/comfy/ops.py+++ b/comfy/ops.py@@ -84,7 +84,8 @@ def cast_bias_weight(s, input=None, dtype=None, device=None, bias_dtype=None, ofif device is None:device = input.device- if offloadable:+ if offloadable and (device != s.weight.device or+ (s.bias is not None and device != s.bias.device)):offload_stream = comfy.model_management.get_offload_stream(device)else:offload_stream = None@@ -94,20 +95,24 @@ def cast_bias_weight(s, input=None, dtype=None, device=None, bias_dtype=None, ofelse:wf_context = contextlib.nullcontext()- bias = Nonenon_blocking = comfy.model_management.device_supports_non_blocking(device)++ weight_has_function = len(s.weight_function) > 0+ bias_has_function = len(s.bias_function) > 0++ weight = comfy.model_management.cast_to(s.weight, None, device, non_blocking=non_blocking, copy=weight_has_function, stream=offload_stream)++ bias = Noneif s.bias is not None:- has_function = len(s.bias_function) > 0- bias = comfy.model_management.cast_to(s.bias, bias_dtype, device, non_blocking=non_blocking, copy=has_function, stream=offload_stream)+ bias = comfy.model_management.cast_to(s.bias, bias_dtype, device, non_blocking=non_blocking, copy=bias_has_function, stream=offload_stream)- if has_function:+ if bias_has_function:with wf_context:for f in s.bias_function:bias = f(bias)- has_function = len(s.weight_function) > 0- weight = comfy.model_management.cast_to(s.weight, dtype, device, non_blocking=non_blocking, copy=has_function, stream=offload_stream)- if has_function:+ weight = weight.to(dtype=dtype)+ if weight_has_function:with wf_context:for f in s.weight_function:weight = f(weight)