{"record":{"id":"28140404710193fa","repo":"sgl-project/sglang","slug":"no-compatible-attention-backend-is-available-compo","errorCode":null,"errorMessage":"No compatible attention backend is available{component_suffix}","messagePattern":"No compatible attention backend is available(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/layers/attention/selector.py","lineNumber":294,"sourceCode":"        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(\n    head_size: int,\n    dtype: torch.dtype,\n    supported_attention_backends: tuple[AttentionBackendEnum],","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/layers/attention/selector.py#L276-L312","documentation":"Raised by get_attn_backend when no attention backend compatible with the layer's constraints can be found, and no more specific error (unsupported requirements or a captured selection error) applies. The component suffix identifies which attention component was being resolved.","triggerScenarios":"Calling get_attn_backend with a constraint set (supported backend list, head size, dtype, platform) that matches zero registered backends; reached from prepare_attention_backend_override or layer __init__.","commonSituations":"Exotic head sizes or dtypes unsupported by all backends on the platform; a platform (e.g. NPU/CPU) with a sparse backend registry; overly restrictive supported_attention_backends list in a custom layer.","solutions":["Check the layer's supported_attention_backends and pick a backend in that list supported by your platform","Adjust model config (head_size/dtype) to one supported by an available backend","Ensure the correct platform backend registry is installed/imported"],"exampleFix":"# before\nattn = get_attn_backend(\"flashinfer\", head_size=512, ...)  # no candidate\n# after\nattn = get_attn_backend(\"fa3\", head_size=512, ...)  # supported on this platform","handlingStrategy":"validation","validationCode":"candidates = [b for b in supported_backends if platform_supports(b, head_size, dtype)]\nassert candidates, \"no compatible backend; relax constraints\"","typeGuard":null,"tryCatchPattern":"try:\\n    backend = get_attn_backend(...)\\nexcept ValueError as e:\\n    if 'No compatible attention backend' in str(e):\\n        backend = get_attn_backend('triton', ...)  # portable fallback","preventionTips":["Pre-check supported backend lists against the platform registry","Keep at least one portable backend (triton/torch native) available","Test model configs on the target device before deployment"],"tags":["attention-backend","no-backend-available","multimodal","sglang"],"backgroundTag":"backend-selection-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}