invoke-ai/InvokeAI · error · NotAMatchError
invalid class name from config: {actual_class_name}
Error message
invalid class name from config: {actual_class_name} What it means
raise_for_class_name extracts the class name from the model's config dict and checks membership in the expected class_name set. If the config's `_class_name`/`architectures` value is not among the expected names, it raises NotAMatchError. This is how InvokeAI rejects models whose pipeline class differs from the config class being probed.
Source
Thrown at invokeai/backend/model_manager/configs/identification_utils.py:129
return config_class_name
def raise_for_class_name(config: Path | set[Path] | dict[str, Any], class_name: str | set[str]) -> None:
"""Get the class name from the config file and raise NotAMatch if it is not in the expected set.
Args:
config_path: The path to the config file, or a set of paths to try.
class_name: The expected class name, or a set of expected class names.
Raises:
NotAMatch if the class name is not in the expected set.
"""
class_name = {class_name} if isinstance(class_name, str) else class_name
actual_class_name = get_class_name_from_config_dict_or_raise(config)
if actual_class_name not in class_name:
raise NotAMatchError(f"invalid class name from config: {actual_class_name}")
def raise_for_override_fields(candidate_config_class: type[BaseModel], override_fields: dict[str, Any]) -> None:
"""Check if the provided override fields are valid for the config class using pydantic.
For example, if the candidate config class has a field "base" of type Literal[BaseModelType.StableDiffusion1], and
the override fields contain "base": BaseModelType.Flux, this function will raise NotAMatch.
Internally, this function extracts the pydantic schema for each individual override field from the candidate config
class and validates the override value against that schema. Post-instantiation validators are not run.
Args:
candidate_config_class: The config class that is being tested.
override_fields: The override fields provided by the user.
Raises:
NotAMatch if any override field is invalid for the config class.
"""View on GitHub (pinned to 0b6a024f2f)
Solutions
- Open the model's config.json / model_index.json and read the actual _class_name value.
- Register the model under the InvokeAI config class matching that actual class name instead of the one you tried.
- If the class name changed across library versions, update the InvokeAI model config records or InvokeAI itself to a version that knows the new name.
- Move the model to the correct directory/type so the right probe matches.
Example fix
// before: probing a model whose config says _class_name: "Flux2Pipeline" with the Flux1 validator
raise_for_class_name(config, "FluxPipeline")
// after
raise_for_class_name(config, {"FluxPipeline", "Flux2Pipeline"}) # or use the matching config class Defensive patterns
Strategy: validation
Validate before calling
import json, pathlib
actual = json.loads(pathlib.Path(path, "model_index.json").read_text()).get("_class_name")
assert actual in EXPECTED_CLASS_NAMES, f"model is {actual}, expected one of {EXPECTED_CLASS_NAMES}" Type guard
def has_expected_class_name(cfg: dict, expected: set[str]) -> bool:
name = cfg.get("_class_name")
return isinstance(name, str) and name in expected Try / catch
try:
record = from_model_on_disk(mod)
except NotAMatchError as e:
if "invalid class name" in str(e):
logger.info("model class does not match any candidate config: %s", e) Prevention
- Match the registered config record to the pipeline class actually declared in model_index.json
- Watch for pipeline class renames across diffusers versions
- Keep model directories organized by architecture
When it happens
Trigger: Calling from_model_on_disk for a specific config class (e.g. _validate_looks_like_flux_diffusers, _validate_looks_like_z_image_diffusers, _validate_looks_like_flux2_diffusers) when the model's config declares a different _class_name/architectures than the class being tried.
Common situations: Pointing a model folder at the wrong config record; diffusers updated the pipeline class name between versions (e.g. renamed pipelines); a model variant (e.g. a LoRA or unrelated pipeline) stored in a directory expected to hold a different architecture.
Related errors
- Selected model provider '{model_config.provider_id}' does no
- Unsupported IP-Adapter base type: '{ip_adapter_info.base}'.
- _class_name or architectures field is not a string: {config_
- Failed to remove image from board
- Failed to get intermediates
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/dad093fcc483c61b.
Report an issue: GitHub.