invoke-ai/InvokeAI · error · ValueError
encoder_hid_dim_type: {encoder_hid_dim_type} must be None, '
Error message
encoder_hid_dim_type: {encoder_hid_dim_type} must be None, 'text_proj' or 'text_image_proj'. What it means
The model constructor only supports three values for `encoder_hid_dim_type`: None, 'text_proj', and 'text_image_proj'. Any other string falls through all supported branches and hits this ValueError. The library enumerates its supported encoder-projection backends explicitly, so an unsupported/typo'd value cannot be silently ignored.
Source
Thrown at invokeai/backend/util/hotfixes.py:223
raise ValueError(
f"`encoder_hid_dim` has to be defined when `encoder_hid_dim_type` is set to {encoder_hid_dim_type}."
)
if encoder_hid_dim_type == "text_proj":
self.encoder_hid_proj = nn.Linear(encoder_hid_dim, cross_attention_dim)
elif encoder_hid_dim_type == "text_image_proj":
# image_embed_dim DOESN'T have to be `cross_attention_dim`. To not clutter the __init__ too much
# they are set to `cross_attention_dim` here as this is exactly the required dimension ...
# for the currently only use
# case when `addition_embed_type == "text_image_proj"` (Kadinsky 2.1)`
self.encoder_hid_proj = TextImageProjection(
text_embed_dim=encoder_hid_dim,
image_embed_dim=cross_attention_dim,
cross_attention_dim=cross_attention_dim,
)
elif encoder_hid_dim_type is not None:
raise ValueError(
f"encoder_hid_dim_type: {encoder_hid_dim_type} must be None, 'text_proj' or 'text_image_proj'."
)
else:
self.encoder_hid_proj = None
# class embedding
if class_embed_type is None and num_class_embeds is not None:
self.class_embedding = nn.Embedding(num_class_embeds, time_embed_dim)
elif class_embed_type == "timestep":
self.class_embedding = TimestepEmbedding(timestep_input_dim, time_embed_dim)
elif class_embed_type == "identity":
self.class_embedding = nn.Identity(time_embed_dim, time_embed_dim)
elif class_embed_type == "projection":
if projection_class_embeddings_input_dim is None:
raise ValueError(
"`class_embed_type`: 'projection' requires `projection_class_embeddings_input_dim` be set"
)
# The projection `class_embed_type` is the same as the timestep `class_embed_type` exceptView on GitHub (pinned to 0b6a024f2f)
Solutions
- Set `encoder_hid_dim_type` to one of: None, 'text_proj', or 'text_image_proj' (check exact spelling/casing).
- If you need 'text_image' style projection, use 'text_image_proj' and supply both `encoder_hid_dim` and `cross_attention_dim`.
- If the value comes from a checkpoint config for a feature this vendored class lacks, upgrade InvokeAI/diffusers or use the stock diffusers class instead of the hotfix copy.
- Print/inspect the offending config value before constructing to catch stray whitespace or case mismatches.
Example fix
// before
model = ControlNetModel2_5(
encoder_hid_dim=1024,
encoder_hid_dim_type="image_proj",
)
// after
model = ControlNetModel2_5(
encoder_hid_dim=1024,
encoder_hid_dim_type="text_image_proj",
cross_attention_dim=1024,
) Defensive patterns
Strategy: validation
Validate before calling
ALLOWED = {None, "text_proj", "text_image_proj"}
t = model_config.get("encoder_hid_dim_type")
if t not in ALLOWED:
raise ValueError(f"encoder_hid_dim_type={t!r} not in {sorted(str(a) for a in ALLOWED)}") Type guard
from typing import Optional, Literal
def is_valid_encoder_hid_dim_type(v: Optional[str]) -> bool:
return v in (None, "text_proj", "text_image_proj") Try / catch
try:
model = ControlNetModel2_5(**cfg)
except ValueError as e:
if "encoder_hid_dim_type" in str(e):
cfg["encoder_hid_dim_type"] = None
model = ControlNetModel2_5(**cfg)
else:
raise Prevention
- Use Literal-typed config schemas or enums so invalid values fail at parse time.
- Copy enum values from the source class, never retype from memory (watch 'text_proj' vs 'text-proj').
- When loading newer checkpoints into vendored classes, check the class supports that encoder_hid_dim_type first.
- Keep configs in version control so accidental edits to enum fields are caught in review.
When it happens
Trigger: Passing `encoder_hid_dim_type` with a value such as 'image_proj', 'ip_adapter', 'text', or a misspelling like 'text-proj'/'TextProj' to the model constructor or in a loaded config.json. Also occurs when a config from a newer diffusers release uses an encoder_hid_dim_type variant this vendored class does not implement.
Common situations: Typos in hand-written configs; copying an encoder_hid_dim_type from a different architecture (e.g. UNet variants that support more types); running an older vendored hotfix copy of the diffusers class against a newer checkpoint config.
Related errors
- `encoder_hid_dim` has to be defined when `encoder_hid_dim_ty
- `class_embed_type`: 'projection' requires `projection_class_
- addition_embed_type: {addition_embed_type} must be None, 'te
- User not found or inactive
- Missing authentication credentials
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/a1bd72d48fe3f1d6.
Report an issue: GitHub.