invoke-ai/InvokeAI · error · TypeError

Expected Main_GGUF_QwenImage_Config, got {type(config).__nam

Error message

Expected Main_GGUF_QwenImage_Config, got {type(config).__name__}.

What it means

The GGUF single-file loader path requires the config to be exactly Main_GGUF_QwenImage_Config (GGUF quantized Qwen Image checkpoint). Any other config type (regular safetensors checkpoint, diffusers config) reaches _load_from_singlefile and raises this TypeError, naming the actual config type received.

Source

Thrown at invokeai/backend/model_manager/load/model_loaders/qwen_image.py:206

        config: AnyModelConfig,
        submodel_type: Optional[SubModelType] = None,
    ) -> AnyModel:
        if not isinstance(config, Checkpoint_Config_Base):
            raise ValueError("Only CheckpointConfigBase models are currently supported here.")

        match submodel_type:
            case SubModelType.Transformer:
                return self._load_from_singlefile(config)

        raise ValueError(
            f"Only Transformer submodels are currently supported. Received: {submodel_type.value if submodel_type else 'None'}"
        )

    def _load_from_singlefile(self, config: AnyModelConfig) -> AnyModel:
        from diffusers import QwenImageTransformer2DModel

        if not isinstance(config, Main_GGUF_QwenImage_Config):
            raise TypeError(f"Expected Main_GGUF_QwenImage_Config, got {type(config).__name__}.")
        model_path = Path(config.path)

        target_device = TorchDevice.choose_torch_device()
        compute_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device)

        sd = gguf_sd_loader(model_path, compute_dtype=compute_dtype)
        sd = _strip_comfyui_prefix(sd)

        is_edit = getattr(config, "variant", None) == QwenImageVariantType.Edit
        model_config = _build_qwen_image_transformer_config(sd, is_edit=is_edit)

        with accelerate.init_empty_weights():
            model = QwenImageTransformer2DModel(**model_config)

        model.load_state_dict(sd, strict=False, assign=True)
        return model

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-scan/re-convert the model so GGUF files are registered with Main_GGUF_QwenImage_Config (ModelFormat.GGUFQuantized).
  2. If the model is a plain safetensors checkpoint, ensure it routes to the non-GGUF checkpoint loader instead.
  3. Check the model's config class in the model manager records and fix the format field on the model record.

Example fix

// before
config = Main_Checkpoint_QwenImage_Config(path="model.safetensors")
model = gguf_loader._load_from_singlefile(config)
// after
config = Main_GGUF_QwenImage_Config(path="model.gguf")
model = gguf_loader._load_from_singlefile(config)
Defensive patterns

Strategy: type-guard

Validate before calling

from invokeai.backend.model_manager.config import Main_GGUF_QwenImage_Config
if not isinstance(config, Main_GGUF_QwenImage_Config):
    raise TypeError(f"GGUF loader needs Main_GGUF_QwenImage_Config, got {type(config).__name__}")

Type guard

def is_gguf_qwen_config(config: AnyModelConfig) -> bool:
    return isinstance(config, Main_GGUF_QwenImage_Config)

Try / catch

try:
    model = gguf_loader._load_from_singlefile(config)
except TypeError as e:
    if "Main_GGUF_QwenImage_Config" in str(e):
        config = reregister_model(path, ModelFormat.GGUFQuantized)
        model = gguf_loader._load_from_singlefile(config)
    else:
        raise

Prevention

When it happens

Trigger: A model whose config is Main_Checkpoint_QwenImage_Config (safetensors single-file) or another type routed into the GGUF loader's _load_from_singlefile, typically via wrong registry/format resolution.

Common situations: GGUF model file registered with the safetensors checkpoint format; mixed-up model entries after manual import; version drift where new GGUF config classes were added but the model entry predates them.

Related errors


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