{"record":{"id":"080539aad6094438","repo":"invoke-ai/InvokeAI","slug":"only-qwen3encoder-sdnq-config-or-qwen3encoder-sdnq","errorCode":null,"errorMessage":"Only Qwen3Encoder_SDNQ_Config or Qwen3Encoder_SDNQ_Folder_Config models are supported here.","messagePattern":"Only Qwen3Encoder_SDNQ_Config or Qwen3Encoder_SDNQ_Folder_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":1469,"sourceCode":"                new_sd[key] = value\n\n        return new_sd\n\n\n@ModelLoaderRegistry.register(base=BaseModelType.Any, type=ModelType.Qwen3Encoder, format=ModelFormat.SDNQQuantized)\nclass Qwen3EncoderSDNQLoader(ModelLoader):\n    \"\"\"Class to load SDNQ-quantized Qwen3 Encoder models for Z-Image.\"\"\"\n\n    # Default HuggingFace model to load tokenizer from when using SDNQ Qwen3 encoder\n    DEFAULT_TOKENIZER_SOURCE = \"Qwen/Qwen3-4B\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if not isinstance(config, (Qwen3Encoder_SDNQ_Config, Qwen3Encoder_SDNQ_Folder_Config)):\n            raise ValueError(\n                \"Only Qwen3Encoder_SDNQ_Config or Qwen3Encoder_SDNQ_Folder_Config models are supported here.\"\n            )\n\n        match submodel_type:\n            case SubModelType.TextEncoder:\n                return self._load_from_sdnq(config)\n            case SubModelType.Tokenizer:\n                return self._load_tokenizer_with_offline_fallback()\n\n        submodel_str = submodel_type.value if submodel_type else \"None\"\n        raise ValueError(f\"Only TextEncoder and Tokenizer submodels are supported. Received: {submodel_str}\")\n\n    def _load_tokenizer_with_offline_fallback(self) -> AnyModel:\n        \"\"\"Load tokenizer with local_files_only fallback for offline support.\"\"\"\n        try:\n            return AutoTokenizer.from_pretrained(self.DEFAULT_TOKENIZER_SOURCE, local_files_only=True)\n        except OSError:\n            return AutoTokenizer.from_pretrained(self.DEFAULT_TOKENIZER_SOURCE)","sourceCodeStart":1451,"sourceCodeEnd":1487,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/z_image.py#L1451-L1487","documentation":"The Z-Image SDNQ loader's _load_model entry point only accepts Qwen3Encoder_SDNQ_Config or Qwen3Encoder_SDNQ_Folder_Config model configs. Passing any other config type (different model family or loader) raises this ValueError at dispatch time.","triggerScenarios":"Registering/invoking the Z-Image SDNQ loader with a config that is not one of the two supported SDNQ config classes — e.g. a plain ModelConfigBase, a GGUF config, or a checkpoint config routed to this loader by a miswritten model-import or custom node.","commonSituations":"Custom model-install code choosing the wrong loader; config class added by a fork/patch but not updated in _load_model's isinstance check; user placed an SDNQ model of the wrong family in the Z-Image text-encoder directory.","solutions":["Confirm the model was imported so its config is Qwen3Encoder_SDNQ_Config or Qwen3Encoder_SDNQ_Folder_Config (check the models.yaml / DB record type field).","Re-import the model through the UI/CLI so the correct config class and loader are matched.","If you support a new SDNQ config type, add it to the isinstance tuple in _load_model.","Verify you did not accidentally install the SDNQ file under the Z-Image model root when it belongs to another model family."],"exampleFix":"// before: wrong loader for config\nloader._load_model(NonSDNQConfig(path=...))\n// after\ncfg = Qwen3Encoder_SDNQ_Folder_Config(path=...)\nloader._load_model(cfg, SubModelType.TextEncoder)","handlingStrategy":"type-guard","validationCode":"from invokeai.backend.model_manager.load.model_loaders.z_image import (\n    Qwen3Encoder_SDNQ_Config, Qwen3Encoder_SDNQ_Folder_Config)\nif not isinstance(cfg, (Qwen3Encoder_SDNQ_Config, Qwen3Encoder_SDNQ_Folder_Config)):\n    raise TypeError(f\"Z-Image SDNQ loader requires an SDNQ Qwen3 config, got {type(cfg).__name__}\")","typeGuard":"def is_sdnq_qwen3_config(cfg: AnyModelConfig) -> bool:\n    from invokeai.backend.model_manager.load.model_loaders.z_image import (\n        Qwen3Encoder_SDNQ_Config, Qwen3Encoder_SDNQ_Folder_Config)\n    return isinstance(cfg, (Qwen3Encoder_SDNQ_Config, Qwen3Encoder_SDNQ_Folder_Config))","tryCatchPattern":"try:\n    model = loader._load_model(cfg, SubModelType.TextEncoder)\nexcept ValueError as e:\n    if \"Only Qwen3Encoder_SDNQ\" in str(e):\n        raise UnsupportedModelTypeError(type(cfg).__name__) from e\n    raise","preventionTips":["Import models through the model manager so the config class matches the loader.","Check the model record's type field before invoking specialized loaders.","Don't mix model families within one model root directory.","When adding new config types, update the loader's isinstance checks."],"tags":["config","type-mismatch","sdnq","model-loading"],"backgroundTag":"unsupported-model-config-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}