{"record":{"id":"8dc71c3d2e480403","repo":"invoke-ai/InvokeAI","slug":"only-qwen3encoder-qwen3encoder-config-models-are-s","errorCode":null,"errorMessage":"Only Qwen3Encoder_Qwen3Encoder_Config models are supported here.","messagePattern":"Only Qwen3Encoder_Qwen3Encoder_Config models are supported here\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/z_image.py","lineNumber":759,"sourceCode":"        # so no BFL→diffusers conversion is needed here. The transformer has no tied/shared weights,\n        # so we expect a complete state dict — any missing key would leave a required parameter on a\n        # meta tensor and fail later during device movement or inference. Fail fast here instead.\n        missing, unexpected = model.load_state_dict(sd, assign=True, strict=False)\n        raise_on_incomplete_sdnq_load(\"SDNQ Z-Image transformer\", missing, unexpected)\n        return model\n\n\n@ModelLoaderRegistry.register(base=BaseModelType.Any, type=ModelType.Qwen3Encoder, format=ModelFormat.Qwen3Encoder)\nclass Qwen3EncoderLoader(ModelLoader):\n    \"\"\"Class to load standalone Qwen3 Encoder models for Z-Image (directory format).\"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if not isinstance(config, Qwen3Encoder_Qwen3Encoder_Config):\n            raise ValueError(\"Only Qwen3Encoder_Qwen3Encoder_Config models are supported here.\")\n\n        model_path = Path(config.path)\n\n        # Support both structures:\n        # 1. Full model: model_root/text_encoder/ and model_root/tokenizer/\n        # 2. Standalone download: model_root/ contains text_encoder files directly\n        text_encoder_path = model_path / \"text_encoder\"\n        tokenizer_path = model_path / \"tokenizer\"\n\n        # Check if this is a standalone text_encoder download (no nested text_encoder folder)\n        is_standalone = not text_encoder_path.exists() and (model_path / \"config.json\").exists()\n\n        if is_standalone:\n            text_encoder_path = model_path\n            tokenizer_path = model_path  # Tokenizer files should also be in root\n\n        match submodel_type:\n            case SubModelType.Tokenizer:","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/z_image.py#L741-L777","documentation":"This loader handles the Qwen3 text encoder used by Z-Image and requires the config to be Qwen3Encoder_Qwen3Encoder_Config. Any other config type raises this ValueError immediately, since only that config class carries the layout expectations (text_encoder/ and tokenizer/ subfolders, or a standalone text_encoder root).","triggerScenarios":"Calling _load_model with a config that is not Qwen3Encoder_Qwen3Encoder_Config — e.g. pointing the VAE/text-encoder source model at a checkpoint, GGUF, or SDNQ config — fails the isinstance check at z_image.py:759.","commonSituations":"The 'Qwen3 & VAE source model' referenced by a Z-Image pipeline was registered with the wrong model type; a full Z-Image checkpoint was selected as the encoder source instead of a Qwen3 encoder model; duplicate/mis-typed model records after re-import.","solutions":["Register the encoder-source model so it resolves to Qwen3Encoder_Qwen3Encoder_Config (standalone Qwen3 encoder download or full model with text_encoder/ + tokenizer/).","Update the Z-Image pipeline settings to reference the correctly-typed Qwen3 encoder model.","Re-scan the model directory so the model manager classifies the model with the right config class.","In custom code, gate the call with isinstance(config, Qwen3Encoder_Qwen3Encoder_Config)."],"exampleFix":"// before\nconfig = Main_Checkpoint_ZImage_Config(path=p)\nenc = qwen3_loader._load_model(config, SubModelType.TextEncoder)  # ValueError\n// after\nconfig = Qwen3Encoder_Qwen3Encoder_Config(path=p)  # p is the Qwen3 encoder root\nenc = qwen3_loader._load_model(config, SubModelType.TextEncoder)","handlingStrategy":"type-guard","validationCode":"if not isinstance(config, Qwen3Encoder_Qwen3Encoder_Config):\n    raise ValueError(f\"Qwen3 encoder loader requires Qwen3Encoder_Qwen3Encoder_Config, got {type(config).__name__}\")","typeGuard":"def is_qwen3_encoder_config(config: AnyModelConfig) -> bool:\n    return isinstance(config, Qwen3Encoder_Qwen3Encoder_Config)","tryCatchPattern":"try:\n    enc = qwen3_loader._load_model(config, SubModelType.TextEncoder)\nexcept ValueError as e:\n    if \"Qwen3Encoder_Qwen3Encoder_Config\" in str(e):\n        config = reclassify_as_qwen3_encoder(config.path)\n        enc = qwen3_loader._load_model(config, SubModelType.TextEncoder)\n    else:\n        raise","preventionTips":["Point the Z-Image 'Qwen3 & VAE source model' setting at a model registered as a Qwen3 encoder, not a full checkpoint.","Re-scan model directories after imports so configs are classified correctly.","Verify the source model root contains text_encoder/ (and tokenizer/) files before wiring it in."],"tags":["python","qwen3","model-loading","type-mismatch","invokeai"],"backgroundTag":"model-config-type-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}