sgl-project/sglang · critical · ValueError
{selection_error}{component_suffix}
Error message
{selection_error}{component_suffix} What it means
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.
Source
Thrown at python/sglang/multimodal_gen/runtime/layers/attention/selector.py:291
continue
attention_backend_cls = candidate_cls
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(View on GitHub (pinned to 0132848349)
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
Example fix
# before: server fails with wrapped selection error
# after: inspect cause and fix root issue
try:
get_attn_backend(...)
except ValueError as e:
logger.error("root cause: %s", e.__cause__)
raise Defensive patterns
Strategy: try-catch
Validate before calling
from sglang.multimodal_gen.runtime.layers.attention.selector import get_attn_backend
try:
get_attn_backend(name, head_size, dtype, supported_backends)
except ValueError:
... Try / catch
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 Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No compatible attention backend is available{component_suffi
- For multimodal input processing do not set `enable_tokenizer
- Sparse Video Gen 2 attention does not support causal attenti
- Attention backend '{selected_backend}' is not supported by t
- f"Unsupported patch_size type: {type(patch_size)}"
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/3c7c21e2ae9f8df2.
Report an issue: GitHub.