sgl-project/sglang · critical · ValueError

No compatible attention backend is available{component_suffi

Error message

No compatible attention backend is available{component_suffix}

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/layers/attention/selector.py:294

        if candidate_index > 0:
            fallback_reason = allowed_fallback_reason
        break

    if attention_backend_cls is None:
        component_name = get_component_attn_backend_name()
        component_suffix = (
            f" for component '{component_name}'" if component_name is not None else ""
        )
        if unsupported_requirements:
            raise ValueError(
                f"Attention backend '{unsupported_backend_name}' does not implement "
                f"{', '.join(unsupported_requirements)}{component_suffix}"
            )
        if selection_error is not None:
            raise ValueError(
                f"{selection_error}{component_suffix}"
            ) from selection_error
        raise ValueError(
            f"No compatible attention backend is available{component_suffix}"
        )

    backend_name = attention_backend_cls.get_enum().name.lower()
    reason = fallback_reason
    if reason is None and backend_name == constraint_backend:
        reason = "component constraint"
    if not _record_component_attn_backend(backend_name, reason):
        reason_suffix = f" ({reason})" if reason else ""
        logger.info_once(f"Using {backend_name} attention backend{reason_suffix}")
    return attention_backend_cls


@cache
def _cached_get_attn_backend(
    head_size: int,
    dtype: torch.dtype,
    supported_attention_backends: tuple[AttentionBackendEnum],

View on GitHub (pinned to 0132848349)

Solutions

  1. Check the layer's supported_attention_backends and pick a backend in that list supported by your platform
  2. Adjust model config (head_size/dtype) to one supported by an available backend
  3. Ensure the correct platform backend registry is installed/imported

Example fix

# before
attn = get_attn_backend("flashinfer", head_size=512, ...)  # no candidate
# after
attn = get_attn_backend("fa3", head_size=512, ...)  # supported on this platform
Defensive patterns

Strategy: validation

Validate before calling

candidates = [b for b in supported_backends if platform_supports(b, head_size, dtype)]
assert candidates, "no compatible backend; relax constraints"

Try / catch

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

Prevention

When it happens

Trigger: 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__.

Common situations: 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.

Related errors


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