invoke-ai/InvokeAI · error · ValueError
Only Gemma2Encoder_Gemma2Encoder_Config models are supported
Error message
Only Gemma2Encoder_Gemma2Encoder_Config models are supported here.
What it means
Gemma2EncoderLoader._load_model is registered only for Gemma2Encoder models and accepts a single config type: Gemma2Encoder_Gemma2Encoder_Config. If the model manager dispatches a config of any other class to this loader (a routing/registration bug or wrong model record), it refuses with this ValueError rather than loading the wrong model.
Source
Thrown at invokeai/backend/model_manager/load/model_loaders/gemma2_encoder.py:84
out["embed_tokens.weight"] = value
elif key == "output_norm.weight":
out["norm.weight"] = value
else:
raise ValueError(f"Unmapped Gemma-2 GGUF tensor key '{key}'")
return out
@ModelLoaderRegistry.register(base=BaseModelType.Any, type=ModelType.Gemma2Encoder, format=ModelFormat.Gemma2Encoder)
class Gemma2EncoderLoader(ModelLoader):
"""Loads a Gemma-2 causal LM directory and exposes its decoder + tokenizer."""
def _load_model(
self,
config: AnyModelConfig,
submodel_type: Optional[SubModelType] = None,
) -> AnyModel:
if not isinstance(config, Gemma2Encoder_Gemma2Encoder_Config):
raise ValueError("Only Gemma2Encoder_Gemma2Encoder_Config models are supported here.")
model_path = Path(config.path)
match submodel_type:
case SubModelType.Tokenizer:
return AutoTokenizer.from_pretrained(model_path, local_files_only=True)
case SubModelType.TextEncoder:
target_device = TorchDevice.choose_torch_device()
model_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device)
causal_lm = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=model_dtype,
low_cpu_mem_usage=True,
local_files_only=True,
)
# PiD only ever uses the decoder block — the transformer stack
# without the LM head. Upstream calls `.get_decoder()`, but
# transformers 4.56 returns None for Gemma2, so we reach forView on GitHub (pinned to 0b6a024f2f)
Solutions
- Ensure the model's format is GGUFQuantized so the Gemma2EncoderGGUFLoader handles it instead
- Reinstall/re-convert the model so its config is Gemma2Encoder_Gemma2Encoder_Config
- Check the registry registration format tags so dispatch selects the correct loader
Example fix
# before config = Gemma2Encoder_GGUF_Config(...) # routed to Gemma2EncoderLoader # after model_format = ModelFormat.GGUFQuantized # dispatched to Gemma2EncoderGGUFLoader
Defensive patterns
Strategy: type-guard
Validate before calling
from invokeai.backend.model_manager.config import Gemma2Encoder_Gemma2Encoder_Config
def can_load_with_gemma2_encoder_loader(config):
return isinstance(config, Gemma2Encoder_Gemma2Encoder_Config) Type guard
def is_gemma2_encoder_config(config) -> bool:
return isinstance(config, Gemma2Encoder_Gemma2Encoder_Config) Try / catch
try:
model = loader._load_model(config, submodel_type)
except ValueError as e:
if "Only Gemma2Encoder_Gemma2Encoder_Config" in str(e):
print(f"Wrong loader for model {config.path}; check its recorded format")
else:
raise Prevention
- Ensure model records store the correct ModelFormat so registry dispatch picks the right loader
- Never call _load_model directly with configs of a different class
- Re-convert models rather than hand-editing config/format metadata
When it happens
Trigger: A model record whose config class is not Gemma2Encoder_Gemma2Encoder_Config is routed to the Gemma2Encoder loader — e.g. a GGUF record handed to the non-GGUF loader because ModelFormat was recorded as Gemma2Encoder instead of GGUFQuantized, or a stale/incorrect models.yaml/DB entry.
Common situations: Model installed with the wrong format metadata so the registry picks the wrong loader; code calling Gemma2EncoderLoader._load_model directly with a foreign config object; refactors renaming the config class without updating model records.
Related errors
- Only Gemma2Encoder_GGUF_Config models are supported here.
- Unsupported submodel type for Gemma2 encoder: {submodel_type
- Only Qwen3VLEncoder_Checkpoint_Config models are supported h
- FLUX.2 [dev] loader requires a FLUX.2 [dev] transformer, but
- No VAE source provided. Single-file / GGUF transformers requ
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/8952b247fbd8d8c4.
Report an issue: GitHub.