{"record":{"id":"929904d8ea1de199","repo":"invoke-ai/InvokeAI","slug":"expected-qwen3encoder-gguf-config-got-type-confi","errorCode":null,"errorMessage":"Expected Qwen3Encoder_GGUF_Config, got {type(config).__name__}. Model configuration type mismatch.","messagePattern":"Expected Qwen3Encoder_GGUF_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":1201,"sourceCode":"        Single-file / GGUF checkpoints do not ship tokenizer files. The Qwen3 BPE\n        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_gguf(\n        self,\n        config: AnyModelConfig,\n    ) -> AnyModel:\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_GGUF_Config):\n            raise TypeError(\n                f\"Expected Qwen3Encoder_GGUF_Config, got {type(config).__name__}. 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        compute_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device)\n\n        # Load the GGUF state dict - this returns GGMLTensor wrappers (on CPU)\n        # We keep them on CPU and let the model cache system handle GPU movement\n        # via apply_custom_layers_to_model() and the partial loading cache\n        sd = gguf_sd_loader(model_path, compute_dtype=compute_dtype)\n\n        # Check if this is llama.cpp format (blk.X.) or PyTorch format (model.layers.X.)\n        is_llamacpp_format = any(k.startswith(\"blk.\") for k in sd.keys() if isinstance(k, str))\n\n        if is_llamacpp_format:\n            logger.info(\"Detected llama.cpp GGUF format, converting keys to PyTorch format\")","sourceCodeStart":1183,"sourceCodeEnd":1219,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/z_image.py#L1183-L1219","documentation":"_load_from_gguf independently re-checks that the config is a Qwen3Encoder_GGUF_Config and raises a TypeError that includes the actual received type name when it is not. Like its single-file counterpart (1334), this is a defense-in-depth guard meant to catch direct or refactored calls that bypass the _load_model dispatch check.","triggerScenarios":"Invoking _load_from_gguf directly with a checkpoint or generic config; a wrapper/subclass passes a config that no longer passes isinstance; config objects reloaded from persistence losing their concrete GGUF config class.","commonSituations":"Custom scripts driving loader internals; mixed InvokeAI versions/config definitions after an upgrade; automated pipelines reusing one config object across checkpoint and GGUF loaders.","solutions":["Pass a real Qwen3Encoder_GGUF_Config (the message names the type you actually passed).","Re-create the model registration so the correct GGUF config class is instantiated by the model manager.","When calling internals directly, instantiate Qwen3Encoder_GGUF_Config with the GGUF file path rather than reusing another config type.","Align InvokeAI versions across services/scripts so config classes match."],"exampleFix":"// before\nself._load_from_gguf(checkpoint_config)\n// after\nassert isinstance(config, Qwen3Encoder_GGUF_Config), type(config).__name__\nself._load_from_gguf(config)","handlingStrategy":"type-guard","validationCode":"if not isinstance(config, Qwen3Encoder_GGUF_Config):\n    raise TypeError(f\"Cannot GGUF-load with {type(config).__name__}\")","typeGuard":"def is_qwen3_gguf(c: AnyModelConfig) -> bool:\n    return isinstance(c, Qwen3Encoder_GGUF_Config)","tryCatchPattern":"try:\n    model = loader._load_from_gguf(config)\nexcept TypeError as e:\n    if \"Expected Qwen3Encoder_GGUF_Config\" in str(e):\n        config = Qwen3Encoder_GGUF_Config(path=gguf_path)\n        model = loader._load_from_gguf(config)\n    else:\n        raise","preventionTips":["Prefer _load_model over calling _load_from_gguf directly.","Build GGUF configs via the model manager registry.","Re-instantiate persisted configs after upgrades instead of reusing stale objects.","Use the type name in the error message to identify the misrouted config quickly."],"tags":["invokeai","z-image","gguf","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"}