sgl-project/sglang · error · ValueError

{name} must be a sequence

Error message

{name} must be a sequence

What it means

_as_nested_int_list normalizes video block token counts (flat list or nested per-video-reference lists); the top-level value must be a non-str/bytes Sequence.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py:179

def _as_int_list(value: int | Sequence[int] | None, *, name: str) -> list[int]:
    if value is None:
        return []
    if isinstance(value, int):
        return [int(value)]
    if not isinstance(value, Sequence) or isinstance(value, (str, bytes)):
        raise ValueError(f"{name} must be an int or a sequence of ints")
    return [int(item) for item in value]


def _as_nested_int_list(
    value: Sequence[int] | Sequence[Sequence[int]] | None,
    *,
    name: str,
) -> list[list[int]]:
    if value is None:
        return []
    if not isinstance(value, Sequence) or isinstance(value, (str, bytes)):
        raise ValueError(f"{name} must be a sequence")
    if len(value) == 0:
        return []
    first = value[0]
    if isinstance(first, Sequence) and not isinstance(first, (str, bytes)):
        out: list[list[int]] = []
        for group in value:
            if not isinstance(group, Sequence) or isinstance(group, (str, bytes)):
                raise ValueError(f"{name} must not mix nested and flat entries")
            out.append([int(item) for item in group])
        return out
    return [[int(item) for item in value]]


def _as_nested_float_list(
    value: Sequence[float] | Sequence[Sequence[float]] | None,
    *,
    name: str,
) -> list[list[float]]:

View on GitHub (pinned to 0132848349)

Solutions

  1. Wrap the value in a list: [196] or [[196]] per reference
  2. Parse config strings into actual lists before calling
  3. Match the nesting to the number of video references

Example fix

// before
video_block_token_counts=196
// after
video_block_token_counts=[[196]]
Defensive patterns

Strategy: type-guard

Validate before calling

if not isinstance(video_block_token_counts, (list, tuple)) or isinstance(video_block_token_counts, (str, bytes)):
    raise TypeError("video_block_token_counts must be a list")

Type guard

def is_int_sequence(v) -> bool:
    return isinstance(v, (list, tuple)) and not isinstance(v, (str, bytes))

Prevention

When it happens

Trigger: Passing video_block_token_counts as an int, float, str, dict, or None-like scalar instead of a list/tuple, e.g. video_block_token_counts=196 or "[196]".

Common situations: YAML/JSON configs deserializing to scalars or strings; passing a single int where a per-video list is expected; dict keyed by reference id instead of a positional list.

Related errors


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