Comfy-Org/ComfyUI · error · RuntimeError
Cannot create non-dynamic delegate: cached_patcher_init is n
Error message
Cannot create non-dynamic delegate: cached_patcher_init is not initialized.
What it means
Cloning a dynamic ModelPatcher into a non-dynamic delegate requires re-instantiating the model through the loader factory stored in cached_patcher_init. If that factory was never registered (custom loader bypassed the core loader plumbing), the clone path has no way to rebuild a clean model and raises RuntimeError rather than producing a half-configured delegate.
Source
Thrown at comfy/model_patcher.py:437
#the vast majority of setups a little bit of offloading on the giant model more
#than pays for CFG. So return everything both torch and Aimdo could give us
aimdo_mem = 0
if comfy.memory_management.aimdo_enabled:
aimdo_device = device.index if getattr(device, "type", None) == "cuda" else None
aimdo_mem = comfy_aimdo.model_vbar.vbars_analyze(aimdo_device)
return comfy.model_management.get_free_memory(device) + aimdo_mem
def get_clone_model_override(self):
return self.model, (self.backup, self.backup_buffers, self.object_patches_backup, self.pinned)
def clone(self, disable_dynamic=False, model_override=None, force_deepcopy=False):
class_ = self.__class__
if self.is_dynamic() and disable_dynamic or force_deepcopy:
if self.is_dynamic() and disable_dynamic:
class_ = ModelPatcher
if model_override is None:
if self.cached_patcher_init is None:
raise RuntimeError("Cannot create non-dynamic delegate: cached_patcher_init is not initialized.")
temp_model_patcher = self.cached_patcher_init[0](*self.cached_patcher_init[1], disable_dynamic=True)
if len(self.cached_patcher_init) > 2:
temp_model_patcher = temp_model_patcher[self.cached_patcher_init[2]]
model_override = temp_model_patcher.get_clone_model_override()
if model_override is None:
model_override = self.get_clone_model_override()
n = class_(model_override[0], self.load_device, self.offload_device, self.model_size(), weight_inplace_update=self.weight_inplace_update)
n.patches = {}
for k in self.patches:
n.patches[k] = self.patches[k][:]
n.patches_uuid = self.patches_uuid
n.object_patches = self.object_patches.copy()
n.weight_wrapper_patches = self.weight_wrapper_patches.copy()
n.model_options = comfy.utils.deepcopy_list_dict(self.model_options)
n.parent = self
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Load the model with a core loader (CheckpointLoaderSimple, UNETLoader, CLIPLoader/DualCLIPLoader, VAELoader) so cached_patcher_init is registered.
- If you maintain the custom loader, register a cached_patcher_init factory that rebuilds the patcher from the checkpoint.
- As a user, drop --fast startup arguments when working with models from custom loaders.
Defensive patterns
Strategy: validation
Validate before calling
patcher = loader_output
if getattr(patcher, "is_dynamic", lambda: False)() and patcher.cached_patcher_init is None:
raise RuntimeError("custom loader did not register cached_patcher_init; cannot make non-dynamic clone")
clone = patcher.clone(disable_dynamic=True) Type guard
def supports_dynamic_delegate(patcher) -> bool:
return (not patcher.is_dynamic()) or patcher.cached_patcher_init is not None Prevention
- Prefer core loaders for models that will be cloned or used with hooks.
- Custom loader authors: register cached_patcher_init when constructing the ModelPatcher.
- Avoid --fast when mixing custom loaders into the workflow.
When it happens
Trigger: patcher.clone(disable_dynamic=True) or clone(force_deepcopy=True) on a ModelPatcher whose cached_patcher_init is None — typically a patcher returned by a custom node loader that constructed ModelPatcher directly.
Common situations: Using --fast (dynamic patcher) together with a custom-node model loader; nodes that call clone(disable_dynamic=True) for hooks or sampling on models from non-core loaders; older custom loaders not updated for the cached_patcher_init contract.
Related errors
- Cannot create multigpu deepclone of {self.model.__class__.__
- Hooks not implemented in ModelPatcherDynamic. Please remove
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/45f6e344d0149906.
Report an issue: GitHub.