Comfy-Org/ComfyUI · error · RuntimeError

ERROR: Could not detect model type of: {}\n{}

Error message

ERROR: Could not detect model type of: {}\n{}

What it means

load_checkpoint_guess_config tries every known checkpoint family (SD1.x/2.x, SDXL, SD3, Flux, AuraFlow, etc.) via load_state_dict_guess_config; when none matches the state dict's key signatures it returns None and this RuntimeError is raised with a hint from model_detection_error_hint. It means the file loaded as a tensor dict but its keys are not any format ComfyUI recognizes.

Source

Thrown at comfy/sd.py:2065

    if "parameterization" in model_config_params:
        if model_config_params["parameterization"] == "v":
            m = model.clone()
            class ModelSamplingAdvanced(comfy.model_sampling.ModelSamplingDiscrete, comfy.model_sampling.V_PREDICTION):
                pass
            m.add_object_patch("model_sampling", ModelSamplingAdvanced(model.model.model_config))
            model = m

    layer_idx = clip_config.get("params", {}).get("layer_idx", None)
    if layer_idx is not None:
        clip.clip_layer(layer_idx)

    return (model, clip, vae)

def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, output_clipvision=False, embedding_directory=None, output_model=True, model_options={}, te_model_options={}, disable_dynamic=False):
    sd, metadata = comfy.utils.load_torch_file(ckpt_path, return_metadata=True)
    out = load_state_dict_guess_config(sd, output_vae, output_clip, output_clipvision, embedding_directory, output_model, model_options, te_model_options=te_model_options, metadata=metadata, disable_dynamic=disable_dynamic)
    if out is None:
        raise RuntimeError("ERROR: Could not detect model type of: {}\n{}".format(ckpt_path, model_detection_error_hint(ckpt_path, sd)))
    if out[0] is not None:
        out[0].cached_patcher_init = (load_checkpoint_guess_config, (ckpt_path, False, False, False, embedding_directory, output_model, model_options, te_model_options), 0)
    # Register reload factories for the CLIP and VAE produced by the same checkpoint so
    # ModelPatcher.deepclone_multigpu can spawn per-device copies (Select{CLIP,VAE}Device,
    # MultiGPU work-units, etc.) without falling back to copy.deepcopy of an
    # already-loaded module.
    if out[1] is not None and getattr(out[1], "patcher", None) is not None:
        out[1].patcher.cached_patcher_init = (load_checkpoint_clip_patcher, (ckpt_path, embedding_directory, model_options, te_model_options))
    if out[2] is not None and getattr(out[2], "patcher", None) is not None:
        out[2].patcher.cached_patcher_init = (load_checkpoint_vae_patcher, (ckpt_path, embedding_directory, model_options, te_model_options))
    return out


def load_checkpoint_clip_patcher(ckpt_path, embedding_directory=None, model_options={}, te_model_options={}, disable_dynamic=False):
    """Reload only the CLIP patcher from a checkpoint. Used as the cached_patcher_init
    factory for the CLIP returned by load_checkpoint_guess_config."""
    _, clip, _, _ = load_checkpoint_guess_config(
        ckpt_path,

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Read the error's second line (model_detection_error_hint) — it prints sample keys from the file to help identify what it actually is.
  2. Confirm the file is a full diffusion checkpoint and not a LoRA/VAE/CLIP/embedding; load it with the matching loader node instead.
  3. If keys carry an unexpected wrapper prefix (e.g. 'model.model.'), strip it so top-level detection keys ('model.diffusion_model.', 'cond_stage_model.', 'first_stage_model.') match.
  4. Re-download the checkpoint in case of truncation, or update ComfyUI if the architecture is newer than your install.

Example fix

# before
ckpt = 'sd_xl_lora.safetensors'  # LoRA loaded as checkpoint -> RuntimeError
model, clip, vae = load_checkpoint_guess_config(ckpt, output_vae=True, output_clip=True)

# after: use the right loader for each file type
# LoRA -> LoraLoader ; VAE -> VAELoader ; full checkpoint -> load_checkpoint_guess_config
Defensive patterns

Strategy: try-catch

Validate before calling

sd, _ = comfy.utils.load_torch_file(path, return_metadata=True)
top = next(iter(sd))
known = ('model.diffusion_model.', 'cond_stage_model.', 'first_stage_model.', 'model.model.',)
assert any(top.startswith(k) for k in known) or 'transformer.' in top, f'unrecognized checkpoint layout, first key: {top}'

Try / catch

try:
    out = load_checkpoint_guess_config(path, output_vae=True, output_clip=True)
except RuntimeError as e:
    if 'Could not detect model type' in str(e):
        raise SystemExit(f'{path} is not a recognized full checkpoint; use the loader matching its type (LoRA/VAE/UNET).')
    raise

Prevention

When it happens

Trigger: Loading non-diffusion files (embeddings, VAEs, upscalers, random safetensors) as a checkpoint; heavily renamed/refactored state dicts; checkpoints saved with a 'model.diffusion_model.' prefix that ComfyUI's key detection expects to strip but that came mangled; encrypted/custom-architecture models.

Common situations: Selecting the wrong file in CheckpointLoader; downloading a model from a fork with non-standard key names; truncated downloads that lost the distinctive keys; Diffusers-format folders pointed at via a single file instead of the supported layout.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/cb83883c26c17ae1. Report an issue: GitHub.