{"record":{"id":"45790a11a680322b","repo":"invoke-ai/InvokeAI","slug":"expected-main-sdnq-diffusers-flux-config-got-typ","errorCode":null,"errorMessage":"Expected Main_SDNQ_Diffusers_FLUX_Config, got {type(config).__name__}","messagePattern":"Expected Main_SDNQ_Diffusers_FLUX_Config, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/flux.py","lineNumber":1592,"sourceCode":"        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        logger.debug(\n            \"[SDNQ] FluxSDNQDiffusersModel._load_model called with config=%s, submodel=%s\",\n            type(config).__name__,\n            submodel_type,\n        )\n        # Handle single-file SDNQ checkpoint (Main_SDNQ_FLUX_Config)\n        if isinstance(config, Main_SDNQ_FLUX_Config):\n            if submodel_type == SubModelType.Transformer:\n                return self._load_sdnq_transformer_checkpoint(config)\n            raise ValueError(\n                f\"Only Transformer submodels are supported for checkpoint format. Received: {submodel_type}\"\n            )\n\n        # Handle diffusers-format SDNQ model (Main_SDNQ_Diffusers_FLUX_Config)\n        if not isinstance(config, Main_SDNQ_Diffusers_FLUX_Config):\n            raise ValueError(f\"Expected Main_SDNQ_Diffusers_FLUX_Config, got {type(config).__name__}\")\n\n        if submodel_type is None:\n            raise ValueError(\"A submodel type must be provided when loading main pipelines.\")\n\n        # Prefer the path discovery actually found. `model_index.json` names its components with\n        # arbitrary keys, and identification records the key it saw — but reconstructing\n        # `model_path / submodel_type.value` here assumes the key always equals the slot name. A\n        # pipeline whose index calls its CLIP encoder something else is then discovered fine and\n        # loaded from a folder that does not exist. Fall back to the conventional name when a config\n        # predates submodel discovery.\n        model_path = Path(config.path)\n        submodel_path = resolve_submodel_path(config, submodel_type, model_path / submodel_type.value)\n\n        # These branches build their modules by hand (`init_empty_weights` + `load_state_dict`)\n        # rather than through `from_pretrained`, so they arrive in training mode — `put_in_eval_mode`\n        # in `load_default._load_and_cache` is what puts every loaded model into inference mode.\n        match submodel_type:\n            case SubModelType.Transformer:","sourceCodeStart":1574,"sourceCodeEnd":1610,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/flux.py#L1574-L1610","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nmodel = SdnqFluxLoader()._load_model(plain_flux_config, SubModelType.Transformer)\n// after\nif not isinstance(plain_flux_config, Main_SDNQ_Diffusers_FLUX_Config):\n    raise TypeError(f\"{type(plain_flux_config).__name__} is not an SDNQ diffusers config; use the standard FLUX loader\")\nmodel = SdnqFluxLoader()._load_model(plain_flux_config, SubModelType.Transformer)","handlingStrategy":"type-guard","validationCode":"if not isinstance(config, (Main_SDNQ_FLUX_Config, Main_SDNQ_Diffusers_FLUX_Config)):\n    raise TypeError(f\"{type(config).__name__} is not an SDNQ FLUX config\")","typeGuard":"def is_sdnq_flux(config) -> bool:\n    return isinstance(config, (Main_SDNQ_FLUX_Config, Main_SDNQ_Diffusers_FLUX_Config))","tryCatchPattern":"try:\n    model = sdnq_loader._load_model(config, submodel_type)\nexcept ValueError as e:\n    if \"Expected Main_SDNQ_Diffusers_FLUX_Config\" in str(e):\n        raise RuntimeError(\"Config is not SDNQ; route it to the standard FLUX loader\") from e\n    raise","preventionTips":["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"],"tags":["type-check","sdnq","flux"],"backgroundTag":"wrong-config-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}