{"record":{"id":"3e4d11c7f8cc4dc9","repo":"sgl-project/sglang","slug":"batching-config-rule-device-memory-gb-min-must-be","errorCode":null,"errorMessage":"batching config rule device_memory_gb_min must be <= device_memory_gb_max","messagePattern":"batching config rule device_memory_gb_min must be <= device_memory_gb_max","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py","lineNumber":121,"sourceCode":"        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,\n    ) -> bool:\n        if self.model is not None and self.model != model_path:\n            return False\n        if self.model_contains is not None and self.model_contains not in model_path:\n            return False\n        if self.resolution not in (None, \"*\") and self.resolution != resolution:\n            return False\n        if self.offload is not None and self.offload != offload:","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py#L103-L139","documentation":"When a rule specifies both device_memory_gb_min and device_memory_gb_max device-memory bounds, the min must not exceed the max. validate() enforces the ordering when both are present.","triggerScenarios":"A rule with \"device_memory_gb_min\": 80 and \"device_memory_gb_max\": 40 (both non-None and min > max).","commonSituations":"Swapped min/max keys while hand-editing; stale bounds after hardware changes (e.g. old 40GB upper bound kept with new 80GB floor).","solutions":["Swap or correct the two values so min <= max","If you only need a floor or ceiling, specify just one bound"],"exampleFix":"// before\n{\"model\": \"x\", \"max_batch_size\": 4, \"device_memory_gb_min\": 80, \"device_memory_gb_max\": 40}\n// after\n{\"model\": \"x\", \"max_batch_size\": 4, \"device_memory_gb_min\": 40, \"device_memory_gb_max\": 80}","handlingStrategy":"validation","validationCode":"for i, r in enumerate(rules):\n    lo, hi = r.get(\"device_memory_gb_min\"), r.get(\"device_memory_gb_max\")\n    if lo is not None and hi is not None and lo > hi:\n        raise SystemExit(f\"rule[{i}]: device_memory_gb_min > max\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set both memory bounds when you truly need a window"],"tags":["config","batching","validation","range-check","gpu-memory"],"backgroundTag":"config-value-out-of-range","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}