sgl-project/sglang · error · ValueError

Unsupported model type: {model_type}

Error message

Unsupported model type: {model_type}

What it means

ReasoningParser looks up model_type.lower() in its DetectorMap; an unrecognized name raises this ValueError listing the offending type. The map keys are per-model detector names (e.g. qwen3-thinking, deepseek-r1), not arbitrary model names.

Source

Thrown at python/sglang/srt/parser/reasoning_parser.py:1976

        "inkling": InklingDetector,
        "cohere_command4": CohereCommand4Detector,
    }

    def __init__(
        self,
        model_type: Optional[str] = None,
        stream_reasoning: bool = True,
        force_reasoning: Optional[bool] = None,
        request: ChatCompletionRequest = None,
        tokenizer=None,
        tool_call_parser_active: bool = False,
    ):
        if not model_type:
            raise ValueError("Model type must be specified")

        detector_class = self.DetectorMap.get(model_type.lower())
        if not detector_class:
            raise ValueError(f"Unsupported model type: {model_type}")

        chat_template_kwargs = getattr(request, "chat_template_kwargs", None) or {}

        # Special cases where we override force_reasoning
        if model_type.lower() in {
            "qwen3-thinking",
            "gpt-oss",
            "minimax",
        }:
            force_reasoning = True

        # M3 consumes the <mm:think> start tag only for thinking_mode=enabled
        # (absent from output → must force); mirror serving_chat's M3 branch.
        if model_type.lower() == "minimax-m3" and force_reasoning is None:
            force_reasoning = chat_template_kwargs.get("thinking_mode") == "enabled"

        # Only pass force_reasoning if explicitly set, let detectors use their defaults
        kwargs = {"stream_reasoning": stream_reasoning}

View on GitHub (pinned to 0132848349)

Solutions

  1. Check ReasoningParser.DetectorMap keys and use an exact (case-insensitive) match
  2. Fix typos/underscores — names use hyphens like 'deepseek-r1'
  3. If the model genuinely has no reasoning format, don't enable the reasoning parser for it
  4. Update sglang to a version that registers your model's detector

Example fix

// before
parser = ReasoningParser(model_type="deepseek_r1")
// after
parser = ReasoningParser(model_type="deepseek-r1")
Defensive patterns

Strategy: validation

Validate before calling

supported = set(map(str.lower, ReasoningParser.DetectorMap.keys()))
if model_type.lower() not in supported:
    raise ValueError(f"unsupported; choose from {sorted(supported)}")

Type guard

def is_supported_reasoning_model(mt: str) -> TypeGuard[str]:
    return mt.lower() in ReasoningParser.DetectorMap

Try / catch

try:
    parser = ReasoningParser(model_type=model_type)
except ValueError as e:
    if "Unsupported model type" in str(e):
        parser = None  # run without reasoning parsing
    else:
        raise

Prevention

When it happens

Trigger: Passing a model name that has no registered reasoning detector, e.g. ReasoningParser(model_type='llama-3') or a typo like 'deepseek_r1'.

Common situations: New or uncommon models lacking a reasoning parser, casing/underscore mismatches, or version drift where a detector name was renamed between releases.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/02627025b34c629d. Report an issue: GitHub.