Comfy-Org/ComfyUI · error · NotImplementedError
ObjectPatchHook is not supported yet in ComfyUI.
Error message
ObjectPatchHook is not supported yet in ComfyUI.
What it means
Raised by ObjectPatchHook.add_hook_patches. The ObjectPatchHook class and its EnumHookType.ObjectPatch enum value exist for hook serialization/deserialization compatibility (e.g. hooks saved in workflows), but ComfyUI's execution engine never implemented applying object patches via hooks. Attempting to register one against a ModelPatcher always raises NotImplementedError.
Source
Thrown at comfy/hooks.py:204
c.need_weight_init = self.need_weight_init
c._strength_model = self._strength_model
c._strength_clip = self._strength_clip
return c
class ObjectPatchHook(Hook):
def __init__(self, object_patches: dict[str]=None,
hook_scope=EnumHookScope.AllConditioning):
super().__init__(hook_type=EnumHookType.ObjectPatch)
self.object_patches = object_patches
self.hook_scope = hook_scope
def clone(self):
c: ObjectPatchHook = super().clone()
c.object_patches = self.object_patches
return c
def add_hook_patches(self, model: ModelPatcher, model_options: dict, target_dict: dict[str], registered: HookGroup):
raise NotImplementedError("ObjectPatchHook is not supported yet in ComfyUI.")
class AdditionalModelsHook(Hook):
'''
Hook responsible for telling model management any additional models that should be loaded.
Note, value of hook_scope is ignored and is treated as AllConditioning.
'''
def __init__(self, models: list[ModelPatcher]=None, key: str=None):
super().__init__(hook_type=EnumHookType.AdditionalModels)
self.models = models
self.key = key
def clone(self):
c: AdditionalModelsHook = super().clone()
c.models = self.models.copy() if self.models else self.models
c.key = self.key
return c
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Replace ObjectPatchHook usage with model patching via ModelPatcher.add_object_patch applied directly at the node level
- If the workflow came from another fork, install that fork/extension or strip the object-patch hooks before loading
- If you are building hook support, implement the logic in your own Hook subclass rather than calling the stock add_hook_patches
Example fix
# before
hook = hooks.ObjectPatchHook(object_patches={'diffusion_model.blocks.0': patch})
group.add(hook) # later raises NotImplementedError
# after
model_patcher.add_object_patch('diffusion_model.blocks.0', patch) Defensive patterns
Strategy: type-guard
Validate before calling
from comfy import hooks
hook = hooks.ObjectPatchHook(...)
if type(hook).add_hook_patches is hooks.ObjectPatchHook.add_hook_patches:
raise RuntimeError('ObjectPatchHook is unimplemented; use model_patcher.add_object_patch') Type guard
def hook_is_applicable(hook) -> bool:
return not isinstance(hook, comfy.hooks.ObjectPatchHook) Try / catch
try:
hook.add_hook_patches(model_patcher, model_options, target_dict, group)
except NotImplementedError:
model_patcher.add_object_patch(key, patch) Prevention
- Prefer ModelPatcher.add_object_patch over hook-based object patches in stock ComfyUI
- Strip hook types you do not control from imported workflows
When it happens
Trigger: Constructing an ObjectPatchHook(object_patches={...}) and calling add_hook_patches on it (directly or through HookGroup registration during conditioning application). Loading a workflow that serialized an object-patch hook from a fork/extension that does support it (e.g. ComfyUI-Lightning-style weight hooks) into stock ComfyUI.
Common situations: Users moving workflows between ComfyUI forks and stock ComfyUI; extension authors assuming all EnumHookType values are functional; deserializing hook payloads whose type index maps to ObjectPatch.
Related errors
- InjectionsHook is not supported yet in ComfyUI.
- Need at least {require_count} hooks to combine, but only had
- Unrecognized interpolation method '{method}'.
- Scalar feature is not implemented yet.
- Must flatten output.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/f1f26514389d8066.
Report an issue: GitHub.