invoke-ai/InvokeAI · error · ValueError

Only TextEncoder and Tokenizer submodels are supported. Rece

Error message

Only TextEncoder and Tokenizer submodels are supported. Received: {submodel_type.value if submodel_type else 'None'}

What it means

This loader handles exactly two submodel types for the Qwen3 single-file text encoder: TextEncoder (loads weights from the checkpoint) and Tokenizer (loads the vendored bundled tokenizer). Any other submodel request — or a None — has no handling branch, so the loader raises this ValueError to report the unsupported combination.

Source

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

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
        download required.
        """
        return load_bundled_qwen3_tokenizer()

    def _load_from_singlefile(
        self,
        config: AnyModelConfig,
    ) -> AnyModel:
        from safetensors.torch import load_file

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Request only TextEncoder or Tokenizer from this loader; obtain VAE/transformer from their own registered loaders.
  2. Pass an explicit valid SubModelType if calling the loader directly rather than None.
  3. Verify the model's ModelType is TextEncoder so only the correct submodels are requested.
  4. Add an explicit case in the match statement if a new submodel must be supported by this loader.

Example fix

// before
model = loader._load_model(config, submodel_type=SubModelType.Vae)
// after
assert submodel_type in (SubModelType.TextEncoder, SubModelType.Tokenizer)
model = loader._load_model(config, submodel_type=submodel_type)
Defensive patterns

Strategy: validation

Validate before calling

if submodel_type not in (SubModelType.TextEncoder, SubModelType.Tokenizer):
    raise ValueError(f"Qwen3 checkpoint loader supports TextEncoder/Tokenizer only, got {submodel_type}")

Type guard

def is_qwen3_supported_submodel(st: SubModelType | None) -> bool:
    return st in (SubModelType.TextEncoder, SubModelType.Tokenizer)

Try / catch

try:
    model = loader._load_model(config, submodel_type=st)
except ValueError as e:
    if "Only TextEncoder and Tokenizer" in str(e):
        model = other_loader_for(st)._load_model(config, submodel_type=st)
    else:
        raise

Prevention

When it happens

Trigger: Calling ZImageQwen3EncoderCheckpointModel._load_model with submodel_type values like Vae, Transformer, Scheduler, or None; model-manager dispatch mistakenly routes non-text submodels of a Z-Image model to the Qwen3 encoder loader.

Common situations: A pipeline component resolver iterates all submodel types per model; a custom workflow requests the VAE through the text-encoder loader; mis-set ModelType on the model record causes wrong loader selection.

Related errors


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