{"record":{"id":"f4b6305801f81ce7","repo":"hpcaitech/Open-Sora","slug":"didn-t-get-conditional-input-for-conditional-model","errorCode":null,"errorMessage":"Didn't get conditional input for conditional model.","messagePattern":"Didn't get conditional input for conditional model\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"opensora/models/mmdit/model.py","lineNumber":179,"sourceCode":"        y_vec: Tensor,  # clip encoded vec\n        cond: Tensor = None,\n        guidance: Tensor | None = None,\n    ):\n        \"\"\"\n        obtain the processed:\n            img: projected noisy img latent,\n            txt: text context (from t5),\n            vec: clip encoded vector,\n            pe: the positional embeddings for concatenated img and txt\n        \"\"\"\n        if img.ndim != 3 or txt.ndim != 3:\n            raise ValueError(\"Input img and txt tensors must have 3 dimensions.\")\n\n        # running on sequences img\n        img = self.img_in(img)\n        if self.config.cond_embed:\n            if cond is None:\n                raise ValueError(\"Didn't get conditional input for conditional model.\")\n            img = img + self.cond_in(cond)\n\n        vec = self.time_in(timestep_embedding(timesteps, 256))\n        if self.config.guidance_embed:\n            if guidance is None:\n                raise ValueError(\n                    \"Didn't get guidance strength for guidance distilled model.\"\n                )\n            vec = vec + self.guidance_in(timestep_embedding(guidance, 256))\n        vec = vec + self.vector_in(y_vec)\n\n        txt = self.txt_in(txt)\n\n        # concat: 4096 + t*h*2/4\n        ids = torch.cat((txt_ids, img_ids), dim=1)\n        pe = self.pe_embedder(ids)\n\n        if self._input_requires_grad:","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/hpcaitech/Open-Sora/blob/7ad6a96a135feb81f755c84fb391818718f6beb2/opensora/models/mmdit/model.py#L161-L197","documentation":"When the MMDiT config enables cond_embed (conditional-input projection), prepare_block_inputs requires a non-None cond tensor to add via self.cond_in(cond). Passing no cond (or cond=None) means the conditional branch cannot execute, so it fails fast.","triggerScenarios":"Instantiating the model with config.cond_embed=True and calling forward without the cond argument (all forward variants: mmdit_model_forward, forward_ckpt, forward_selective_ckpt).","commonSituations":"Loading a conditional checkpoint but running an unconditional-generation code path; shared inference scripts that omit cond for unconditional models; refactor dropping the cond kwarg.","solutions":["Pass cond=... (the conditional embedding tensor, shape compatible with img sequence length) to forward","If you intended an unconditional model, set config.cond_embed=False (and use a matching checkpoint)","Audit the call site: mmdit_model_forward and ckpt variants need the same argument"],"exampleFix":"# before\nout = model(img, txt, timesteps, y_vec=y_vec)  # cond_embed=True\n# after\nout = model(img, txt, timesteps, y_vec=y_vec, cond=cond_emb)","handlingStrategy":"validation","validationCode":"if model.config.cond_embed:\n    assert cond is not None, \"cond_embed=True requires the cond tensor\"","typeGuard":"def needs_cond(model) -> bool:\n    return bool(getattr(model.config, \"cond_embed\", False))","tryCatchPattern":"try:\n    out = model(img, txt, t, y_vec=y_vec, cond=cond)\nexcept ValueError as e:\n    if \"conditional input\" in str(e):\n        raise TypeError(\"checkpoint is conditional; supply cond= or use a cond_embed=False checkpoint\") from e\n    raise","preventionTips":["Match inference script flags to checkpoint's cond_embed setting","Pass cond explicitly for conditional checkpoints","Centralize model-config inspection in your runner"],"tags":["transformer","mmdit","conditional-input","api-misuse"],"backgroundTag":"missing-required-argument","analyzedSha":"7ad6a96a135feb81f755c84fb391818718f6beb2","analyzedAt":"2026-08-28T16:58:37.171Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}