sgl-project/sglang · error · RuntimeError
Multiple serve backends matched this request: {names}. Selec
Error message
Multiple serve backends matched this request: {names}. Select one explicitly with --model-type BACKEND. What it means
Thrown by ServeBackendRegistry.auto_detect() when more than one registered backend's detector claims the request (e.g. the model path/config matches both a diffusion backend and another backend). Because detection cannot pick a winner, SGLang requires the user to disambiguate explicitly with --model-type.
Source
Thrown at python/sglang/cli/serve_backends.py:206
if not isinstance(result, ServeBackendDetection):
raise TypeError(
"detector must return ServeBackendDetection, got "
f"{type(result).__name__}"
)
if result is ServeBackendDetection.MATCH:
matches.append(registered)
except Exception as exc:
# An unrelated optional extension must not make the default LLM
# path unusable. Explicit selection remains strict via get().
logger.warning(
"Skipping automatic detection for serve backend %r: %s",
name,
exc,
)
if len(matches) > 1:
names = ", ".join(match.name for match in matches)
raise RuntimeError(
f"Multiple serve backends matched this request: {names}. "
"Select one explicitly with --model-type BACKEND."
)
if matches:
return matches[0]
return self.get("llm")
@classmethod
def _entry_point_distribution(cls, entry_point: EntryPoint) -> str | None:
distribution = getattr(entry_point, "dist", None)
return getattr(distribution, "name", None)
@classmethod
def _entry_point_provider(cls, entry_point: EntryPoint) -> str:
return cls._entry_point_distribution(entry_point) or entry_point.value
__all__ = [View on GitHub (pinned to 0132848349)
Solutions
- Pass --model-type BACKEND with one of the names listed in the error.
- If you own one of the detectors, narrow its detect() predicate so it only matches its intended models.
- Uninstall the redundant backend package if it was accidental.
Example fix
# before sglang serve --model-path ./my-model # after sglang serve --model-path ./my-model --model-type diffusion
Defensive patterns
Strategy: fallback
Validate before calling
from sglang.cli.serve_backends import ServeBackendRegistry reg = ServeBackendRegistry() # detect ambiguity before it raises # (mirror auto_detect's match loop, or simply always pass --model-type)
Try / catch
try:
backend = registry.auto_detect(model_path=p, ...)
except RuntimeError as e:
if "Multiple serve backends matched" in str(e):
names = parse_names(e)
backend = registry.get(choose_interactively(names)) Prevention
- Always pass --model-type explicitly in scripts/automation to bypass detection.
- When writing plugins, keep detect() predicates narrow (exact config keys, not substrings).
When it happens
Trigger: Running `sglang serve --model-path X` without --model-type where X matches multiple backends' detect() predicates; calling auto_detect(model_path=...) with an ambiguous path; two plugins implementing overly broad detectors.
Common situations: A model directory containing both LLM-style config.json and diffusion-model artifacts; a third-party detector that matches too aggressively alongside the built-in diffusion detector.
Related errors
- Unknown serve backend {name!r}. Available values: {available
- Multiple distributions register serve backend {name!r}: {pro
- Failed to load serve backend {name!r} from {self._entry_poin
- Serve backend {name!r} factory returned {type(backend).__nam
- Serve backend {name!r} uses API version {backend.api_version
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/f91fad6be33cfab4.
Report an issue: GitHub.