{"record":{"id":"530e869da0511e7e","repo":"invoke-ai/InvokeAI","slug":"state-dict-does-not-look-like-bnb-quantized-llm-in","errorCode":null,"errorMessage":"state dict does not look like bnb quantized llm_int8","messagePattern":"state dict does not look like bnb quantized llm_int8","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"info","filePath":"invokeai/backend/model_manager/configs/t5_encoder.py","lineNumber":97,"sourceCode":"        raise_for_class_name(expected_config_path, expected_class_name)\n\n        cls.raise_if_filename_doesnt_look_like_bnb_quantized(mod)\n\n        cls.raise_if_state_dict_doesnt_look_like_bnb_quantized(mod)\n\n        return cls(**override_fields)\n\n    @classmethod\n    def raise_if_filename_doesnt_look_like_bnb_quantized(cls, mod: ModelOnDisk) -> None:\n        filename_looks_like_bnb = any(x for x in mod.weight_files() if \"llm_int8\" in x.as_posix())\n        if not filename_looks_like_bnb:\n            raise NotAMatchError(\"filename does not look like bnb quantized llm_int8\")\n\n    @classmethod\n    def raise_if_state_dict_doesnt_look_like_bnb_quantized(cls, mod: ModelOnDisk) -> None:\n        has_scb_key_suffix = state_dict_has_any_keys_ending_with(mod.load_state_dict(), \"SCB\")\n        if not has_scb_key_suffix:\n            raise NotAMatchError(\"state dict does not look like bnb quantized llm_int8\")\n\n\nclass T5Encoder_SDNQ_Config(Config_Base):\n    \"\"\"Configuration for SDNQ-quantized T5 Encoder models.\n\n    Matches two layouts:\n\n    1. **Standalone T5 bundle**: ``mod.path`` is the pipeline-style root, with\n       ``text_encoder_2/`` (and usually ``tokenizer_2/``) as subfolders.\n    2. **Inline submodel**: ``mod.path`` *is* the ``text_encoder_2`` folder itself —\n       this is how a parent FluxPipeline / similar config registers its T5 submodel\n       (``submodels[TextEncoder2].path_or_prefix`` points straight at the folder).\n\n    In both cases, the SDNQ-quantized state lives next to a ``config.json`` declaring\n    ``T5EncoderModel`` and is signalled either by ``quantization_config.json`` with\n    ``quant_method == \"sdnq\"`` or by SDNQ-style ``weight`` + ``scale`` key pairs.\n    \"\"\"\n","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/t5_encoder.py#L79-L115","documentation":"NotAMatchError from T5Encoder_BnBLLMint8_Config.raise_if_state_dict_doesnt_look_like_bnb_quantized. bitsandbytes LLM.int8 quantization stores absolute-value (SCB) tensors alongside weights; a state dict without any keys ending in 'SCB' is not LLM.int8-quantized, so the config declines the match.","triggerScenarios":"from_model_on_disk probing a model whose loaded state dict has no keys ending with 'SCB' — the model was saved without bnb quantization state, or saved in a format that strips SCB tensors.","commonSituations":"Models quantized with newer bnb 4-bit (NF4/FP4, which use different metadata), models dequantized and re-saved, or conversions produced by tools that drop the SCB suffix tensors.","solutions":["Re-download the proper llm_int8 conversion that includes SCB tensors","Re-quantize with bitsandbytes LLM.int8 keeping SCB tensors in the saved state dict","Register the model with the correct non-bnb config explicitly instead of relying on auto-scan"],"exampleFix":"// before\nsave_file(state_dict, path)  # SCB tensors omitted\n// after\nsave_file({**state_dict, **scb_tensors}, path)  # include *SCB keys","handlingStrategy":"validation","validationCode":"from safetensors import safe_open\ndef has_scb_keys(sf_path) -> bool:\n    with safe_open(sf_path, framework=\"pt\") as f:\n        return any(k.endswith(\"SCB\") for k in f.keys())","typeGuard":null,"tryCatchPattern":"try:\n    install_model(path)\nexcept NotAMatchError as e:\n    if \"SCB\" in str(e):\n        logger.warning(\"State dict lacks SCB tensors: not llm_int8; using default config\")","preventionTips":["Use official bnb llm_int8 conversions that retain SCB tensors","Don't dequantize-and-resave if you intend to keep bnb quantization","Check bnb version compatibility when converting"],"tags":["bitsandbytes","state-dict","quantization"],"backgroundTag":"model-scan-no-match","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}