sgl-project/sglang · error · ValueError
batching config rule cannot set both model and model_contain
Error message
batching config rule cannot set both model and model_contains
What it means
A BatchingRule cannot restrict matches by both an exact model name and a model_contains substring; the two selectors are mutually exclusive. validate() runs at the end of from_dict and raises when both fields are non-None.
Source
Thrown at python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py:107
raise ValueError("batching config rule requires max_batch_size")
rule = cls(
model=_optional_str(data.get("model")),
model_contains=_optional_str(data.get("model_contains")),
resolution=_optional_str(data.get("resolution")),
device_memory_gb_min=_optional_float(data.get("device_memory_gb_min")),
device_memory_gb_max=_optional_float(data.get("device_memory_gb_max")),
offload=_optional_bool(data.get("offload")),
max_batch_size=int(data["max_batch_size"]),
max_cost=_optional_float(data.get("max_cost")),
source=source,
)
rule.validate()
return rule
def validate(self) -> None:
if self.model is not None and self.model_contains is not None:
raise ValueError(
"batching config rule cannot set both model and model_contains"
)
if self.model is None and self.model_contains is None:
raise ValueError("batching config rule requires model or model_contains")
if self.max_batch_size < 1:
raise ValueError("batching config rule max_batch_size must be >= 1")
if self.max_cost is not None and self.max_cost <= 0.0:
raise ValueError("batching config rule max_cost must be > 0")
if (
self.device_memory_gb_min is not None
and self.device_memory_gb_max is not None
and self.device_memory_gb_min > self.device_memory_gb_max
):
raise ValueError(
"batching config rule device_memory_gb_min must be <= device_memory_gb_max"
)
def matches(View on GitHub (pinned to 0132848349)
Solutions
- Delete either "model" or "model_contains" from the rule, keeping exactly one selector
- If you need both exact and substring matches, split into two separate rules
Example fix
// before
{"model": "qwen-image", "model_contains": "qwen", "max_batch_size": 4}
// after
{"model_contains": "qwen", "max_batch_size": 4} Defensive patterns
Strategy: validation
Validate before calling
for i, r in enumerate(rules):
if "model" in r and "model_contains" in r:
raise SystemExit(f"rule[{i}]: model and model_contains are mutually exclusive") Prevention
- Decide per rule whether you need exact or substring matching before writing it
When it happens
Trigger: A config rule containing both "model" and "model_contains" keys, e.g. {"model": "foo", "model_contains": "bar", "max_batch_size": 4}.
Common situations: Copy-paste of an existing rule followed by adding model_contains for a broader match, leaving the old exact model key in place; schema drift after the rule format added model_contains.
Related errors
- batching config rule requires max_batch_size
- batching config rule requires model or model_contains
- batching config rule max_batch_size must be >= 1
- batching config rule max_cost must be > 0
- batching config rule device_memory_gb_min must be <= device_
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/a288329ee73d3c51.
Report an issue: GitHub.