{"record":{"id":"8578ad059cc8f312","repo":"invoke-ai/InvokeAI","slug":"self-class-has-the-config-param-addition-em-8578ad","errorCode":null,"errorMessage":"{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`","messagePattern":"(.+?) has the config param `addition_embed_type` set to '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":1105,"sourceCode":"                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\")\n                time_embeds = self.add_time_proj(time_ids.flatten())\n                time_embeds = time_embeds.reshape((text_embeds.shape[0], -1))\n                add_embeds = torch.concat([text_embeds, time_embeds], dim=-1)\n                add_embeds = add_embeds.to(emb.dtype)\n                aug_emb = self.add_embedding(add_embeds)\n            elif self.config.addition_embed_type == \"image\":\n                # Kandinsky 2.2 - 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 'image' which requires the keyword argument `image_embeds` to be passed in `added_cond_kwargs`\"\n                    )\n                image_embs = added_cond_kwargs.get(\"image_embeds\")\n                aug_emb = self.add_embedding(image_embs)\n            elif self.config.addition_embed_type == \"image_hint\":\n                # Kandinsky 2.2 - style\n                if \"image_embeds\" not in added_cond_kwargs or \"hint\" not in added_cond_kwargs:\n                    raise ValueError(\n                        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`\"\n                    )\n                image_embs = added_cond_kwargs.get(\"image_embeds\")\n                hint = added_cond_kwargs.get(\"hint\")\n                aug_emb, hint = self.add_embedding(image_embs, hint)\n                sample = torch.cat([sample, hint], dim=1)\n\n            emb = emb + aug_emb if aug_emb is not None else emb\n\n            if self.time_embed_act is not None:","sourceCodeStart":1087,"sourceCodeEnd":1123,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/hidiffusion/hidiffusion.py#L1087-L1123","documentation":"The UNet config sets `addition_embed_type='image'` (Kandinsky 2.2 style), so forward requires `added_cond_kwargs['image_embeds']` to compute the augmentation embedding from image embeddings alone. It raises when the key is missing from `added_cond_kwargs`.","triggerScenarios":"Calling forward on a UNet with `config.addition_embed_type == 'image'` (Kandinsky 2.2) without `added_cond_kwargs={'image_embeds': ...}`.","commonSituations":"Loading a Kandinsky 2.2 UNet and calling it with a generic SD-style signature; migrating pipelines between Kandinsky 2.1 (text_image) and 2.2 (image) where the required kwargs differ; omitting `added_cond_kwargs` entirely in custom loops.","solutions":["Pass `added_cond_kwargs={'image_embeds': image_embeds}` (from Kandinsky's image encoder / CLIP vision model) to forward","Confirm the checkpoint type: Kandinsky 2.2 uses only image embeds; 2.1 needs text+image","Reload a non-image-conditioned UNet if image conditioning is not intended"],"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) == 'image' and not (added_cond_kwargs and 'image_embeds' in added_cond_kwargs):\n    raise ValueError(\"image-embedding 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":["Check `addition_embed_type` before calling forward on third-party checkpoints","Compute image embeds from the checkpoint's own image encoder","Do not reuse SD-loop code for Kandinsky 2.2 UNets"],"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"}