mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-24 01:12:37 +08:00
Merge branch 'master' into feat/api-nodes/SD2-realhuman
This commit is contained in:
commit
99aacfaa62
@ -578,8 +578,8 @@ class Stable_Zero123(BaseModel):
|
|||||||
def __init__(self, model_config, model_type=ModelType.EPS, device=None, cc_projection_weight=None, cc_projection_bias=None):
|
def __init__(self, model_config, model_type=ModelType.EPS, device=None, cc_projection_weight=None, cc_projection_bias=None):
|
||||||
super().__init__(model_config, model_type, device=device)
|
super().__init__(model_config, model_type, device=device)
|
||||||
self.cc_projection = comfy.ops.manual_cast.Linear(cc_projection_weight.shape[1], cc_projection_weight.shape[0], dtype=self.get_dtype(), device=device)
|
self.cc_projection = comfy.ops.manual_cast.Linear(cc_projection_weight.shape[1], cc_projection_weight.shape[0], dtype=self.get_dtype(), device=device)
|
||||||
self.cc_projection.weight.copy_(cc_projection_weight)
|
self.cc_projection.weight = torch.nn.Parameter(cc_projection_weight.clone())
|
||||||
self.cc_projection.bias.copy_(cc_projection_bias)
|
self.cc_projection.bias = torch.nn.Parameter(cc_projection_bias.clone())
|
||||||
|
|
||||||
def extra_conds(self, **kwargs):
|
def extra_conds(self, **kwargs):
|
||||||
out = {}
|
out = {}
|
||||||
|
|||||||
@ -1801,7 +1801,7 @@ def debug_memory_summary():
|
|||||||
return torch.cuda.memory.memory_summary()
|
return torch.cuda.memory.memory_summary()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
class InterruptProcessingException(Exception):
|
class InterruptProcessingException(BaseException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
interrupt_processing_mutex = threading.RLock()
|
interrupt_processing_mutex = threading.RLock()
|
||||||
|
|||||||
@ -685,9 +685,9 @@ class ModelPatcher:
|
|||||||
sd.pop(k)
|
sd.pop(k)
|
||||||
return sd
|
return sd
|
||||||
|
|
||||||
def patch_weight_to_device(self, key, device_to=None, inplace_update=False, return_weight=False):
|
def patch_weight_to_device(self, key, device_to=None, inplace_update=False, return_weight=False, force_cast=False):
|
||||||
weight, set_func, convert_func = get_key_weight(self.model, key)
|
weight, set_func, convert_func = get_key_weight(self.model, key)
|
||||||
if key not in self.patches:
|
if key not in self.patches and not force_cast:
|
||||||
return weight
|
return weight
|
||||||
|
|
||||||
inplace_update = self.weight_inplace_update or inplace_update
|
inplace_update = self.weight_inplace_update or inplace_update
|
||||||
@ -695,7 +695,7 @@ class ModelPatcher:
|
|||||||
if key not in self.backup and not return_weight:
|
if key not in self.backup and not return_weight:
|
||||||
self.backup[key] = collections.namedtuple('Dimension', ['weight', 'inplace_update'])(weight.to(device=self.offload_device, copy=inplace_update), inplace_update)
|
self.backup[key] = collections.namedtuple('Dimension', ['weight', 'inplace_update'])(weight.to(device=self.offload_device, copy=inplace_update), inplace_update)
|
||||||
|
|
||||||
temp_dtype = comfy.model_management.lora_compute_dtype(device_to)
|
temp_dtype = comfy.model_management.lora_compute_dtype(device_to) if key in self.patches else None
|
||||||
if device_to is not None:
|
if device_to is not None:
|
||||||
temp_weight = comfy.model_management.cast_to_device(weight, device_to, temp_dtype, copy=True)
|
temp_weight = comfy.model_management.cast_to_device(weight, device_to, temp_dtype, copy=True)
|
||||||
else:
|
else:
|
||||||
@ -703,9 +703,10 @@ class ModelPatcher:
|
|||||||
if convert_func is not None:
|
if convert_func is not None:
|
||||||
temp_weight = convert_func(temp_weight, inplace=True)
|
temp_weight = convert_func(temp_weight, inplace=True)
|
||||||
|
|
||||||
out_weight = comfy.lora.calculate_weight(self.patches[key], temp_weight, key)
|
out_weight = comfy.lora.calculate_weight(self.patches[key], temp_weight, key) if key in self.patches else temp_weight
|
||||||
if set_func is None:
|
if set_func is None:
|
||||||
out_weight = comfy.float.stochastic_rounding(out_weight, weight.dtype, seed=comfy.utils.string_to_seed(key))
|
if key in self.patches:
|
||||||
|
out_weight = comfy.float.stochastic_rounding(out_weight, weight.dtype, seed=comfy.utils.string_to_seed(key))
|
||||||
if return_weight:
|
if return_weight:
|
||||||
return out_weight
|
return out_weight
|
||||||
elif inplace_update:
|
elif inplace_update:
|
||||||
@ -1584,7 +1585,7 @@ class ModelPatcherDynamic(ModelPatcher):
|
|||||||
key = key_param_name_to_key(n, param_key)
|
key = key_param_name_to_key(n, param_key)
|
||||||
if key in self.backup:
|
if key in self.backup:
|
||||||
comfy.utils.set_attr_param(self.model, key, self.backup[key].weight)
|
comfy.utils.set_attr_param(self.model, key, self.backup[key].weight)
|
||||||
self.patch_weight_to_device(key, device_to=device_to)
|
self.patch_weight_to_device(key, device_to=device_to, force_cast=True)
|
||||||
weight, _, _ = get_key_weight(self.model, key)
|
weight, _, _ = get_key_weight(self.model, key)
|
||||||
if weight is not None:
|
if weight is not None:
|
||||||
self.model.model_loaded_weight_memory += weight.numel() * weight.element_size()
|
self.model.model_loaded_weight_memory += weight.numel() * weight.element_size()
|
||||||
@ -1609,6 +1610,10 @@ class ModelPatcherDynamic(ModelPatcher):
|
|||||||
m._v = vbar.alloc(v_weight_size)
|
m._v = vbar.alloc(v_weight_size)
|
||||||
allocated_size += v_weight_size
|
allocated_size += v_weight_size
|
||||||
|
|
||||||
|
for param in params:
|
||||||
|
if param not in ("weight", "bias"):
|
||||||
|
force_load_param(self, param, device_to)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for param in params:
|
for param in params:
|
||||||
key = key_param_name_to_key(n, param)
|
key = key_param_name_to_key(n, param)
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
comfyui_manager==4.1
|
comfyui_manager==4.2.1
|
||||||
|
|||||||
@ -39,7 +39,7 @@ def get_required_packages_versions():
|
|||||||
if len(s) == 2:
|
if len(s) == 2:
|
||||||
version_str = s[-1]
|
version_str = s[-1]
|
||||||
if not is_valid_version(version_str):
|
if not is_valid_version(version_str):
|
||||||
logging.error(f"Invalid version format in requirements.txt: {version_str}")
|
logging.debug(f"Invalid version format for {s[0]} in requirements.txt: {version_str}")
|
||||||
continue
|
continue
|
||||||
out[s[0]] = version_str
|
out[s[0]] = version_str
|
||||||
return out.copy()
|
return out.copy()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user