invoke-ai/InvokeAI · error · ValueError
Expected Main_SDNQ_Diffusers_FLUX_Config, got {type(config).
Error message
Expected Main_SDNQ_Diffusers_FLUX_Config, got {type(config).__name__} What it means
In the SDNQ FLUX diffusers loader, after the single-file branch is excluded, the config must be a Main_SDNQ_Diffusers_FLUX_Config. If it is neither, _load_model raises ValueError with the actual class name, guarding against configs routed to the wrong loader.
Source
Thrown at invokeai/backend/model_manager/load/model_loaders/flux.py:1592
config: AnyModelConfig,
submodel_type: Optional[SubModelType] = None,
) -> AnyModel:
logger.debug(
"[SDNQ] FluxSDNQDiffusersModel._load_model called with config=%s, submodel=%s",
type(config).__name__,
submodel_type,
)
# Handle single-file SDNQ checkpoint (Main_SDNQ_FLUX_Config)
if isinstance(config, Main_SDNQ_FLUX_Config):
if submodel_type == SubModelType.Transformer:
return self._load_sdnq_transformer_checkpoint(config)
raise ValueError(
f"Only Transformer submodels are supported for checkpoint format. Received: {submodel_type}"
)
# Handle diffusers-format SDNQ model (Main_SDNQ_Diffusers_FLUX_Config)
if not isinstance(config, Main_SDNQ_Diffusers_FLUX_Config):
raise ValueError(f"Expected Main_SDNQ_Diffusers_FLUX_Config, got {type(config).__name__}")
if submodel_type is None:
raise ValueError("A submodel type must be provided when loading main pipelines.")
# Prefer the path discovery actually found. `model_index.json` names its components with
# arbitrary keys, and identification records the key it saw — but reconstructing
# `model_path / submodel_type.value` here assumes the key always equals the slot name. A
# pipeline whose index calls its CLIP encoder something else is then discovered fine and
# loaded from a folder that does not exist. Fall back to the conventional name when a config
# predates submodel discovery.
model_path = Path(config.path)
submodel_path = resolve_submodel_path(config, submodel_type, model_path / submodel_type.value)
# These branches build their modules by hand (`init_empty_weights` + `load_state_dict`)
# rather than through `from_pretrained`, so they arrive in training mode — `put_in_eval_mode`
# in `load_default._load_and_cache` is what puts every loaded model into inference mode.
match submodel_type:
case SubModelType.Transformer:View on GitHub (pinned to 0b6a024f2f)
Solutions
- Re-scan the model so identification assigns the correct config class (standard FLUX vs SDNQ diffusers).
- Ensure the loader registry maps each config class to its proper loader.
- Construct Main_SDNQ_Diffusers_FLUX_Config explicitly if writing custom import code.
Example fix
// before
model = SdnqFluxLoader()._load_model(plain_flux_config, SubModelType.Transformer)
// after
if not isinstance(plain_flux_config, Main_SDNQ_Diffusers_FLUX_Config):
raise TypeError(f"{type(plain_flux_config).__name__} is not an SDNQ diffusers config; use the standard FLUX loader")
model = SdnqFluxLoader()._load_model(plain_flux_config, SubModelType.Transformer) Defensive patterns
Strategy: type-guard
Validate before calling
if not isinstance(config, (Main_SDNQ_FLUX_Config, Main_SDNQ_Diffusers_FLUX_Config)):
raise TypeError(f"{type(config).__name__} is not an SDNQ FLUX config") Type guard
def is_sdnq_flux(config) -> bool:
return isinstance(config, (Main_SDNQ_FLUX_Config, Main_SDNQ_Diffusers_FLUX_Config)) Try / catch
try:
model = sdnq_loader._load_model(config, submodel_type)
except ValueError as e:
if "Expected Main_SDNQ_Diffusers_FLUX_Config" in str(e):
raise RuntimeError("Config is not SDNQ; route it to the standard FLUX loader") from e
raise Prevention
- Don't manually reclassify standard FLUX models as SDNQ
- Keep one loader per config class in the registry
- Re-scan models after changing InvokeAI versions
When it happens
Trigger: A config that is neither Main_SDNQ_FLUX_Config nor Main_SDNQ_Diffusers_FLUX_Config reaches this SDNQ loader branch — e.g. a standard FLUX diffusers config misrouted by a customized registry or direct loader invocation.
Common situations: Manually invoking the SDNQ loader with a non-SDNQ diffusers config; editing model records' format fields so standard FLUX models get classified as SDNQ diffusers.
Related errors
- The selected FLUX model does not ship its own {', '.join(mis
- transformer is SDNQ-quantized; use Main_SDNQ_Diffusers_FLUX_
- Unexpected model config type: {type(config)}.
- Only Transformer submodels are supported for checkpoint form
- Unsupported submodel type: {submodel_type}
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/45790a11a680322b.
Report an issue: GitHub.