Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

model_patcher: guard against none model_dtype (#12410)

rattus3fe61cedda09
diff --git a/comfy/model_patcher.py b/comfy/model_patcher.py
index 224e218e3..f278fccac 100644
--- a/comfy/model_patcher.py
+++ b/comfy/model_patcher.py
@@ -1525,7 +1525,7 @@ class ModelPatcherDynamic(ModelPatcher):
setattr(m, param_key + "_function", weight_function)
geometry = weight
if not isinstance(weight, QuantizedTensor):
- model_dtype = getattr(m, param_key + "_comfy_model_dtype", weight.dtype)
+ model_dtype = getattr(m, param_key + "_comfy_model_dtype", None) or weight.dtype
weight._model_dtype = model_dtype
geometry = comfy.memory_management.TensorGeometry(shape=weight.shape, dtype=model_dtype)
return comfy.memory_management.vram_aligned_size(geometry)
@@ -1551,7 +1551,7 @@ class ModelPatcherDynamic(ModelPatcher):
weight.seed_key = key
set_dirty(weight, dirty)
geometry = weight
- model_dtype = getattr(m, param + "_comfy_model_dtype", weight.dtype)
+ model_dtype = getattr(m, param + "_comfy_model_dtype", None) or weight.dtype
geometry = comfy.memory_management.TensorGeometry(shape=weight.shape, dtype=model_dtype)
weight_size = geometry.numel() * geometry.element_size()
if vbar is not None and not hasattr(weight, "_v"):