The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Work around black image bug on Mac 14.5 by forcing attention upcasting.
comfyanonymous8508df25691b
diff --git a/comfy/ldm/modules/attention.py b/comfy/ldm/modules/attention.pyindex 2ce99d460..93c944589 100644--- a/comfy/ldm/modules/attention.py+++ b/comfy/ldm/modules/attention.py@@ -19,12 +19,13 @@ from comfy.cli_args import argsimport comfy.opsops = comfy.ops.disable_weight_init+FORCE_UPCAST_ATTENTION_DTYPE = model_management.force_upcast_attention_dtype()def get_attn_precision(attn_precision):if args.dont_upcast_attention:return None- if attn_precision is None and args.force_upcast_attention:- return torch.float32+ if FORCE_UPCAST_ATTENTION_DTYPE is not None:+ return FORCE_UPCAST_ATTENTION_DTYPEreturn attn_precisiondef exists(val):diff --git a/comfy/model_management.py b/comfy/model_management.pyindex b21928628..fbfbb7e4c 100644--- a/comfy/model_management.py+++ b/comfy/model_management.py@@ -5,6 +5,7 @@ from comfy.cli_args import argsimport comfy.utilsimport torchimport sys+import platformclass VRAMState(Enum):DISABLED = 0 #No vram present: no need to move models to vram@@ -685,6 +686,18 @@ def pytorch_attention_flash_attention():return Truereturn False+def force_upcast_attention_dtype():+ upcast = args.force_upcast_attention+ try:+ if platform.mac_ver()[0] in ['14.5']: #black image bug on OSX Sonoma 14.5+ upcast = True+ except:+ pass+ if upcast:+ return torch.float32+ else:+ return None+def get_free_memory(dev=None, torch_free_too=False):global directml_enabledif dev is None: