sgl-project/sglang · error · ValueError
reference audio start time must be non-negative
Error message
reference audio start time must be non-negative
What it means
_load_waveform requires the audio clip start time to be a non-negative finite float. A negative start time would seek before the beginning of the media and is rejected before ffmpeg is invoked.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/reference_encoding.py:232
) -> tuple[torch.Tensor, int]:
"""Apply the audio material chain.
Pure-audio references preserve their source rate while normalizing to
stereo. Video-bearing references first extract 44.1 kHz stereo PCM. The
audio VAE boundary then performs the single 32 kHz resample below. ffmpeg
writes bounded interleaved float PCM directly to stdout, avoiding a
temporary lossless file plus a second decode.
"""
import numpy as np
if max_duration_seconds is not None:
max_duration_seconds = float(max_duration_seconds)
if not math.isfinite(max_duration_seconds) or max_duration_seconds <= 0:
raise ValueError("reference audio duration bound must be positive")
start_time_seconds = float(start_time_seconds)
if not math.isfinite(start_time_seconds) or start_time_seconds < 0:
raise ValueError("reference audio start time must be non-negative")
if material_chain == "audio":
if source_sample_rate is None or int(source_sample_rate) <= 0:
raise ValueError("reference audio sample rate must be positive")
source_rate = int(source_sample_rate)
elif material_chain in {
"video.reference_preserve",
"video_audio.reference_preserve",
}:
source_rate = 44100
else:
raise ValueError(
f"unsupported MiniMax H3 audio material chain {material_chain!r}"
)
command = [
"ffmpeg",
"-v",View on GitHub (pinned to 0132848349)
Solutions
- Clamp start times: start = max(0.0, start)
- Treat negative offsets as offsets from the end and convert: start = max(0.0, total_duration + negative_offset)
- Validate request timestamps server-side before the pipeline
Example fix
// before start = marker_t - 5.0 # may go negative // after start = max(0.0, marker_t - 5.0)
Defensive patterns
Strategy: validation
Validate before calling
def valid_start(t) -> bool:
import math
return math.isfinite(t) and t >= 0 Prevention
- Clamp computed start times with max(0.0, x)
- Validate user-supplied offsets at the API boundary
When it happens
Trigger: Passing start_time_seconds < 0 or NaN to minimax_h3_encode_reference_audio_rows, e.g. from a sign error in timestamp math.
Common situations: Clip offsets computed as (marker - duration) underflowing below zero, or API users sending negative offsets to trim from the end.
Related errors
- MiniMax H3 audio material has no usable sample rate
- MiniMax H3 audio material has no usable channel count
- reference audio duration bound must be positive
- reference audio sample rate must be positive
- reference audio is empty: {audio_path}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/111dcf3bcca0fa5d.
Report an issue: GitHub.