Merge branch 'comfyanonymous:master' into refactor/onprompt

This commit is contained in:
Dr.Lt.Data 2023-07-04 15:31:17 +09:00 committed by GitHub
commit 5de7d30bea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -456,7 +456,13 @@ def mps_mode():
def is_device_cpu(device): def is_device_cpu(device):
if hasattr(device, 'type'): if hasattr(device, 'type'):
if (device.type == 'cpu' or device.type == 'mps'): if (device.type == 'cpu'):
return True
return False
def is_device_mps(device):
if hasattr(device, 'type'):
if (device.type == 'mps'):
return True return True
return False return False
@ -468,7 +474,7 @@ def should_use_fp16(device=None, model_params=0):
return True return True
if device is not None: #TODO if device is not None: #TODO
if is_device_cpu(device): if is_device_cpu(device) or is_device_mps(device):
return False return False
if FORCE_FP32: if FORCE_FP32:

View File

@ -46,9 +46,11 @@ class ModelMergeBlocks:
ratio = default_ratio ratio = default_ratio
k_unet = k[len("diffusion_model."):] k_unet = k[len("diffusion_model."):]
last_arg_size = 0
for arg in kwargs: for arg in kwargs:
if k_unet.startswith(arg): if k_unet.startswith(arg) and last_arg_size < len(arg):
ratio = kwargs[arg] ratio = kwargs[arg]
last_arg_size = len(arg)
m.add_patches({k: (sd[k], )}, 1.0 - ratio, ratio) m.add_patches({k: (sd[k], )}, 1.0 - ratio, ratio)
return (m, ) return (m, )