{"record":{"id":"c06acf5af1c41080","repo":"sgl-project/sglang","slug":"unsupported-device-type-device-r-if-this-is-an","errorCode":null,"errorMessage":"Unsupported device type: {device!r}. If this is an OOT platform, ensure it is properly registered via the 'sglang.platform_plugins' entry point.","messagePattern":"Unsupported device type: (.+?)\\. If this is an OOT platform, ensure it is properly registered via the 'sglang\\.platform_plugins' entry point\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/common.py","lineNumber":525,"sourceCode":"                \"memory allocation for torch MUSA context.\",\n                gpu_id,\n                torch.musa.current_device(),\n            )\n        if empty_cache:\n            empty_device_cache(torch.musa)\n        props = torch.musa.get_device_properties(gpu_id)\n        if props.is_integrated:\n            # On these devices, which use sysmem as device mem, torch.musa.mem_get_info()\n            # only reports \"free\" memory, which can be lower than what is actually\n            # available due to not including cache memory. So we use the system available\n            # memory metric instead.\n            free_gpu_memory = psutil.virtual_memory().available\n        free_gpu_memory, total_gpu_memory = torch.musa.mem_get_info()\n    elif device == \"mps\":\n        free_gpu_memory = psutil.virtual_memory().available\n    else:\n        if not current_platform.is_out_of_tree():\n            raise ValueError(\n                f\"Unsupported device type: {device!r}. \"\n                \"If this is an OOT platform, ensure it is properly registered \"\n                \"via the 'sglang.platform_plugins' entry point.\"\n            )\n        total_mem = current_platform.get_device_total_memory(gpu_id)\n        used_mem = current_platform.get_current_memory_usage()\n        free_gpu_memory = total_mem - used_mem\n\n    if distributed:\n        tensor = torch.tensor(free_gpu_memory, dtype=torch.float32)\n        torch.distributed.all_reduce(\n            tensor, op=torch.distributed.ReduceOp.MIN, group=cpu_group\n        )\n        free_gpu_memory = tensor.item()\n\n    return free_gpu_memory / (1 << 30)\n\n","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/common.py#L507-L543","documentation":"get_available_gpu_memory enumerates known device backends (cuda, npu, mps, musa, ...). For an unrecognized device string it only proceeds if current_platform.is_out_of_tree(); otherwise it raises ValueError telling you the OOT platform must be registered via the 'sglang.platform_plugins' entry point.","triggerScenarios":"Calling get_available_gpu_memory with a device string not in the handled list on a non-OOT platform, e.g. a new accelerator or a typo, reached during kernel load (_on_kernel_load).","commonSituations":"Porting SGLang to a new backend without writing a platform plugin; partial OOT setup where the plugin isn't installed/registered; wrong device id string from env config.","solutions":["Install/register your platform via the 'sglang.platform_plugins' entry point implementing is_out_of_tree(), get_device_total_memory, get_current_memory_usage","Verify the device string matches a supported backend (cuda/npu/mps/musa/rocm)","Update SGLang if your backend is newly supported upstream"],"exampleFix":"# before\n# custom backend 'xyz' not registered -> ValueError in get_available_gpu_memory\n# after\n# pyproject.toml of your platform package:\n[project.entry-points.'sglang.platform_plugins']\nxyz = 'sglang_xyz:register_platform'","handlingStrategy":"validation","validationCode":"supported = {'cuda','npu','mps','musa'}\nassert device in supported or current_platform.is_out_of_tree(), device\nmem = get_available_gpu_memory(device, gpu_id)","typeGuard":"def is_supported_device(device: str) -> bool:\n    return device in {'cuda','npu','mps','musa'} or current_platform.is_out_of_tree()","tryCatchPattern":null,"preventionTips":["Validate the device string during config parsing","Install platform plugins via the 'sglang.platform_plugins' entry point before running on new hardware"],"tags":["platform-plugin","device","configuration"],"backgroundTag":"unsupported-device-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}