sgl-project/sglang · error · ValueError
conditions[{index}].frame_index must be -1 or in [0, {frame_
Error message
conditions[{index}].frame_index must be -1 or in [0, {frame_count}) after 17n+5 frame alignment, got {semantic_frame_index} What it means
The semantic frame_index must be -1 (last frame) or a non-negative int strictly below shape['frame_count'] (computed after 17n+5 frame alignment). Anything else raises this ValueError with the offending value.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py:343
keyframe_pixel_indices: list[int] = []
seen_keyframe_pixel_indices: dict[int, int] = {}
for index, cond in enumerate(canonical["conditions"]):
rule = profile.rule_for(
role=str(cond["role"]), condition_type=str(cond["type"])
)
frame_index = cond.get("frame_index")
resolved_frame_index = None
if rule.requires_frame_index:
if frame_index is None:
raise ValueError(f"conditions[{index}].frame_index is required")
semantic_frame_index = int(frame_index)
frame_count = int(shape["frame_count"])
if semantic_frame_index == -1:
resolved_frame_index = frame_count - 1
elif 0 <= semantic_frame_index < frame_count:
resolved_frame_index = semantic_frame_index
else:
raise ValueError(
f"conditions[{index}].frame_index must be -1 or in "
f"[0, {frame_count}) after 17n+5 frame alignment, got "
f"{semantic_frame_index}"
)
previous = seen_keyframe_pixel_indices.get(resolved_frame_index)
if previous is not None:
raise ValueError(
f"conditions[{index}].frame_index resolves to "
f"{resolved_frame_index}, already bound by "
f"conditions[{previous}]"
)
seen_keyframe_pixel_indices[resolved_frame_index] = index
keyframe_semantic_indices.append(semantic_frame_index)
keyframe_pixel_indices.append(resolved_frame_index)
materials.append(
MiniMaxH3MaterialPlanItem(
condition_index=index,
role=str(cond["role"]),View on GitHub (pinned to 0132848349)
Solutions
- Use -1 for the last frame instead of a computed absolute index
- Lower the frame_index below the resolved frame_count (recompute frame_count from the request's duration/resolution under 17n+5 alignment)
- Increase the requested video length so frame_count exceeds the index
Example fix
# before
{"frame_index": frame_count} # off-by-one, out of range
# after
{"frame_index": -1} # semantic last frame Defensive patterns
Strategy: validation
Validate before calling
assert fi == -1 or 0 <= fi < frame_count, fi
Type guard
def in_frame_range(fi: int, frame_count: int) -> bool:
return fi == -1 or 0 <= fi < frame_count Prevention
- Use -1 for last frame instead of absolute indices
- Recompute frame_count after 17n+5 alignment before validating indices
When it happens
Trigger: Passing frame_index >= frame_count (e.g. 17 for a short clip), or a negative index other than -1 such as -2.
Common situations: Requesting the last frame by passing an explicit large index instead of -1; frame_count shrinking after the 17n+5 alignment for a very short requested duration, making previously valid indices out of range.
Related errors
- H3 conditioning projection tap {tap} is outside the selected
- condition_frame_indexes={cond_indexes} exceeds the latent fr
- {cpath}.frame_index requires a resolved target duration
- {cpath}.frame_index must be -1 or in [0, {aligned_frame_coun
- {profile.task} ResolvedPlan requires one or two ordered imag
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/9a73078d38e2ac27.
Report an issue: GitHub.