invoke-ai/InvokeAI · error · ValueError

{self.__class__} has the config param `encoder_hid_dim_type`

Error message

{self.__class__} has the config param `encoder_hid_dim_type` set to 'text_image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`

What it means

When the UNet has an `encoder_hid_proj` with `encoder_hid_dim_type='text_image_proj'` (Kandinsky 2.1), `encoder_hidden_states` must be combined with image embeddings supplied via `added_cond_kwargs['image_embeds']` before being consumed by downstream attention. The projection needs both text and image embeds, so a missing `image_embeds` raises immediately.

Source

Thrown at invokeai/backend/hidiffusion/hidiffusion.py:1131

                    raise ValueError(
                        f"{self.__class__} has the config param `addition_embed_type` set to 'image_hint' which requires the keyword arguments `image_embeds` and `hint` to be passed in `added_cond_kwargs`"
                    )
                image_embs = added_cond_kwargs.get("image_embeds")
                hint = added_cond_kwargs.get("hint")
                aug_emb, hint = self.add_embedding(image_embs, hint)
                sample = torch.cat([sample, hint], dim=1)

            emb = emb + aug_emb if aug_emb is not None else emb

            if self.time_embed_act is not None:
                emb = self.time_embed_act(emb)

            if self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == "text_proj":
                encoder_hidden_states = self.encoder_hid_proj(encoder_hidden_states)
            elif self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == "text_image_proj":
                # Kadinsky 2.1 - style
                if "image_embeds" not in added_cond_kwargs:
                    raise ValueError(
                        f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'text_image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`"
                    )

                image_embeds = added_cond_kwargs.get("image_embeds")
                encoder_hidden_states = self.encoder_hid_proj(encoder_hidden_states, image_embeds)
            elif self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == "image_proj":
                # Kandinsky 2.2 - style
                if "image_embeds" not in added_cond_kwargs:
                    raise ValueError(
                        f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`"
                    )
                image_embeds = added_cond_kwargs.get("image_embeds")
                encoder_hidden_states = self.encoder_hid_proj(image_embeds)
            elif self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == "ip_image_proj":
                if "image_embeds" not in added_cond_kwargs:
                    raise ValueError(
                        f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'ip_image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`"
                    )

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Pass `added_cond_kwargs={'image_embeds': image_embeds}` (output of the Kandinsky image encoder) to forward
  2. Ensure `text_embeds`/`encoder_hidden_states` match the shapes the `TextImageProjection` expects
  3. If only text conditioning is needed, use a UNet with `encoder_hid_dim_type=None` or `'text_proj'`

Example fix

// before
unet(sample, t, encoder_hidden_states=text_emb, added_cond_kwargs={})
// after
unet(sample, t, encoder_hidden_states=text_emb,
     added_cond_kwargs={'image_embeds': image_embeds})
Defensive patterns

Strategy: validation

Validate before calling

if getattr(unet.config, 'encoder_hid_dim_type', None) == 'text_image_proj' and not (added_cond_kwargs and 'image_embeds' in added_cond_kwargs):
    raise ValueError("text_image_proj UNet requires added_cond_kwargs={'image_embeds': ...}")

Type guard

def has_image_embeds(added_cond_kwargs) -> bool:
    return isinstance(added_cond_kwargs, dict) and 'image_embeds' in added_cond_kwargs

Try / catch

try:
    out = unet(sample, t, emb, added_cond_kwargs=ackw)
except ValueError as e:
    if 'image_embeds' in str(e):
        ackw = {'image_embeds': image_embeds}; out = unet(sample, t, emb, added_cond_kwargs=ackw)
    else: raise

Prevention

When it happens

Trigger: Calling forward on a Kandinsky 2.1 UNet whose `encoder_hid_dim_type == 'text_image_proj'` without `added_cond_kwargs={'image_embeds': ...}`.

Common situations: Feeding raw text embeddings into a Kandinsky 2.1 UNet without its ImageTextEmbedding projection inputs; reusing SD pipeline code for Kandinsky; calling `unet.forward` directly instead of going through `prior`/`decoder` pipelines that assemble embeddings.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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