hpcaitech/Open-Sora · error · ValueError
Didn't get conditional input for conditional model.
Error message
Didn't get conditional input for conditional model.
What it means
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.
Source
Thrown at opensora/models/mmdit/model.py:179
y_vec: Tensor, # clip encoded vec
cond: Tensor = None,
guidance: Tensor | None = None,
):
"""
obtain the processed:
img: projected noisy img latent,
txt: text context (from t5),
vec: clip encoded vector,
pe: the positional embeddings for concatenated img and txt
"""
if img.ndim != 3 or txt.ndim != 3:
raise ValueError("Input img and txt tensors must have 3 dimensions.")
# running on sequences img
img = self.img_in(img)
if self.config.cond_embed:
if cond is None:
raise ValueError("Didn't get conditional input for conditional model.")
img = img + self.cond_in(cond)
vec = self.time_in(timestep_embedding(timesteps, 256))
if self.config.guidance_embed:
if guidance is None:
raise ValueError(
"Didn't get guidance strength for guidance distilled model."
)
vec = vec + self.guidance_in(timestep_embedding(guidance, 256))
vec = vec + self.vector_in(y_vec)
txt = self.txt_in(txt)
# concat: 4096 + t*h*2/4
ids = torch.cat((txt_ids, img_ids), dim=1)
pe = self.pe_embedder(ids)
if self._input_requires_grad:View on GitHub (pinned to 7ad6a96a13)
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
Example fix
# before out = model(img, txt, timesteps, y_vec=y_vec) # cond_embed=True # after out = model(img, txt, timesteps, y_vec=y_vec, cond=cond_emb)
Defensive patterns
Strategy: validation
Validate before calling
if model.config.cond_embed:
assert cond is not None, "cond_embed=True requires the cond tensor" Type guard
def needs_cond(model) -> bool:
return bool(getattr(model.config, "cond_embed", False)) Try / catch
try:
out = model(img, txt, t, y_vec=y_vec, cond=cond)
except ValueError as e:
if "conditional input" in str(e):
raise TypeError("checkpoint is conditional; supply cond= or use a cond_embed=False checkpoint") from e
raise Prevention
- Match inference script flags to checkpoint's cond_embed setting
- Pass cond explicitly for conditional checkpoints
- Centralize model-config inspection in your runner
When it happens
Trigger: 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).
Common situations: 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.
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
- Didn't get guidance strength for guidance distilled model.
- Hidden size {config.hidden_size} must be divisible by num_he
- Got {config.axes_dim} but expected positional dim {pe_dim}
- Input img and txt tensors must have 3 dimensions.
- ContextParallelAttention should not be initialized directly.
AI-assisted analysis of hpcaitech/Open-Sora@7ad6a96a13 (2026-08-28).
Data as JSON: /api/errors/f4b6305801f81ce7.
Report an issue: GitHub.