sgl-project/sglang · error · ValueError

realtime_causal_sink_size must be non-negative

Error message

realtime_causal_sink_size must be non-negative

What it means

_apply_causal_cache_overrides reads realtime_causal_sink_size from the request or pipeline_config; if set, it must be >= 0 since a negative sink window is meaningless for the attention cache policy.

Source

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

            batch_size=b,
            channels=c,
            num_frames=t,
            height=h,
            width=w,
        )

    def _apply_causal_cache_overrides(
        self,
        batch: Req,
        server_args: ServerArgs,
    ) -> None:
        pipeline_config = server_args.pipeline_config
        sink_size = getattr(batch, "realtime_causal_sink_size", None)
        if sink_size is None:
            sink_size = getattr(pipeline_config, "realtime_causal_sink_size", None)
        if sink_size is not None:
            if sink_size < 0:
                raise ValueError("realtime_causal_sink_size must be non-negative")
            self.sink_size = int(sink_size)

        kv_cache_num_frames = getattr(
            batch,
            "realtime_causal_kv_cache_num_frames",
            None,
        )
        if kv_cache_num_frames is None:
            kv_cache_num_frames = getattr(
                pipeline_config,
                "realtime_causal_kv_cache_num_frames",
                None,
            )
        if kv_cache_num_frames is not None:
            if kv_cache_num_frames <= 0:
                raise ValueError("realtime_causal_kv_cache_num_frames must be positive")
            self.sliding_window_num_frames = int(kv_cache_num_frames)

View on GitHub (pinned to 0132848349)

Solutions

  1. Set realtime_causal_sink_size to None or omit it if you want the default
  2. Use a non-negative integer (0 disables the sink)
  3. Audit config generation code for negative arithmetic

Example fix

# before
pipeline_config.realtime_causal_sink_size = -1
# after
pipeline_config.realtime_causal_sink_size = None
Defensive patterns

Strategy: validation

Validate before calling

sink = cfg.get('realtime_causal_sink_size')
assert sink is None or sink >= 0

Type guard

def valid_sink(v) -> bool: return v is None or (isinstance(v,int) and v >= 0)

Prevention

When it happens

Trigger: Setting realtime_causal_sink_size=-1 in pipeline_config or on the request while a causal denoising pipeline initializes its cache policy.

Common situations: Using -1 as an 'unset' sentinel instead of None; config templating arithmetic producing negatives; copying configs from another pipeline with different semantics.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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