hpcaitech/Open-Sora · error · NotImplementedError

Unknown condition type {cond_type}

Error message

Unknown condition type {cond_type}

What it means

collect_references_batch builds reference latents for image-to-video/video-continuation conditioning and only implements specific cond_type branches (each handling how many reference frames are read and encoded). An unrecognized cond_type string falls to the else and raises NotImplementedError.

Source

Thrown at opensora/utils/inference.py:277

            r = r[:, -1:]
            r_x = model_ae.encode(r.unsqueeze(0).to(device, dtype))
            r_x = r_x.squeeze(0)  # size [C, T, H, W]
            ref.append(r_x)
        elif cond_type == "i2v_loop":
            # first frame
            r_head = read_from_path(ref_path[0], image_size, transform_name="resize_crop")  # size [C, T, H, W]
            r_head = r_head[:, :1]
            r_x_head = model_ae.encode(r_head.unsqueeze(0).to(device, dtype))
            r_x_head = r_x_head.squeeze(0)  # size [C, T, H, W]
            ref.append(r_x_head)
            # last frame
            r_tail = read_from_path(ref_path[-1], image_size, transform_name="resize_crop")  # size [C, T, H, W]
            r_tail = r_tail[:, -1:]
            r_x_tail = model_ae.encode(r_tail.unsqueeze(0).to(device, dtype))
            r_x_tail = r_x_tail.squeeze(0)  # size [C, T, H, W]
            ref.append(r_x_tail)
        else:
            raise NotImplementedError(f"Unknown condition type {cond_type}")

        refs_x.append(ref)
    return refs_x


def prepare_inference_condition(
    z: torch.Tensor,
    mask_cond: str,
    ref_list: list[list[torch.Tensor]] = None,
    causal: bool = True,
) -> torch.Tensor:
    """
    Prepare the visual condition for the model, using causal vae.

    Args:
        z (torch.Tensor): The latent noise tensor, of shape [B, C, T, H, W]
        mask_cond (dict): The condition configuration.
        ref_list: list of lists of media (image/video) for i2v and v2v condition, of shape [C, T', H, W]; len(ref_list)==B; ref_list[i] is the list of media for the generation in batch idx i, we use a list of media for each batch item so that it can have multiple references. For example, ref_list[i] could be [ref_image_1, ref_image_2] for i2v_loop condition.

View on GitHub (pinned to 7ad6a96a13)

Solutions

  1. Check the if/elif chain just above the raise in opensora/utils/inference.py for the exact supported cond_type strings and use one of them
  2. Fix typos/casing in your inference config's cond_type
  3. If you need a new conditioning mode, add an elif branch that reads and encodes the references appropriately

Example fix

# before
refs = collect_references_batch(ref_path, cond_type="i2v_tail")  # unsupported
# after
refs = collect_references_batch(ref_path, cond_type="i2v")  # exact supported value
Defensive patterns

Strategy: validation

Validate before calling

import inspect, opensora.utils.inference as inf
src = inspect.getsource(inf.collect_references_batch)
# or hard-check the supported set from the if/elif chain:
assert cond_type in SUPPORTED_COND_TYPES, f"unsupported cond_type {cond_type!r}"

Type guard

def is_supported_cond_type(ct: str, supported: set) -> bool:
    return ct in supported

Try / catch

try:
    refs = collect_references_batch(ref_path, cond_type=cond_type, ...)
except NotImplementedError:
    raise ValueError(f"cond_type {cond_type!r} unsupported in this opensora version") from None

Prevention

When it happens

Trigger: Calling collect_references_batch (directly or via run_inference / the Gradio api_fn) with a cond_type value not handled by the if/elif chain in this version — e.g. a new or misspelled condition type from the inference config.

Common situations: Using a cond_type from a different opensora version's docs (supported set changed between releases); typos in inference configs; forks adding new conditioning modes without extending this function.

Related errors


AI-assisted analysis of hpcaitech/Open-Sora@7ad6a96a13 (2026-08-28). Data as JSON: /api/errors/ffcfcbc00370698d. Report an issue: GitHub.