{"record":{"id":"7a107b09f9fa679c","repo":"invoke-ai/InvokeAI","slug":"self-class-has-the-config-param-addition-em-7a107b","errorCode":null,"errorMessage":"{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`","messagePattern":"(.+?) 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`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/hidiffusion/hidiffusion.py","lineNumber":1093,"sourceCode":"            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\")\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","sourceCodeStart":1075,"sourceCodeEnd":1111,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/hidiffusion/hidiffusion.py#L1075-L1111","documentation":"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.","triggerScenarios":"Calling forward on an SDXL UNet with `added_cond_kwargs` containing `text_embeds` but not `time_ids`.","commonSituations":"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`.","solutions":["Add `time_ids` to `added_cond_kwargs`: `unet(..., added_cond_kwargs={'text_embeds': p, 'time_ids': add_time_ids})`","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","Reuse `pipe._get_add_time_ids(...)` from diffusers pipelines to construct correct time ids"],"exampleFix":"// before\nunet(sample, t, encoder_hidden_states=emb, added_cond_kwargs={'text_embeds': pooled})\n// after\nadd_time_ids = torch.tensor([[1024, 1024, 0, 0, 1024, 1024]], device=device, dtype=dtype)\nunet(sample, t, encoder_hidden_states=emb,\n     added_cond_kwargs={'text_embeds': pooled, 'time_ids': add_time_ids})","handlingStrategy":"validation","validationCode":"if getattr(unet.config, 'addition_embed_type', None) == 'text_time' and not (added_cond_kwargs and 'time_ids' in added_cond_kwargs):\n    raise ValueError(\"SDXL UNet requires added_cond_kwargs with 'time_ids'\")","typeGuard":"def has_time_ids(added_cond_kwargs) -> bool:\n    return isinstance(added_cond_kwargs, dict) and 'time_ids' in added_cond_kwargs","tryCatchPattern":"try:\n    out = unet(sample, t, emb, added_cond_kwargs=ackw)\nexcept ValueError as e:\n    if 'time_ids' in str(e):\n        ackw['time_ids'] = add_time_ids.to(device, dtype); out = unet(sample, t, emb, added_cond_kwargs=ackw)\n    else: raise","preventionTips":["Construct `add_time_ids` = [orig_h, orig_w, crop_top, crop_left, target_h, target_w] on correct device/dtype","Keep time_ids alongside text_embeds in one cached kwargs dict","Validate the time_ids tensor has 6 elements per batch item"],"tags":["diffusers","unet","sdxl","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"}