{"record":{"id":"69361b1cc9660dd3","repo":"sgl-project/sglang","slug":"op-op-r-has-no-backend-usable-on-device-platfor","errorCode":null,"errorMessage":"op {op!r} has no backend usable on device {platform.device.value!r} (registered: {[s.backend.value for s in specs]})","messagePattern":"op (.+?) has no backend usable on device (.+?) \\(registered: (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/selector.py","lineNumber":76,"sourceCode":"    if not specs:\n        raise KeyError(f\"No kernels registered for op {op!r}\")\n\n    if backend is not None:\n        for spec in specs:\n            if spec.backend == backend:\n                return spec\n        raise KeyError(f\"No '{backend.value}' backend registered for op {op!r}\")\n\n    if len(specs) == 1:\n        return specs[0]\n\n    # Multiple backends: hard-filter by device eligibility.\n    platform = _platform()\n    eligible = [s for s in specs if s.is_available(platform)]\n    if len(eligible) == 1:\n        return eligible[0]\n    if not eligible:\n        raise ValueError(\n            f\"op {op!r} has no backend usable on device {platform.device.value!r} \"\n            f\"(registered: {[s.backend.value for s in specs]})\"\n        )\n    raise ValueError(\n        f\"op {op!r} has multiple backends usable on device \"\n        f\"{platform.device.value!r} ({[s.backend.value for s in eligible]}); \"\n        f\"pass backend=... to choose one\"\n    )\n\n\n@lru_cache(maxsize=None)\ndef _resolve(op: str, backend: Optional[KernelBackend]) -> Callable:\n    return select_kernel(op, backend=backend).load()\n\n\ndef get_kernel(op: str, backend: Optional[KernelBackend] = None) -> Callable:\n    \"\"\"Resolve ``op`` to a callable kernel and cache it.\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/selector.py#L58-L94","documentation":"Raised when an op has multiple registered backends but, after hard-filtering by device eligibility via spec.is_available(platform), none can run on the current device. This is an environment/platform mismatch: e.g. kernels registered only for CUDA while running on CPU/ROCm, or the backend's optional package is not importable.","triggerScenarios":"select_kernel(op) with no explicit backend on a machine where every registered backend's is_available(platform) returns False — missing flashinfer/sgl-kernel packages, running on a device none of the specs target (CPU host, unsupported GPU arch).","commonSituations":"Running sglang on non-CUDA hardware or a container without the compiled kernel wheels; CI machines without GPUs; a new backend whose availability check fails due to an uninstalled dependency.","solutions":["Install the optional backend package the op needs (e.g. the flashinfer or sgl-kernel wheel matching your torch/CUDA version).","Verify the runtime device matches what the kernels support (CUDA available, correct compute capability); run on supported hardware.","If you have a working backend for your device, pass backend= explicitly so eligibility filtering is skipped only when that backend is registered."],"exampleFix":"# before (on a host where flashinfer/cuda kernels unavailable)\nspec = select_kernel(op)\n\n# after\npip install flashinfer  # or sgl-kernel matching your torch build\nspec = select_kernel(op)","handlingStrategy":"fallback","validationCode":"from sglang.kernels.registry import registry\nfrom sglang.kernels.platform import _platform\n\np = _platform()\neligible = [s for s in registry.get(op, []) if s.is_available(p)]\nif not eligible:\n    raise SystemExit(f\"No kernel backend for {op} on {p.device}; install flashinfer/sgl-kernel\")","typeGuard":null,"tryCatchPattern":"try:\n    spec = select_kernel(op)\nexcept ValueError as e:\n    if 'no backend usable' in str(e):\n        use_pure_torch_fallback()  # e.g. torch-native implementation\n    else:\n        raise","preventionTips":["Pin the exact kernel wheels (flashinfer/sgl-kernel) in your image.","Fail fast at startup with an environment self-test listing missing backends.","Keep a torch-native fallback path for CPU/debug environments."],"tags":["kernels","device-eligibility","environment","missing-dependency","sglang"],"backgroundTag":"no-backend-available-on-device","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}