sgl-project/sglang · error · ValueError

seq must be positive, got {seq}

Error message

seq must be positive, got {seq}

What it means

Raised by _build_video_cfg in the Dots Note Omni multimodal processor when the seq parameter is zero or negative. seq bounds the total sequence budget for a video request; a non-positive value makes the derived seq_length meaningless, so the processor rejects it before building the config dict.

Source

Thrown at python/sglang/srt/multimodal/processors/dots_note_omni.py:49

from sglang.srt.utils import VideoData, get_video_bytes

logger = logging.getLogger(__name__)

_VIDEO_TOKEN_RE = re.compile(r"(<image_\d+>|<audio_\d+>)")
_EXPANDED_VIDEO_MEDIA_RE = re.compile(
    r"<\|sglang_dots_video_(?P<video>\d+)_(?P<modality>image|audio)_(?P<item>\d+)\|>"
)


def _build_video_cfg(
    *,
    seq: int,
    audio_cap: float,
    audio_sr: int,
    max_new_tokens: int,
) -> dict[str, Any]:
    if seq <= 0:
        raise ValueError(f"seq must be positive, got {seq}")
    if max_new_tokens < 0:
        raise ValueError(f"max_new_tokens must be non-negative, got {max_new_tokens}")
    if max_new_tokens >= seq:
        raise ValueError(
            "max_new_tokens must leave room for input: "
            f"max_new_tokens={max_new_tokens}, seq={seq}"
        )
    if audio_cap < 0:
        raise ValueError(f"audio_cap must be non-negative, got {audio_cap}")
    if audio_sr <= 0:
        raise ValueError(f"audio_sr must be positive, got {audio_sr}")

    return {
        "process_audio": audio_cap > 0,
        "seq_length": seq - max_new_tokens,
        "reserve_interleave": True,
        "audio_token_ratio_cap": float(audio_cap),
        "audio_sample_rate": int(audio_sr),

View on GitHub (pinned to 0132848349)

Solutions

  1. Check that seq (video_config 'seq', default 131072) is > 0 before sending the request
  2. If computing seq from context window, ensure max_new_tokens < context_len so the subtraction stays positive
  3. Validate in the client: raise early with your own message instead of the server-side ValueError

Example fix

// before
video_config = {"seq": context_len - max_new_tokens}  # can be <= 0
// after
video_config = {"seq": max(1, context_len - max_new_tokens)}
assert video_config["seq"] > 0
Defensive patterns

Strategy: validation

Validate before calling

cfg = request.get('video_config') or {}
seq = cfg.get('seq', 131072)
assert isinstance(seq, int) and seq > 0, f'seq must be positive, got {seq}'

Type guard

def valid_seq(cfg: dict) -> bool:
    seq = cfg.get('seq', 131072)
    return isinstance(seq, int) and not isinstance(seq, bool) and seq > 0

Prevention

When it happens

Trigger: Calling preprocess_dots_video (directly or via process_mm_data_async) with seq<=0, e.g. passing video_config={"seq": 0} in the request, or omitting it while a wrapper computes seq as context_len - max_tokens and underflows to <=0.

Common situations: Users compute seq = model_context_len - max_new_tokens and pass a negative value when max_new_tokens exceeds context length; or they copy a config where seq is set per-model and use 0/None coerced to 0.

Related errors


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