{"record":{"id":"3d6d0ab956874cda","repo":"invoke-ai/InvokeAI","slug":"only-main-sdnq-zimage-config-or-main-sdnq-diffuser","errorCode":null,"errorMessage":"Only Main_SDNQ_ZImage_Config or Main_SDNQ_Diffusers_ZImage_Config models are supported here.","messagePattern":"Only Main_SDNQ_ZImage_Config or Main_SDNQ_Diffusers_ZImage_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":593,"sourceCode":"\n\n@ModelLoaderRegistry.register(base=BaseModelType.ZImage, type=ModelType.Main, format=ModelFormat.SDNQQuantized)\nclass ZImageSDNQCheckpointModel(ModelLoader):\n    \"\"\"Class to load SDNQ-quantized Z-Image transformer models.\n\n    Handles both single-file SDNQ checkpoints (``Main_SDNQ_ZImage_Config``) and full\n    diffusers-pipeline folders (``Main_SDNQ_Diffusers_ZImage_Config``), where the\n    quantized weights live under ``transformer/`` alongside a ``config.json`` that\n    describes the architecture.\n    \"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if not isinstance(config, (Main_SDNQ_ZImage_Config, Main_SDNQ_Diffusers_ZImage_Config)):\n            raise ValueError(\n                \"Only Main_SDNQ_ZImage_Config or Main_SDNQ_Diffusers_ZImage_Config models are supported here.\"\n            )\n\n        # Single-file SDNQ checkpoints only carry the transformer.\n        if isinstance(config, Main_SDNQ_ZImage_Config):\n            if submodel_type == SubModelType.Transformer:\n                return self._load_from_singlefile(config)\n            raise ValueError(\n                f\"Single-file SDNQ Z-Image checkpoints only provide the Transformer submodel. \"\n                f\"Received: {submodel_type.value if submodel_type else 'None'}\"\n            )\n\n        # Full ZImagePipeline folder — dispatch each submodel out of its own subfolder so the\n        # model can be used as a 'Qwen3 & VAE source model' for other Z-Image runs.\n        match submodel_type:\n            case SubModelType.Transformer:\n                return self._load_from_diffusers_folder(config)\n            case SubModelType.TextEncoder:","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/z_image.py#L575-L611","documentation":"The SDNQ Z-Image loader accepts only Main_SDNQ_ZImage_Config (single-file SDNQ checkpoint) or Main_SDNQ_Diffusers_ZImage_Config (full ZImagePipeline folder). Any other config type raises this ValueError. SDNQ quantized weights need their specialized loading path, so foreign configs are rejected up front.","triggerScenarios":"Calling this loader's _load_model with a config that is neither Main_SDNQ_ZImage_Config nor Main_SDNQ_Diffusers_ZImage_Config — e.g. a checkpoint or GGUF config — triggers the ValueError at z_image.py:593.","commonSituations":"An SDNQ-quantized model was registered with the wrong config class in the model manager; loader matching selected the SDNQ loader for a non-SDNQ model; custom install pipelines instantiate the loader with generic configs.","solutions":["Re-register the model with the correct SDNQ config class matching the on-disk layout (single file vs pipeline folder).","If the model is not quantized with SDNQ, use the checkpoint or GGUF loader instead.","Check the loader-routing/match code to see why the SDNQ loader was chosen for this config.","In custom code, gate on isinstance(config, (Main_SDNQ_ZImage_Config, Main_SDNQ_Diffusers_ZImage_Config)) before calling."],"exampleFix":"// before\nconfig = Main_Checkpoint_ZImage_Config(path=p)\nmodel = sdnq_loader._load_model(config, SubModelType.Transformer)  # ValueError\n// after\nconfig = Main_SDNQ_ZImage_Config(path=p)  # SDNQ single-file checkpoint\nmodel = sdnq_loader._load_model(config, SubModelType.Transformer)","handlingStrategy":"type-guard","validationCode":"from invokeai.backend.model_manager.load.model_loaders.z_image import Main_SDNQ_ZImage_Config, Main_SDNQ_Diffusers_ZImage_Config\nif not isinstance(config, (Main_SDNQ_ZImage_Config, Main_SDNQ_Diffusers_ZImage_Config)):\n    raise ValueError(f\"SDNQ loader requires an SDNQ ZImage config, got {type(config).__name__}\")","typeGuard":"def is_zimage_sdnq_config(config: AnyModelConfig) -> bool:\n    return isinstance(config, (Main_SDNQ_ZImage_Config, Main_SDNQ_Diffusers_ZImage_Config))","tryCatchPattern":"try:\n    model = sdnq_loader._load_model(config, submodel_type)\nexcept ValueError as e:\n    if \"Main_SDNQ_ZImage_Config\" in str(e):\n        model = select_loader_for(config)._load_model(config, submodel_type)\n    else:\n        raise","preventionTips":["Match the config class to the on-disk layout: single SDNQ file vs full pipeline folder.","Let the loader registry pick loaders rather than hard-coding loader classes.","Validate quantization format at model-install time."],"tags":["python","quantization","sdnq","model-loading","invokeai"],"backgroundTag":"model-config-type-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}