sgl-project/sglang · error · ValueError

seed must be non-negative, got {normalized_seed}

Error message

seed must be non-negative, got {normalized_seed}

What it means

The optional `seed` field of a MiniMax-H3 canonical request must be a non-negative integer. The validator normalizes it with _require_int and rejects negative values with this error.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/request_validation.py:372

    canonical: dict[str, Any] = {
        "schema": MINIMAX_H3_REQUEST_SCHEMA,
        "task": task_name,
        "prompt": prompt_text,
        "conditions": normalized_conditions,
        "target": normalized_target,
    }
    normalized_flow_shift = _optional_positive_finite_float(flow_shift, "flow_shift")
    normalized_audio_flow_shift = _optional_positive_finite_float(
        audio_flow_shift, "audio_flow_shift"
    )
    if normalized_flow_shift is not None:
        canonical["flow_shift"] = normalized_flow_shift
    if normalized_audio_flow_shift is not None:
        canonical["audio_flow_shift"] = normalized_audio_flow_shift
    if seed is not None:
        normalized_seed = _require_int(seed, "seed")
        if normalized_seed < 0:
            raise ValueError(f"seed must be non-negative, got {normalized_seed}")
        if normalized_seed > MINIMAX_H3_MAX_SIGNED_SEED:
            raise ValueError(
                f"seed must not exceed the signed int64 maximum, got {normalized_seed}"
            )
        canonical["seed"] = normalized_seed
    return canonical


__all__ = [
    "MINIMAX_H3_REQUEST_SCHEMA",
    "MINIMAX_H3_MAX_SIGNED_SEED",
    "MINIMAX_H3_SUPPORTED_FPS",
    "minimax_h3_validate_canonical_request",
]

View on GitHub (pinned to 0132848349)

Solutions

  1. Use a non-negative integer seed, or omit seed entirely to let the server choose
  2. Use a different sentinel (None) for 'unspecified'

Example fix

// before
{"seed":-1}
// after
{"seed":42}  // or omit the key
Defensive patterns

Strategy: validation

Validate before calling

def seed_ok(seed):
    return seed is None or (isinstance(seed, int) and not isinstance(seed, bool) and seed >= 0)

Type guard

def is_valid_seed(v) -> bool: return v is None or (type(v) is int and 0 <= v <= 2**63 - 1)

Try / catch

null

Prevention

When it happens

Trigger: Calling minimax_h3_validate_canonical_request with seed set to a negative integer (e.g. -1) to 'randomize'.

Common situations: Porting code from another API where seed=-1 means random; passing -1 as a sentinel for unspecified.

Related errors


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