{"record":{"id":"cb83883c26c17ae1","repo":"Comfy-Org/ComfyUI","slug":"error-could-not-detect-model-type-of-n","errorCode":null,"errorMessage":"ERROR: Could not detect model type of: {}\\n{}","messagePattern":"ERROR: Could not detect model type of: (.+?)\\\\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"comfy/sd.py","lineNumber":2065,"sourceCode":"    if \"parameterization\" in model_config_params:\n        if model_config_params[\"parameterization\"] == \"v\":\n            m = model.clone()\n            class ModelSamplingAdvanced(comfy.model_sampling.ModelSamplingDiscrete, comfy.model_sampling.V_PREDICTION):\n                pass\n            m.add_object_patch(\"model_sampling\", ModelSamplingAdvanced(model.model.model_config))\n            model = m\n\n    layer_idx = clip_config.get(\"params\", {}).get(\"layer_idx\", None)\n    if layer_idx is not None:\n        clip.clip_layer(layer_idx)\n\n    return (model, clip, vae)\n\ndef 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):\n    sd, metadata = comfy.utils.load_torch_file(ckpt_path, return_metadata=True)\n    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)\n    if out is None:\n        raise RuntimeError(\"ERROR: Could not detect model type of: {}\\n{}\".format(ckpt_path, model_detection_error_hint(ckpt_path, sd)))\n    if out[0] is not None:\n        out[0].cached_patcher_init = (load_checkpoint_guess_config, (ckpt_path, False, False, False, embedding_directory, output_model, model_options, te_model_options), 0)\n    # Register reload factories for the CLIP and VAE produced by the same checkpoint so\n    # ModelPatcher.deepclone_multigpu can spawn per-device copies (Select{CLIP,VAE}Device,\n    # MultiGPU work-units, etc.) without falling back to copy.deepcopy of an\n    # already-loaded module.\n    if out[1] is not None and getattr(out[1], \"patcher\", None) is not None:\n        out[1].patcher.cached_patcher_init = (load_checkpoint_clip_patcher, (ckpt_path, embedding_directory, model_options, te_model_options))\n    if out[2] is not None and getattr(out[2], \"patcher\", None) is not None:\n        out[2].patcher.cached_patcher_init = (load_checkpoint_vae_patcher, (ckpt_path, embedding_directory, model_options, te_model_options))\n    return out\n\n\ndef load_checkpoint_clip_patcher(ckpt_path, embedding_directory=None, model_options={}, te_model_options={}, disable_dynamic=False):\n    \"\"\"Reload only the CLIP patcher from a checkpoint. Used as the cached_patcher_init\n    factory for the CLIP returned by load_checkpoint_guess_config.\"\"\"\n    _, clip, _, _ = load_checkpoint_guess_config(\n        ckpt_path,","sourceCodeStart":2047,"sourceCodeEnd":2083,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/sd.py#L2047-L2083","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the error's second line (model_detection_error_hint) — it prints sample keys from the file to help identify what it actually is.","Confirm the file is a full diffusion checkpoint and not a LoRA/VAE/CLIP/embedding; load it with the matching loader node instead.","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.","Re-download the checkpoint in case of truncation, or update ComfyUI if the architecture is newer than your install."],"exampleFix":"# before\nckpt = 'sd_xl_lora.safetensors'  # LoRA loaded as checkpoint -> RuntimeError\nmodel, clip, vae = load_checkpoint_guess_config(ckpt, output_vae=True, output_clip=True)\n\n# after: use the right loader for each file type\n# LoRA -> LoraLoader ; VAE -> VAELoader ; full checkpoint -> load_checkpoint_guess_config","handlingStrategy":"try-catch","validationCode":"sd, _ = comfy.utils.load_torch_file(path, return_metadata=True)\ntop = next(iter(sd))\nknown = ('model.diffusion_model.', 'cond_stage_model.', 'first_stage_model.', 'model.model.',)\nassert any(top.startswith(k) for k in known) or 'transformer.' in top, f'unrecognized checkpoint layout, first key: {top}'","typeGuard":null,"tryCatchPattern":"try:\n    out = load_checkpoint_guess_config(path, output_vae=True, output_clip=True)\nexcept RuntimeError as e:\n    if 'Could not detect model type' in str(e):\n        raise SystemExit(f'{path} is not a recognized full checkpoint; use the loader matching its type (LoRA/VAE/UNET).')\n    raise","preventionTips":["Match each file type to its dedicated loader node (Checkpoint, LoRA, VAE, UNET).","Use the key hint printed in the error to identify mislabeled files.","Keep a naming convention that distinguishes full checkpoints from component files."],"tags":["checkpoint-loading","model-detection","file-format"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}