{"record":{"id":"ebb5739e172f3459","repo":"invoke-ai/InvokeAI","slug":"self-class-has-the-config-param-addition-em","errorCode":null,"errorMessage":"{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`","messagePattern":"(.+?) 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`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/hidiffusion/hidiffusion.py","lineNumber":1078,"sourceCode":"                    class_labels = self.time_proj(class_labels)\n\n                    # `Timesteps` does not contain any weights and will always return f32 tensors\n                    # there might be better ways to encapsulate this.\n                    class_labels = class_labels.to(dtype=sample.dtype)\n\n                class_emb = self.class_embedding(class_labels).to(dtype=sample.dtype)\n\n                if self.config.class_embeddings_concat:\n                    emb = torch.cat([emb, class_emb], dim=-1)\n                else:\n                    emb = emb + class_emb\n\n            if self.config.addition_embed_type == \"text\":\n                aug_emb = self.add_embedding(encoder_hidden_states)\n            elif self.config.addition_embed_type == \"text_image\":\n                # Kandinsky 2.1 - style\n                if \"image_embeds\" not in added_cond_kwargs:\n                    raise ValueError(\n                        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`\"\n                    )\n\n                image_embs = added_cond_kwargs.get(\"image_embeds\")\n                text_embs = added_cond_kwargs.get(\"text_embeds\", encoder_hidden_states)\n                aug_emb = self.add_embedding(text_embs, image_embs)\n            elif self.config.addition_embed_type == \"text_time\":\n                # SDXL - style\n                if \"text_embeds\" not in added_cond_kwargs:\n                    raise ValueError(\n                        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`\"\n                    )\n                text_embeds = added_cond_kwargs.get(\"text_embeds\")\n                if \"time_ids\" not in added_cond_kwargs:\n                    raise ValueError(\n                        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`\"\n                    )\n                time_ids = added_cond_kwargs.get(\"time_ids\")","sourceCodeStart":1060,"sourceCodeEnd":1096,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/hidiffusion/hidiffusion.py#L1060-L1096","documentation":"The UNet config sets `addition_embed_type='text_image'` (Kandinsky 2.1 style extra conditioning), so `forward()` requires `added_cond_kwargs={'image_embeds': ...}` to build the augmentation embedding from text+image embeddings. When `image_embeds` is absent from `added_cond_kwargs`, the model raises instead of silently producing wrong conditioning.","triggerScenarios":"Calling forward on a UNet whose `config.addition_embed_type == 'text_image'` (Kandinsky 2.1) without passing `added_cond_kwargs` or passing a dict that lacks the `image_embeds` key.","commonSituations":"Loading a Kandinsky 2.1 checkpoint and calling the UNet directly with only sample/timestep/text embeddings; adapting an SD pipeline loop to Kandinsky without adding the extra kwargs; copying UNet forward calls between models with different `addition_embed_type` configs.","solutions":["Pass `added_cond_kwargs={'image_embeds': image_embeds}` to the UNet forward call","Pass `text_embeds` too if the text embeddings differ from `encoder_hidden_states` (optional; it defaults to encoder_hidden_states)","If the checkpoint is not Kandinsky-style, load a UNet with `addition_embed_type=None`"],"exampleFix":"// before\nnoise_pred = unet(sample, t, encoder_hidden_states=text_emb)\n// after\nnoise_pred = unet(sample, t, encoder_hidden_states=text_emb,\n                  added_cond_kwargs={'image_embeds': image_embeds})","handlingStrategy":"validation","validationCode":"if getattr(unet.config, 'addition_embed_type', None) == 'text_image' and not (added_cond_kwargs and 'image_embeds' in added_cond_kwargs):\n    raise ValueError(\"text_image UNet requires added_cond_kwargs={'image_embeds': ...}\")","typeGuard":"def has_image_embeds(added_cond_kwargs) -> bool:\n    return isinstance(added_cond_kwargs, dict) and 'image_embeds' in added_cond_kwargs","tryCatchPattern":"try:\n    out = unet(sample, t, emb, added_cond_kwargs=ackw)\nexcept ValueError as e:\n    if 'image_embeds' in str(e):\n        ackw = {'image_embeds': image_embeds}; out = unet(sample, t, emb, added_cond_kwargs=ackw)\n    else: raise","preventionTips":["Inspect `unet.config.addition_embed_type` after loading any checkpoint","Branch your forward-call helper on addition_embed_type to assemble kwargs","Use official Kandinsky 2.1 pipelines rather than hand-rolled loops"],"tags":["diffusers","unet","kandinsky","missing-argument","conditioning"],"backgroundTag":"missing-required-argument","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}