{"record":{"id":"870934b90ec2c81d","repo":"invoke-ai/InvokeAI","slug":"expected-qwen3encoder-checkpoint-config-got-type","errorCode":null,"errorMessage":"Expected Qwen3Encoder_Checkpoint_Config, got {type(config).__name__}. Model configuration type mismatch.","messagePattern":"Expected Qwen3Encoder_Checkpoint_Config, got (.+?)\\. Model configuration type mismatch\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/z_image.py","lineNumber":948,"sourceCode":"        tokenizer is identical across the 0.6B / 4B / 8B variants, so we load the\n        self-contained copy vendored in the package — fully offline, no HuggingFace\n        download required.\n        \"\"\"\n        return load_bundled_qwen3_tokenizer()\n\n    def _load_from_singlefile(\n        self,\n        config: AnyModelConfig,\n    ) -> AnyModel:\n        from safetensors.torch import load_file\n        from transformers import Qwen3Config, Qwen3ForCausalLM\n\n        from invokeai.backend.util.logging import InvokeAILogger\n\n        logger = InvokeAILogger.get_logger(self.__class__.__name__)\n\n        if not isinstance(config, Qwen3Encoder_Checkpoint_Config):\n            raise TypeError(\n                f\"Expected Qwen3Encoder_Checkpoint_Config, got {type(config).__name__}. \"\n                \"Model configuration type mismatch.\"\n            )\n        model_path = Path(config.path)\n\n        # Determine safe dtype based on target device capabilities\n        target_device = TorchDevice.choose_torch_device()\n        model_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device)\n\n        # Load the state dict from safetensors file\n        sd = load_file(model_path)\n\n        # Handle ComfyUI quantized checkpoints\n        # ComfyUI stores quantized weights with accompanying scale factors:\n        # - layer.weight: quantized data (FP8)\n        # - layer.weight_scale: scale factor (FP32 scalar)\n        # Dequantization formula: dequantized = weight.to(dtype) * weight_scale\n        # Reference: https://github.com/Comfy-Org/ComfyUI/blob/master/QUANTIZATION.md","sourceCodeStart":930,"sourceCodeEnd":966,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/z_image.py#L930-L966","documentation":"_load_from_singlefile re-validates the config with a strict isinstance check against Qwen3Encoder_Checkpoint_Config and raises TypeError naming the actual received type if it fails. This is a defense-in-depth check: the dispatching _load_model already guards, so hitting this means the loader was invoked through an unusual path or the config type changed between checks.","triggerScenarios":"Calling _load_from_singlefile directly with a non-Qwen3Encoder_Checkpoint_Config object; a custom subclass or wrapper passes a duck-typed config that fails the exact isinstance check; internal refactors bypass the _load_model guard.","commonSituations":"Scripting the loader internals instead of using the model manager; config objects deserialized from cache/DB losing their concrete class; mixing config classes across InvokeAI versions after an upgrade.","solutions":["Pass a genuine Qwen3Encoder_Checkpoint_Config instance (read the printed type name in the message to see what you actually passed).","Re-create the model record via the model manager so the correct config class is instantiated.","If calling internals directly, build the config via the same factory the registry uses.","Upgrade/downgrade consistently — do not mix config definitions from different InvokeAI versions."],"exampleFix":"// before\nself._load_from_singlefile(config_dict)\n// after\nfrom invokeai.backend.model_manager.load.model_loaders.z_image import Qwen3Encoder_Checkpoint_Config\nconfig = Qwen3Encoder_Checkpoint_Config(**config_dict)\nself._load_from_singlefile(config)","handlingStrategy":"type-guard","validationCode":"if not isinstance(config, Qwen3Encoder_Checkpoint_Config):\n    raise TypeError(f\"Cannot single-file load with {type(config).__name__}\")","typeGuard":"def is_qwen3_ckpt(c: AnyModelConfig) -> bool:\n    return isinstance(c, Qwen3Encoder_Checkpoint_Config)","tryCatchPattern":"try:\n    model = loader._load_from_singlefile(config)\nexcept TypeError as e:\n    if \"Expected Qwen3Encoder_Checkpoint_Config\" in str(e):\n        config = Qwen3Encoder_Checkpoint_Config(**vars(config))\n        model = loader._load_from_singlefile(config)\n    else:\n        raise","preventionTips":["Use the model manager/registry to build configs, not raw dicts.","Call _load_model rather than _load_from_singlefile directly.","Don't persist and reuse config blobs across InvokeAI version upgrades without re-instantiation.","Read the received type name in the message to diagnose quickly."],"tags":["invokeai","z-image","qwen3","typeerror","config-type-mismatch"],"backgroundTag":"model-config-type-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}