{"record":{"id":"eeca16a009dc277f","repo":"sgl-project/sglang","slug":"realtime-causal-sink-size-must-be-non-negative","errorCode":null,"errorMessage":"realtime_causal_sink_size must be non-negative","messagePattern":"realtime_causal_sink_size must be non-negative","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/causal_denoising.py","lineNumber":401,"sourceCode":"            batch_size=b,\n            channels=c,\n            num_frames=t,\n            height=h,\n            width=w,\n        )\n\n    def _apply_causal_cache_overrides(\n        self,\n        batch: Req,\n        server_args: ServerArgs,\n    ) -> None:\n        pipeline_config = server_args.pipeline_config\n        sink_size = getattr(batch, \"realtime_causal_sink_size\", None)\n        if sink_size is None:\n            sink_size = getattr(pipeline_config, \"realtime_causal_sink_size\", None)\n        if sink_size is not None:\n            if sink_size < 0:\n                raise ValueError(\"realtime_causal_sink_size must be non-negative\")\n            self.sink_size = int(sink_size)\n\n        kv_cache_num_frames = getattr(\n            batch,\n            \"realtime_causal_kv_cache_num_frames\",\n            None,\n        )\n        if kv_cache_num_frames is None:\n            kv_cache_num_frames = getattr(\n                pipeline_config,\n                \"realtime_causal_kv_cache_num_frames\",\n                None,\n            )\n        if kv_cache_num_frames is not None:\n            if kv_cache_num_frames <= 0:\n                raise ValueError(\"realtime_causal_kv_cache_num_frames must be positive\")\n            self.sliding_window_num_frames = int(kv_cache_num_frames)\n","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/causal_denoising.py#L383-L419","documentation":"_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.","triggerScenarios":"Setting realtime_causal_sink_size=-1 in pipeline_config or on the request while a causal denoising pipeline initializes its cache policy.","commonSituations":"Using -1 as an 'unset' sentinel instead of None; config templating arithmetic producing negatives; copying configs from another pipeline with different semantics.","solutions":["Set realtime_causal_sink_size to None or omit it if you want the default","Use a non-negative integer (0 disables the sink)","Audit config generation code for negative arithmetic"],"exampleFix":"# before\npipeline_config.realtime_causal_sink_size = -1\n# after\npipeline_config.realtime_causal_sink_size = None","handlingStrategy":"validation","validationCode":"sink = cfg.get('realtime_causal_sink_size')\nassert sink is None or sink >= 0","typeGuard":"def valid_sink(v) -> bool: return v is None or (isinstance(v,int) and v >= 0)","tryCatchPattern":null,"preventionTips":["Use None (not -1) as the unset sentinel in configs"],"tags":["causal-denoising","kv-cache","config-validation"],"backgroundTag":"invalid-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}