sgl-project/sglang · error · ValueError

keyframe denoising requires one encoded keyframe per semanti

Error message

keyframe denoising requires one encoded keyframe per semantic anchor

What it means

keyframe['keyframes'] must be a list with exactly one encoded entry per semantic anchor, and each entry must be a Mapping. Any non-list, wrong length, or non-mapping entries raise ValueError.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/denoising.py:126

        raise ValueError("keyframe payload frame_count must be greater than one")
    pixel_indices = keyframe.get("pixel_frame_indices")
    expected_pixel_indices = [
        frame_count - 1 if index == -1 else index for index in semantic_indices
    ]
    if pixel_indices != expected_pixel_indices:
        raise ValueError(
            "keyframe denoising requires pixel_frame_indices resolved from the "
            "semantic anchors, "
            f"got {pixel_indices!r} for frame_count={frame_count}"
        )

    entries = keyframe.get("keyframes")
    if (
        not isinstance(entries, list)
        or len(entries) != len(semantic_indices)
        or any(not isinstance(entry, Mapping) for entry in entries)
    ):
        raise ValueError(
            "keyframe denoising requires one encoded keyframe per semantic anchor"
        )
    if [entry.get("frame_index") for entry in entries] != list(semantic_indices):
        raise ValueError("encoded keyframes must remain in semantic anchor order")
    if [
        entry.get("resolved_frame_index") for entry in entries
    ] != expected_pixel_indices:
        raise ValueError(
            "encoded keyframes must carry matching resolved_frame_index values"
        )

    latent_h = int(keyframe.get("latent_h") or 0)
    latent_w = int(keyframe.get("latent_w") or 0)
    rows = keyframe.get("rows")
    expected_rows = len(semantic_indices) * (latent_h // 2) * (latent_w // 2)
    if (
        latent_h <= 0
        or latent_w <= 0

View on GitHub (pinned to 0132848349)

Solutions

  1. Ensure exactly len(semantic_frame_indices) dict entries in keyframes
  2. Wrap non-mapping entries with dataclasses.asdict()/dict(...) or skip failures upstream by reducing anchors
  3. Fail the whole request if any keyframe source can't be encoded, rather than emitting a short list

Example fix

# before
payload["keyframes"] = [enc0]  # 2 anchors, 1 entry
# after
payload["keyframes"] = [enc0, enc1]  # one per semantic anchor
Defensive patterns

Strategy: validation

Validate before calling

kfs = keyframe.get("keyframes")
assert isinstance(kfs, list) and len(kfs) == len(sem) and all(isinstance(e, Mapping) for e in kfs)

Type guard

def keyframes_valid(kf) -> bool:
    kfs = kf.get("keyframes")
    sem = kf.get("semantic_frame_indices") or ()
    return isinstance(kfs, list) and len(kfs) == len(sem) and all(isinstance(e, Mapping) for e in kfs)

Prevention

When it happens

Trigger: An empty keyframes list with 2 anchors, 3 entries for 2 anchors, entries as tuples/classes instead of dicts, or the field missing (None).

Common situations: Dropping one encoded keyframe when its source image failed to load; producers emitting dataclasses or namedtuples instead of dict-like entries.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/aeeecdfae61b1f37. Report an issue: GitHub.