invoke-ai/InvokeAI · error · NotAMatchError
state dict does not look like a main model
Error message
state dict does not look like a main model
What it means
Before accepting a main checkpoint config, InvokeAI checks the state dict against a heuristic set of keys expected in a main model (_has_main_keys). If none of the characteristic keys are present, the file is not treated as a main model and NotAMatchError is raised. Typically this means you scanned a VAE, LoRA, ControlNet, embedding, or an empty file rather than a full UNet checkpoint.
Source
Thrown at invokeai/backend/model_manager/configs/main.py:432
in_channels = state_dict["model.diffusion_model.input_blocks.0.0.weight"].shape[1]
match in_channels:
case 4:
return ModelVariantType.Normal
case 5:
# Only SD2 has a depth variant
assert base is BaseModelType.StableDiffusion2, f"unexpected unet in_channels 5 for base '{base}'"
return ModelVariantType.Depth
case 9:
return ModelVariantType.Inpaint
case _:
raise NotAMatchError(f"unrecognized unet in_channels {in_channels} for base '{base}'")
@classmethod
def _validate_looks_like_main_model(cls, mod: ModelOnDisk) -> None:
has_main_model_keys = _has_main_keys(mod.load_state_dict())
if not has_main_model_keys:
raise NotAMatchError("state dict does not look like a main model")
class Main_Checkpoint_SD1_Config(Main_SD_Checkpoint_Config_Base, Config_Base):
base: Literal[BaseModelType.StableDiffusion1] = Field(default=BaseModelType.StableDiffusion1)
class Main_Checkpoint_SD2_Config(Main_SD_Checkpoint_Config_Base, Config_Base):
base: Literal[BaseModelType.StableDiffusion2] = Field(default=BaseModelType.StableDiffusion2)
class Main_Checkpoint_SDXL_Config(Main_SD_Checkpoint_Config_Base, Config_Base):
base: Literal[BaseModelType.StableDiffusionXL] = Field(default=BaseModelType.StableDiffusionXL)
class Main_Checkpoint_SDXLRefiner_Config(Main_SD_Checkpoint_Config_Base, Config_Base):
base: Literal[BaseModelType.StableDiffusionXLRefiner] = Field(default=BaseModelType.StableDiffusionXLRefiner)
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Confirm the scanned file is the full checkpoint (contains model.diffusion_model.* UNet weights), not a VAE/LoRA/ControlNet.
- Re-check directory structure and scan the intended file; fix path mixups.
- Re-download if the file is truncated (very small file size).
- Inspect keys: sd.keys() should include UNet entries before import.
Example fix
// check first
from safetensors.torch import load_file
sd = load_file('model.safetensors')
assert any(k.startswith('model.diffusion_model') for k in sd), 'not a main checkpoint' Defensive patterns
Strategy: validation
Validate before calling
sd = mod.load_state_dict()
if not any(k.startswith(('model.diffusion_model', 'double_blocks', 'down_blocks')) for k in sd):
print('File does not look like a main model checkpoint') Type guard
def looks_like_main_model(sd: dict) -> bool:
from invokeai.backend.model_manager.configs.main import _has_main_keys
return _has_main_keys(sd) Try / catch
try:
cfg = probe_model(path)
except NotAMatchError as e:
if 'main model' in str(e):
print('Not a main checkpoint — classify as VAE/LoRA/ControlNet as appropriate') Prevention
- Organize model folders by type so scanners hit the right files
- Check file sizes and key names before import
- Download complete checkpoints (watch for truncation)
When it happens
Trigger: from_model_on_disk → _validate_looks_like_main_model on a state dict failing the main-keys heuristic — VAE files, LoRA files, ControlNet state dicts, text-encoder dumps, or files with pruned/renamed keys.
Common situations: Batch-scanning a models directory and hitting non-checkpoint files; picking the wrong file in a multi-file repo; all-in-one downloads where UNet keys are nested under unexpected prefixes.
Related errors
- Unrecognized LLLite module name: '{name}'
- State dict contains no LLLite modules (no 'lllite_dit_blocks
- LLLite module '{name}' is missing key '{down_key}'
- Unexpected key: {k}
- missing keys after fp8 load: {missing[:10]}
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/1273ba13410ecd01.
Report an issue: GitHub.