sgl-project/sglang · error · ValueError
{name} must not mix nested and flat entries
Error message
{name} must not mix nested and flat entries What it means
When the first element of video_block_token_counts is a sequence (nested form), every subsequent element must also be a sequence; mixing ints and lists is ambiguous and rejected.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py:187
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]]:
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)):View on GitHub (pinned to 0132848349)
Solutions
- Normalize all entries to the same shape — nested lists for multiple videos ([[196],[128]]) or a flat list for a single video ([196,128])
- Fix the data assembly to always append lists
Example fix
// before video_block_token_counts=[[196,196], 128] // after video_block_token_counts=[[196,196], [128]]
Defensive patterns
Strategy: validation
Validate before calling
assert all(isinstance(g, (list, tuple)) for g in video_block_token_counts), "uniform nesting required"
Type guard
def uniform_nested(v: list) -> bool:
return all(isinstance(g, (list, tuple)) for g in v) or all(not isinstance(g, (list, tuple)) for g in v) Prevention
- Build per-video groups with one append path
- Never mix scalars into nested lists
When it happens
Trigger: Passing video_block_token_counts=[[196,196], 128] — first entry nested, second flat.
Common situations: Concatenating per-video lists with stray scalars; heterogeneous data built from mixed sources; appending a default scalar to a list of lists.
Related errors
- refiner cu_seqlens live text length must be in [1, {int(text
- {context}video block token counts and timestamps must align
- {context}video block token count must be positive
- {name} must be a sequence
- video reference requires block token counts and timestamps
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/5e42a71216061808.
Report an issue: GitHub.