{"record":{"id":"fdc228e9ad9109f4","repo":"invoke-ai/InvokeAI","slug":"expected-main-checkpoint-qwenimage-config-got-ty","errorCode":null,"errorMessage":"Expected Main_Checkpoint_QwenImage_Config, got {type(config).__name__}.","messagePattern":"Expected Main_Checkpoint_QwenImage_Config, got (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/qwen_image.py","lineNumber":258,"sourceCode":"        match submodel_type:\n            case SubModelType.Transformer:\n                model = self._load_from_singlefile(config)\n                return self._apply_fp8_layerwise_casting(model, config, submodel_type)\n\n        raise ValueError(\n            f\"Only Transformer submodels are currently supported. Received: {submodel_type.value if submodel_type else 'None'}\"\n        )\n\n    def _load_from_singlefile(self, config: AnyModelConfig) -> AnyModel:\n        from diffusers import QwenImageTransformer2DModel\n        from safetensors.torch import load_file\n\n        from invokeai.backend.util.logging import InvokeAILogger\n\n        logger = InvokeAILogger.get_logger(self.__class__.__name__)\n\n        if not isinstance(config, Main_Checkpoint_QwenImage_Config):\n            raise TypeError(f\"Expected Main_Checkpoint_QwenImage_Config, got {type(config).__name__}.\")\n        model_path = Path(config.path)\n\n        target_device = TorchDevice.choose_torch_device()\n        model_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device)\n\n        sd = load_file(str(model_path))\n        sd = _strip_comfyui_prefix(sd)\n\n        dequantized = _dequantize_comfyui_fp8(sd, model_dtype)\n        if dequantized > 0:\n            logger.info(f\"Dequantized {dequantized} ComfyUI-quantized weights\")\n        _strip_quantization_metadata(sd)\n\n        is_edit = getattr(config, \"variant\", None) == QwenImageVariantType.Edit\n        model_config = _build_qwen_image_transformer_config(sd, is_edit=is_edit)\n\n        with accelerate.init_empty_weights():\n            model = QwenImageTransformer2DModel(**model_config)","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/qwen_image.py#L240-L276","documentation":"The safetensors single-file loader path expects Main_Checkpoint_QwenImage_Config specifically. A GGUF config or any other config type reaching this _load_from_singlefile raises this TypeError naming the actual received type, because safetensors load_file() cannot read GGUF files.","triggerScenarios":"A GGUF-quantized Qwen Image model registered with the plain checkpoint format, routed into this loader's single-file path.","commonSituations":"Model format misdetection during import; user manually editing model records; older InvokeAI versions predating GGUF Qwen Image support where GGUF files fell into the safetensors path.","solutions":["Register the model with ModelFormat.GGUFQuantized so it gets Main_GGUF_QwenImage_Config and the GGUF loader.","Convert the GGUF file to safetensors if you intend to use the safetensors path.","Re-scan the models directory so format detection runs again on the file."],"exampleFix":"// before\nconfig = Main_GGUF_QwenImage_Config(path=\"model.gguf\")\nmodel = safetensors_loader._load_from_singlefile(config)\n// after\nconfig = Main_Checkpoint_QwenImage_Config(path=\"model.safetensors\")\nmodel = safetensors_loader._load_from_singlefile(config)","handlingStrategy":"type-guard","validationCode":"from invokeai.backend.model_manager.config import Main_Checkpoint_QwenImage_Config\nif not isinstance(config, Main_Checkpoint_QwenImage_Config):\n    raise TypeError(f\"Safetensors loader needs Main_Checkpoint_QwenImage_Config, got {type(config).__name__}\")\nif not str(config.path).endswith((\".safetensors\", \".ckpt\")):\n    raise ValueError(\"Path does not look like a single-file checkpoint\")","typeGuard":"def is_safetensors_qwen_config(config: AnyModelConfig) -> bool:\n    return isinstance(config, Main_Checkpoint_QwenImage_Config)","tryCatchPattern":"try:\n    model = loader._load_from_singlefile(config)\nexcept TypeError as e:\n    if \"Main_Checkpoint_QwenImage_Config\" in str(e):\n        config = reregister_model(path, ModelFormat.Checkpoint)\n        model = loader._load_from_singlefile(config)\n    else:\n        raise","preventionTips":["Never route .gguf files through the safetensors loader","Check file extension against the model record's format before loading","Re-scan models after manual edits to model records"],"tags":["model-loader","invokeai","safetensors","gguf","config-type"],"backgroundTag":"invalid-config-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}