{"record":{"id":"e2908500ee15da09","repo":"invoke-ai/InvokeAI","slug":"text-encoder-2-does-not-look-like-an-sdnq-quantize","errorCode":null,"errorMessage":"text_encoder_2 does not look like an SDNQ-quantized T5 encoder","messagePattern":"text_encoder_2 does not look like an SDNQ-quantized T5 encoder","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"info","filePath":"invokeai/backend/model_manager/configs/t5_encoder.py","lineNumber":193,"sourceCode":"            raise NotAMatchError(\"no text_encoder_2/config.json or config.json at model root\")\n        return te_dir\n\n    @classmethod\n    def _raise_if_not_sdnq_quantized(cls, te_dir) -> None:\n        quant_config_path = te_dir / \"quantization_config.json\"\n        if quant_config_path.exists():\n            try:\n                with open(quant_config_path, \"r\", encoding=\"utf-8\") as f:\n                    quant_config = json.load(f)\n            except (OSError, ValueError):\n                quant_config = {}\n            if quant_config.get(\"quant_method\") == \"sdnq\":\n                return\n\n        if _safetensors_dir_has_sdnq_keys(te_dir):\n            return\n\n        raise NotAMatchError(\"text_encoder_2 does not look like an SDNQ-quantized T5 encoder\")\n\n\nclass T5Encoder_GGUF_Config(Checkpoint_Config_Base, Config_Base):\n    \"\"\"Configuration for GGUF-quantized T5 text encoder models in a single .gguf file.\n\n    These are conversions like city96/t5-v1_1-xxl-encoder-gguf, which use llama.cpp's T5 encoder\n    tensor naming (``enc.blk.N.*``, ``token_embd.weight``, ``enc.output_norm.weight``).\"\"\"\n\n    base: Literal[BaseModelType.Any] = Field(default=BaseModelType.Any)\n    type: Literal[ModelType.T5Encoder] = Field(default=ModelType.T5Encoder)\n    format: Literal[ModelFormat.GGUFQuantized] = Field(default=ModelFormat.GGUFQuantized)\n    cpu_only: bool | None = Field(default=None, description=\"Whether this model should run on CPU only\")\n\n    @classmethod\n    def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:\n        raise_if_not_file(mod)\n\n        raise_for_override_fields(cls, override_fields)","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/t5_encoder.py#L175-L211","documentation":"NotAMatchError from _raise_if_not_sdnq_quantized. After locating the encoder dir, the config verifies SDNQ provenance via `quantization_config.json` with quant_method=='sdnq' or SDNQ-specific keys in the safetensors; if neither check passes, the model is not SDNQ-quantized and this config declines.","triggerScenarios":"from_model_on_disk on a T5 encoder whose te_dir lacks a valid sdnq quantization_config.json and whose safetensors contain no SDNQ keys — e.g. an fp16/bnb/gguf encoder probed against the SDNQ config.","commonSituations":"Models quantized with bitsandbytes, GGUF, or left unquantized; SDNQ conversions saved by tools that don't emit quantization_config.json.","solutions":["Re-quantize the model with SDNQ ensuring quantization_config.json (quant_method: sdnq) is saved","Download a verified SDNQ conversion of the T5 encoder","If the model uses another quantization, let the matching config (bnb/gguf) handle it — this rejection is expected"],"exampleFix":"// before\ntext_encoder_2/{config.json, model.safetensors}\n// after\ntext_encoder_2/{config.json, model.safetensors, quantization_config.json}  # {\"quant_method\": \"sdnq\", ...}","handlingStrategy":"validation","validationCode":"import json\ndef is_sdnq(te_dir) -> bool:\n    qcfg = te_dir / \"quantization_config.json\"\n    if qcfg.exists() and json.loads(qcfg.read_text()).get(\"quant_method\") == \"sdnq\":\n        return True\n    return False","typeGuard":null,"tryCatchPattern":"try:\n    install_model(path)\nexcept NotAMatchError as e:\n    if \"SDNQ\" in str(e):\n        logger.warning(\"Not SDNQ-quantized; selecting the matching bnb/gguf/fp16 config instead\")","preventionTips":["Verify quantization_config.json quant_method before installing SDNQ models","Match the config type to the actual quantization method","Re-quantize with SDNQ tooling if the file lacks sdnq metadata"],"tags":["sdnq","quantization","not-a-match"],"backgroundTag":"quantization-format-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}