invoke-ai/InvokeAI · error · ValueError

Only Qwen3Encoder_Checkpoint_Config models are supported her

Error message

Only Qwen3Encoder_Checkpoint_Config models are supported here.

What it means

The Z-Image single-file (Qwen3 text encoder) checkpoint loader requires the config to be exactly a Qwen3Encoder_Checkpoint_Config instance. Any other config type reaching this loader's _load_model cannot provide the single-file path/keys it needs, so it raises this ValueError as a guard at dispatch time.

Source

Thrown at invokeai/backend/model_manager/load/model_loaders/z_image.py:913

            import torch.nn as nn

            model.x_pad_token = nn.Parameter(torch.empty(dim))
            nn.init.normal_(model.x_pad_token, std=0.02)

        return model


@ModelLoaderRegistry.register(base=BaseModelType.Any, type=ModelType.Qwen3Encoder, format=ModelFormat.Checkpoint)
class Qwen3EncoderCheckpointLoader(ModelLoader):
    """Class to load single-file Qwen3 Encoder models for Z-Image (safetensors format)."""

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

        match submodel_type:
            case SubModelType.TextEncoder:
                return self._load_from_singlefile(config)
            case SubModelType.Tokenizer:
                # Single-file checkpoints ship no tokenizer files; use the vendored copy.
                return self._load_bundled_tokenizer()

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

    def _load_bundled_tokenizer(self) -> AnyModel:
        """Load the Qwen3 tokenizer from the vendored, bundled copy.

        Single-file / GGUF checkpoints do not ship tokenizer files. The Qwen3 BPE
        tokenizer is identical across the 0.6B / 4B / 8B variants, so we load the
        self-contained copy vendored in the package — fully offline, no HuggingFace

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-register the model so InvokeAI builds a Qwen3Encoder_Checkpoint_Config for it (single-file checkpoint format).
  2. If the file is actually GGUF, route it to the GGUF loader (Qwen3Encoder_GGUF_Config) instead.
  3. If calling programmatically, construct or cast the config as Qwen3Encoder_Checkpoint_Config before calling _load_model.
  4. Check the model's format/type fields in the model manager UI or models.yaml and correct mismatches.

Example fix

// before
loader._load_model(generic_config, submodel_type=SubModelType.TextEncoder)
// after
assert isinstance(config, Qwen3Encoder_Checkpoint_Config), type(config)
loader._load_model(config, submodel_type=SubModelType.TextEncoder)
Defensive patterns

Strategy: type-guard

Validate before calling

if not isinstance(config, Qwen3Encoder_Checkpoint_Config):
    raise TypeError(f"Expected Qwen3Encoder_Checkpoint_Config, got {type(config).__name__}")

Type guard

def is_qwen3_checkpoint_config(config: AnyModelConfig) -> bool:
    return isinstance(config, Qwen3Encoder_Checkpoint_Config)

Try / catch

try:
    model = loader._load_model(config, submodel_type)
except ValueError as e:
    if "Qwen3Encoder_Checkpoint_Config" in str(e):
        config = model_manager.get_config(model_id)  # rebuild proper config
        model = loader._load_model(config, submodel_type)
    else:
        raise

Prevention

When it happens

Trigger: ZImageQwen3EncoderCheckpointModel._load_model is invoked with a config that is not Qwen3Encoder_Checkpoint_Config — e.g. a generic main-model config, a GGUF config routed to the checkpoint loader, or a raw dict/config for another loader family.

Common situations: Model registered as single-file checkpoint but its DB/yaml record was created under a different config class; a custom loader or script calls _load_model directly with a hand-built config; model format changed on disk without re-registration.

Related errors


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