invoke-ai/InvokeAI · info · NotAMatchError

state dict does not look like bnb quantized llm_int8

Error message

state dict does not look like bnb quantized llm_int8

What it means

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.

Source

Thrown at invokeai/backend/model_manager/configs/t5_encoder.py:97

        raise_for_class_name(expected_config_path, expected_class_name)

        cls.raise_if_filename_doesnt_look_like_bnb_quantized(mod)

        cls.raise_if_state_dict_doesnt_look_like_bnb_quantized(mod)

        return cls(**override_fields)

    @classmethod
    def raise_if_filename_doesnt_look_like_bnb_quantized(cls, mod: ModelOnDisk) -> None:
        filename_looks_like_bnb = any(x for x in mod.weight_files() if "llm_int8" in x.as_posix())
        if not filename_looks_like_bnb:
            raise NotAMatchError("filename does not look like bnb quantized llm_int8")

    @classmethod
    def raise_if_state_dict_doesnt_look_like_bnb_quantized(cls, mod: ModelOnDisk) -> None:
        has_scb_key_suffix = state_dict_has_any_keys_ending_with(mod.load_state_dict(), "SCB")
        if not has_scb_key_suffix:
            raise NotAMatchError("state dict does not look like bnb quantized llm_int8")


class T5Encoder_SDNQ_Config(Config_Base):
    """Configuration for SDNQ-quantized T5 Encoder models.

    Matches two layouts:

    1. **Standalone T5 bundle**: ``mod.path`` is the pipeline-style root, with
       ``text_encoder_2/`` (and usually ``tokenizer_2/``) as subfolders.
    2. **Inline submodel**: ``mod.path`` *is* the ``text_encoder_2`` folder itself —
       this is how a parent FluxPipeline / similar config registers its T5 submodel
       (``submodels[TextEncoder2].path_or_prefix`` points straight at the folder).

    In both cases, the SDNQ-quantized state lives next to a ``config.json`` declaring
    ``T5EncoderModel`` and is signalled either by ``quantization_config.json`` with
    ``quant_method == "sdnq"`` or by SDNQ-style ``weight`` + ``scale`` key pairs.
    """

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-download the proper llm_int8 conversion that includes SCB tensors
  2. Re-quantize with bitsandbytes LLM.int8 keeping SCB tensors in the saved state dict
  3. Register the model with the correct non-bnb config explicitly instead of relying on auto-scan

Example fix

// before
save_file(state_dict, path)  # SCB tensors omitted
// after
save_file({**state_dict, **scb_tensors}, path)  # include *SCB keys
Defensive patterns

Strategy: validation

Validate before calling

from safetensors import safe_open
def has_scb_keys(sf_path) -> bool:
    with safe_open(sf_path, framework="pt") as f:
        return any(k.endswith("SCB") for k in f.keys())

Try / catch

try:
    install_model(path)
except NotAMatchError as e:
    if "SCB" in str(e):
        logger.warning("State dict lacks SCB tensors: not llm_int8; using default config")

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/530e869da0511e7e. Report an issue: GitHub.