{"record":{"id":"0d0b71f8f1c97d42","repo":"sgl-project/sglang","slug":"batching-config-rule-max-batch-size-must-be-1","errorCode":null,"errorMessage":"batching config rule max_batch_size must be >= 1","messagePattern":"batching config rule max_batch_size must be >= 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py","lineNumber":113,"sourceCode":"            device_memory_gb_min=_optional_float(data.get(\"device_memory_gb_min\")),\n            device_memory_gb_max=_optional_float(data.get(\"device_memory_gb_max\")),\n            offload=_optional_bool(data.get(\"offload\")),\n            max_batch_size=int(data[\"max_batch_size\"]),\n            max_cost=_optional_float(data.get(\"max_cost\")),\n            source=source,\n        )\n        rule.validate()\n        return rule\n\n    def validate(self) -> None:\n        if self.model is not None and self.model_contains is not None:\n            raise ValueError(\n                \"batching config rule cannot set both model and model_contains\"\n            )\n        if self.model is None and self.model_contains is None:\n            raise ValueError(\"batching config rule requires model or model_contains\")\n        if self.max_batch_size < 1:\n            raise ValueError(\"batching config rule max_batch_size must be >= 1\")\n        if self.max_cost is not None and self.max_cost <= 0.0:\n            raise ValueError(\"batching config rule max_cost must be > 0\")\n        if (\n            self.device_memory_gb_min is not None\n            and self.device_memory_gb_max is not None\n            and self.device_memory_gb_min > self.device_memory_gb_max\n        ):\n            raise ValueError(\n                \"batching config rule device_memory_gb_min must be <= device_memory_gb_max\"\n            )\n\n    def matches(\n        self,\n        *,\n        model_path: str,\n        resolution: str | None,\n        device_memory_gb: float | None,\n        offload: bool,","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py#L95-L131","documentation":"max_batch_size must be a positive integer (>= 1); zero or negative values are meaningless for admission control and validate() rejects them.","triggerScenarios":"A rule with \"max_batch_size\": 0, a negative number, or a non-integer value that coerces to < 1 (e.g. \"max_batch_size\": \"0\").","commonSituations":"Using 0 intending 'unlimited/disabled' (the code has no unlimited sentinel); copy from a template placeholder; off-by-one tuning experiments.","solutions":["Set max_batch_size to 1 or higher","To effectively disable batching for a model, set max_batch_size: 1 rather than 0"],"exampleFix":"// before\n{\"model\": \"x\", \"max_batch_size\": 0}\n// after\n{\"model\": \"x\", \"max_batch_size\": 1}","handlingStrategy":"validation","validationCode":"for i, r in enumerate(rules):\n    v = r.get(\"max_batch_size\")\n    if not isinstance(v, int) or v < 1:\n        raise SystemExit(f\"rule[{i}]: max_batch_size must be an int >= 1\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use max_batch_size: 1 (not 0) to serialize a model's requests"],"tags":["config","batching","validation","range-check"],"backgroundTag":"config-value-out-of-range","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}