invoke-ai/InvokeAI · error · ValueError
Model config discriminator value must be computed from a dic
Error message
Model config discriminator value must be computed from a dict or ModelConfigBase instance
What it means
get_model_discriminator_value computes a string discriminator used to pick the right ModelConfigBase subclass. It only accepts either a raw config dict or an already-instantiated ModelConfigBase; anything else (None, a path, a string, arbitrary object) reaches the final else branch and raises this ValueError. It is an internal typing/contract error in InvokeAI's model-manager config resolution.
Source
Thrown at invokeai/backend/model_manager/configs/base.py:204
# Special case: CLIP Embed models also need the variant to distinguish them.
if (
type_ == ModelType.CLIPEmbed.value
and format_ == ModelFormat.Diffusers.value
and base_ == BaseModelType.Any.value
):
if variant_ := v.get("variant"):
if isinstance(variant_, Enum):
variant_ = variant_.value
elif not isinstance(variant_, str):
raise ValueError("Model config dict 'variant' field must be a string or Enum")
tag_strings.append(variant_)
else:
raise ValueError("CLIP Embed model config dict must include a 'variant' field")
return ".".join(tag_strings)
else:
raise ValueError(
"Model config discriminator value must be computed from a dict or ModelConfigBase instance"
)
@classmethod
@abstractmethod
def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:
"""Given the model on disk and any override fields, attempt to construct an instance of this config class.
This method serves to identify whether the model on disk matches this config class, and if so, to extract any
additional metadata needed to instantiate the config.
Implementations should raise a NotAMatchError if the model does not match this config class."""
raise NotImplementedError(f"from_model_on_disk not implemented for {cls.__name__}")
class Checkpoint_Config_Base(ABC, BaseModel):
"""Base class for checkpoint-style models."""
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Pass the loaded config dict or a ModelConfigBase instance instead of a path/object
- Before calling, check isinstance(value, (dict, ModelConfigBase)) and load/convert otherwise
- Inspect the caller that produced the value — it likely swallowed a load failure and returned None
- Upgrade/align InvokeAI versions; internal signature of discriminator resolution changed across releases
Example fix
// before discrim = get_model_discriminator_value(model_path) // after config = load_config_dict(model_path) # dict[str, Any] assert isinstance(config, dict) discrim = get_model_discriminator_value(config)
Defensive patterns
Strategy: type-guard
Validate before calling
from typing import Any
from invokeai.backend.model_manager.configs.base import ModelConfigBase
def can_compute_discriminator(value: Any) -> bool:
return isinstance(value, (dict, ModelConfigBase)) Type guard
def is_config_input(value: Any) -> bool:
return isinstance(value, (dict, ModelConfigBase)) Try / catch
try:
discrim = get_model_discriminator_value(value)
except ValueError as e:
if "discriminator value" in str(e):
value = value.config if hasattr(value, "config") else dict(value)
discrim = get_model_discriminator_value(value)
else:
raise Prevention
- Always load the config into a dict before discriminator resolution
- Never pass Path/str/model objects to get_model_discriminator_value
- Check loader return values for None before forwarding
- Pin InvokeAI versions when relying on internal config APIs
When it happens
Trigger: Calling get_model_discriminator_value with an argument that is neither a dict nor a ModelConfigBase instance — e.g. passing None, a Path/str model path, or a plain object instead of the config dict; also happens when upstream config-loading code fails to build the dict and silently forwards the wrong type.
Common situations: Custom probe/integration code that calls discriminator resolution directly; passing a ModelOnDisk or path where the loaded config dict was expected; a subclassed config pipeline that returns None from a loader and forwards it.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- Unsupported control_lllite type: {type(control_lllite)}
- Expected ModelPatchRaw for LoRA '{lora.lora.key}', got {type
- Expected torch.Tensor for prompt embeddings, got {type(promp
- Expected ModelPatchRaw for LoRA '{lora.lora.key}', got {type
- Failed to load api keys file {api_keys_file_path}: value for
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/6b4ee337d427faf0.
Report an issue: GitHub.