{"record":{"id":"3c7c21e2ae9f8df2","repo":"sgl-project/sglang","slug":"selection-error-component-suffix","errorCode":null,"errorMessage":"{selection_error}{component_suffix}","messagePattern":"\\{selection_error\\}\\{component_suffix\\}","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/layers/attention/selector.py","lineNumber":291,"sourceCode":"            continue\n\n        attention_backend_cls = candidate_cls\n        if candidate_index > 0:\n            fallback_reason = allowed_fallback_reason\n        break\n\n    if attention_backend_cls is None:\n        component_name = get_component_attn_backend_name()\n        component_suffix = (\n            f\" for component '{component_name}'\" if component_name is not None else \"\"\n        )\n        if unsupported_requirements:\n            raise ValueError(\n                f\"Attention backend '{unsupported_backend_name}' does not implement \"\n                f\"{', '.join(unsupported_requirements)}{component_suffix}\"\n            )\n        if selection_error is not None:\n            raise ValueError(\n                f\"{selection_error}{component_suffix}\"\n            ) from selection_error\n        raise ValueError(\n            f\"No compatible attention backend is available{component_suffix}\"\n        )\n\n    backend_name = attention_backend_cls.get_enum().name.lower()\n    reason = fallback_reason\n    if reason is None and backend_name == constraint_backend:\n        reason = \"component constraint\"\n    if not _record_component_attn_backend(backend_name, reason):\n        reason_suffix = f\" ({reason})\" if reason else \"\"\n        logger.info_once(f\"Using {backend_name} attention backend{reason_suffix}\")\n    return attention_backend_cls\n\n\n@cache\ndef _cached_get_attn_backend(","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/layers/attention/selector.py#L273-L309","documentation":"Raised by get_attn_backend in the multimodal runtime's attention backend selector when a candidate backend was tried and its own selection logic raised an error (e.g. the backend's constructor/requirements check failed). The original exception is chained via `from selection_error`, so the cause message is embedded at the front of the string, followed by a component suffix naming the attention component.","triggerScenarios":"Calling get_attn_backend (directly or via layer __init__ / prepare_attention_backend_override) where every candidate backend's internal selection raises; the selection_error string is prepended to the message.","commonSituations":"A model config requests an attention backend whose __init__ fails on the current platform (e.g. flashinfer missing, unsupported dtype/head size), and the selector falls through to re-raising the underlying error wrapped in ValueError.","solutions":["Read the chained cause (`__cause__`) — the real failure is the selection_error text, fix that (install backend deps, adjust head_size/dtype/config)","Verify the attention backend name in the model/server config is valid for your platform","If the underlying error is a missing optional dependency, install it (e.g. flashinfer) and retry"],"exampleFix":"# before: server fails with wrapped selection error\n# after: inspect cause and fix root issue\ntry:\n    get_attn_backend(...)\nexcept ValueError as e:\n    logger.error(\"root cause: %s\", e.__cause__)\n    raise","handlingStrategy":"try-catch","validationCode":"from sglang.multimodal_gen.runtime.layers.attention.selector import get_attn_backend\ntry:\n    get_attn_backend(name, head_size, dtype, supported_backends)\nexcept ValueError:\n    ...","typeGuard":null,"tryCatchPattern":"try:\\n    backend = get_attn_backend(...)\\nexcept ValueError as e:\\n    root = e.__cause__ or e\\n    logger.error(\"backend selection failed: %s\", root)\\n    raise","preventionTips":["Validate backend name against the layer's supported list before requesting","Pin backend dependency versions in the environment","Surface e.__cause__ in logs to find the real failure"],"tags":["attention-backend","config","multimodal","sglang"],"backgroundTag":"backend-selection-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}