invoke-ai/InvokeAI · error · ValueError

Unexpected model config type: {type(config)}.

Error message

Unexpected model config type: {type(config)}.

What it means

The FLUX XLabs IP-Adapter loader's _load_model only accepts configs deriving from IPAdapter_Checkpoint_Config_Base. If some other config object reaches this loader (registry misconfiguration, wrong model type on the record, or passing a config manually), it raises ValueError naming the unexpected type.

Source

Thrown at invokeai/backend/model_manager/load/model_loaders/flux.py:1528

        with accelerate.init_empty_weights():
            model = InstantXControlNetFlux(flux_params, num_control_modes)

        model.load_state_dict(sd, assign=True)
        return model


@ModelLoaderRegistry.register(base=BaseModelType.Flux, type=ModelType.IPAdapter, format=ModelFormat.Checkpoint)
class FluxIpAdapterModel(ModelLoader):
    """Class to load FLUX IP-Adapter models."""

    def _load_model(
        self,
        config: AnyModelConfig,
        submodel_type: Optional[SubModelType] = None,
    ) -> AnyModel:
        if not isinstance(config, IPAdapter_Checkpoint_Config_Base):
            raise ValueError(f"Unexpected model config type: {type(config)}.")

        sd = load_file(Path(config.path))

        params = infer_xlabs_ip_adapter_params_from_state_dict(sd)

        with accelerate.init_empty_weights():
            model = XlabsIpAdapterFlux(params=params)

        model.load_xlabs_state_dict(sd, assign=True)
        return model


@ModelLoaderRegistry.register(base=BaseModelType.Flux, type=ModelType.FluxRedux, format=ModelFormat.Checkpoint)
class FluxReduxModelLoader(ModelLoader):
    """Class to load FLUX Redux models."""

    def _load_model(
        self,

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Ensure the model record is imported/registered as an IP-Adapter (FLUX XLabs) so the correct config class is used.
  2. Pass a config that subclasses IPAdapter_Checkpoint_Config_Base, not a generic main-model config.
  3. Fix the registry wiring so the config routes to the loader matching its class.

Example fix

// before
model = XLabsFluxIPAdapterLoader()._load_model(some_main_config)
// after
if not isinstance(some_main_config, IPAdapter_Checkpoint_Config_Base):
    raise TypeError("Expected an XLabs IP-Adapter checkpoint config")
model = XLabsFluxIPAdapterLoader()._load_model(some_main_config)
Defensive patterns

Strategy: type-guard

Validate before calling

if not isinstance(config, IPAdapter_Checkpoint_Config_Base):
    raise TypeError(f"Expected XLabs IP-Adapter config, got {type(config).__name__}")

Type guard

def is_xlabs_ip_adapter(config) -> bool:
    return isinstance(config, IPAdapter_Checkpoint_Config_Base)

Try / catch

try:
    model = loader._load_model(config, submodel_type)
except ValueError as e:
    if "Unexpected model config type" in str(e):
        raise RuntimeError("Config routed to wrong loader; re-scan the model") from e
    raise

Prevention

When it happens

Trigger: Calling this loader's _load_model directly, or a registry lookup routing a non-IP-Adapter FLUX config into the XLabs IP-Adapter loader class.

Common situations: Custom scripts feeding arbitrary AnyModelConfig objects into loaders; a model record whose type was mis-edited in the database; developing a new IP-Adapter config class that does not subclass IPAdapter_Checkpoint_Config_Base.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/04222b1c9a8642eb. Report an issue: GitHub.