invoke-ai/InvokeAI · error · ValueError

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

Error message

{self.__class__} has the config param `addition_embed_type` set to 'text_time' which requires the keyword argument `time_ids` to be passed in `added_cond_kwargs`

What it means

Companion to the 'text_time' check: for SDXL-style addition embedding, forward also requires `added_cond_kwargs['time_ids']` (original size, crop coords, target size) which are projected through `add_time_proj` and concatenated with `text_embeds`. Missing `time_ids` means the size-conditioning half of SDXL's micro-conditioning cannot be computed.

Source

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

            elif self.config.addition_embed_type == "text_image":
                # Kandinsky 2.1 - style
                if "image_embeds" not in added_cond_kwargs:
                    raise ValueError(
                        f"{self.__class__} has the config param `addition_embed_type` set to 'text_image' which requires the keyword argument `image_embeds` to be passed in `added_cond_kwargs`"
                    )

                image_embs = added_cond_kwargs.get("image_embeds")
                text_embs = added_cond_kwargs.get("text_embeds", encoder_hidden_states)
                aug_emb = self.add_embedding(text_embs, image_embs)
            elif self.config.addition_embed_type == "text_time":
                # SDXL - style
                if "text_embeds" not in added_cond_kwargs:
                    raise ValueError(
                        f"{self.__class__} has the config param `addition_embed_type` set to 'text_time' which requires the keyword argument `text_embeds` to be passed in `added_cond_kwargs`"
                    )
                text_embeds = added_cond_kwargs.get("text_embeds")
                if "time_ids" not in added_cond_kwargs:
                    raise ValueError(
                        f"{self.__class__} has the config param `addition_embed_type` set to 'text_time' which requires the keyword argument `time_ids` to be passed in `added_cond_kwargs`"
                    )
                time_ids = added_cond_kwargs.get("time_ids")
                time_embeds = self.add_time_proj(time_ids.flatten())
                time_embeds = time_embeds.reshape((text_embeds.shape[0], -1))
                add_embeds = torch.concat([text_embeds, time_embeds], dim=-1)
                add_embeds = add_embeds.to(emb.dtype)
                aug_emb = self.add_embedding(add_embeds)
            elif self.config.addition_embed_type == "image":
                # Kandinsky 2.2 - style
                if "image_embeds" not in added_cond_kwargs:
                    raise ValueError(
                        f"{self.__class__} has the config param `addition_embed_type` set to 'image' which requires the keyword argument `image_embeds` to be passed in `added_cond_kwargs`"
                    )
                image_embs = added_cond_kwargs.get("image_embeds")
                aug_emb = self.add_embedding(image_embs)
            elif self.config.addition_embed_type == "image_hint":
                # Kandinsky 2.2 - style

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Add `time_ids` to `added_cond_kwargs`: `unet(..., added_cond_kwargs={'text_embeds': p, 'time_ids': add_time_ids})`
  2. Build `add_time_ids` via `unet.add_time_ids`-style inputs: tensor of [original_height, original_width, crop_top, crop_left, target_height, target_width] on the right device/dtype
  3. Reuse `pipe._get_add_time_ids(...)` from diffusers pipelines to construct correct time ids

Example fix

// before
unet(sample, t, encoder_hidden_states=emb, added_cond_kwargs={'text_embeds': pooled})
// after
add_time_ids = torch.tensor([[1024, 1024, 0, 0, 1024, 1024]], device=device, dtype=dtype)
unet(sample, t, encoder_hidden_states=emb,
     added_cond_kwargs={'text_embeds': pooled, 'time_ids': add_time_ids})
Defensive patterns

Strategy: validation

Validate before calling

if getattr(unet.config, 'addition_embed_type', None) == 'text_time' and not (added_cond_kwargs and 'time_ids' in added_cond_kwargs):
    raise ValueError("SDXL UNet requires added_cond_kwargs with 'time_ids'")

Type guard

def has_time_ids(added_cond_kwargs) -> bool:
    return isinstance(added_cond_kwargs, dict) and 'time_ids' in added_cond_kwargs

Try / catch

try:
    out = unet(sample, t, emb, added_cond_kwargs=ackw)
except ValueError as e:
    if 'time_ids' in str(e):
        ackw['time_ids'] = add_time_ids.to(device, dtype); out = unet(sample, t, emb, added_cond_kwargs=ackw)
    else: raise

Prevention

When it happens

Trigger: Calling forward on an SDXL UNet with `added_cond_kwargs` containing `text_embeds` but not `time_ids`.

Common situations: Hand-rolled SDXL sampling loops that pass pooled embeddings but forget the resolution/time ids; caching embeddings across calls and dropping the time ids; using default sizes at inference but never constructing `add_time_ids`.

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/7a107b09f9fa679c. Report an issue: GitHub.