sgl-project/sglang · error · ValueError

shot_prompts must be non-empty

Error message

shot_prompts must be non-empty

What it means

expand_causal_block_prompts requires at least one shot prompt to build causal block prompts; an empty shot_prompts list is rejected immediately.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/causal_denoising.py:64

logger = init_logger(__name__)

CAUSAL_BLOCK_PROMPTS_KEY = "causal_block_prompts"
CAUSAL_SCENE_CUT_MASK_KEY = "causal_scene_cut_mask"
CAUSAL_SHOT_INDICES_KEY = "causal_shot_indices"
CausalKVCache = CausalSelfAttentionKVCache | QVGPackedCausalKVCache


def expand_causal_block_prompts(
    shot_prompts: list[str],
    *,
    num_blocks: int,
    shot_durations: list[int] | None = None,
    chunks_per_shot: int = 0,
    scene_cut_prefix: str = "",
) -> tuple[list[str], list[bool], list[int]]:
    if not shot_prompts:
        raise ValueError("shot_prompts must be non-empty")
    if num_blocks <= 0:
        raise ValueError("num_blocks must be positive")
    if shot_durations is not None and len(shot_durations) != len(shot_prompts):
        raise ValueError("shot_durations must match shot_prompts length")

    if shot_durations is not None:
        durations = shot_durations[: len(shot_prompts)]
    elif chunks_per_shot > 0:
        durations = [chunks_per_shot] * len(shot_prompts)
    else:
        base, extra = divmod(num_blocks, len(shot_prompts))
        durations = [base + (1 if i < extra else 0) for i in range(len(shot_prompts))]

    clamped: list[int] = []
    remaining = num_blocks
    for duration in durations:
        if remaining <= 0:
            break

View on GitHub (pinned to 0132848349)

Solutions

  1. Provide at least one non-empty shot prompt string
  2. Validate prompts at the request boundary before reaching the pipeline
  3. Check upstream prompt construction for accidental empty lists

Example fix

# before
prompts = expand_causal_block_prompts([], num_blocks=8)
# after
prompts = expand_causal_block_prompts(['a cinematic shot of a fox'], num_blocks=8)
Defensive patterns

Strategy: validation

Validate before calling

prompts = [p for p in shot_prompts if p and p.strip()]
assert prompts, 'shot_prompts empty'

Type guard

def has_shots(prompts: list[str]) -> bool: return bool(prompts)

Prevention

When it happens

Trigger: Calling expand_causal_block_prompts([], num_blocks=4) or a higher-level wrapper (expand_longlive2_shot_prompts / stage._block_prompts) receiving an empty prompt list from the request/config.

Common situations: Empty text prompt in a video generation request; config parsing yields empty shots list; user passes whitespace-only prompt that gets stripped to empty.

Related errors


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