sgl-project/sglang · error · ValueError

{path}.kind unsupported for ref2va: {kind!r}

Error message

{path}.kind unsupported for ref2va: {kind!r}

What it means

After extracting a valid kind string from a ref_blocks entry, the ref2va builder only supports 'image', 'audio', and 'video' kinds; any other non-empty kind hits the unsupported-kind branch. This guards the layout arithmetic which is specialized per media type, so unknown kinds cannot be silently ignored.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_sequence.py:354

            vh = _positive_int(raw, "latent_h", path)
            vw = _positive_int(raw, "latent_w", path)
            frame_rows = (vh // _PATCH_H) * (vw // _PATCH_W)
            audio_rows = rt * audio_channel
            video_rows = vt * frame_rows
            item = {
                "kind": kind,
                "ref_audio_t": rt,
                "latent_t": vt,
                "latent_h": vh,
                "latent_w": vw,
                "frame_rows": frame_rows,
                "audio_rows": audio_rows,
                "video_rows": video_rows,
            }
            ref_audio_rows += audio_rows
            ref_visual_rows += video_rows
        else:
            raise ValueError(f"{path}.kind unsupported for ref2va: {kind!r}")
        parsed.append(item)

    ph, pw = latent_h // _PATCH_H, latent_w // _PATCH_W
    frame_rows = ph * pw
    keyframe_indices = _keyframe_cond_frame_indices(
        include_keyframe_cond=keyframe_frame_indices is not None,
        keyframe_frame_indices=keyframe_frame_indices,
    )
    resolved_keyframe_indices = _resolve_keyframe_frame_indices(
        keyframe_indices,
        frame_count=frame_count,
    )
    keyframe_rows = len(keyframe_indices) * frame_rows
    video_rows = latent_t * frame_rows
    audio_rows = audio_t * audio_channel
    ref_rows = ref_visual_rows + ref_audio_rows
    used = text_len + keyframe_rows + ref_rows + audio_rows + video_rows
    if seq_len is None:

View on GitHub (pinned to 0132848349)

Solutions

  1. Normalize the kind to one of image/audio/video exactly (lowercase).
  2. If you genuinely need a new kind, extend the dispatch in minimax_h3_packed_sequence_ref2va_blocks in packed_sequence.py.
  3. Whitelist-validate ref_blocks kinds upstream (e.g. in _branch) so unsupported kinds are rejected with context earlier.

Example fix

# before
ref_blocks = [{"kind": "Image", "latent_h": 32, "latent_w": 32}]

# after
ref_blocks = [{"kind": "image", "latent_h": 32, "latent_w": 32}]
Defensive patterns

Strategy: type-guard

Validate before calling

ALLOWED_REF2VA_KINDS = {"image", "audio", "video"}
assert all(b.get("kind", b.get("type")) in ALLOWED_REF2VA_KINDS for b in ref_blocks)

Type guard

def has_supported_ref2va_kind(raw: Mapping) -> bool:
    return raw.get("kind", raw.get("type")) in {"image", "audio", "video"}

Prevention

When it happens

Trigger: Calling minimax_h3_packed_sequence_ref2va_blocks with a ref_blocks entry whose 'kind'/'type' is e.g. 'text', 'Image' (capitalized), 'img', or a future media type not handled by this builder.

Common situations: Case or spelling drift between producer and consumer ('Image' vs 'image', 'vid' vs 'video'); adding a new media modality to the pipeline without extending the packer; copy-pasting blocks from a different model's stage that supports more kinds.

Related errors


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