From 1ebff996a118cdc6e831c521c839d29ffe47d30f Mon Sep 17 00:00:00 2001 From: Yizhou <136800916+yiz-liu@users.noreply.github.com> Date: Sun, 30 Aug 2026 12:23:10 +0800 Subject: [PATCH] [Fix] Improve ROCm detection in WSL environments (#38434) Signed-off-by: Yizhou Liu --- vllm/platforms/__init__.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/vllm/platforms/__init__.py b/vllm/platforms/__init__.py index 718e2520c4..8cf8282e5d 100644 --- a/vllm/platforms/__init__.py +++ b/vllm/platforms/__init__.py @@ -10,7 +10,7 @@ from vllm import envs from vllm.plugins import PLATFORM_PLUGINS_GROUP, load_plugins_by_group from vllm.utils.import_utils import resolve_obj_by_qualname -from .interface import CpuArchEnum, Platform, PlatformEnum +from .interface import CpuArchEnum, Platform, PlatformEnum, in_wsl logger = logging.getLogger(__name__) @@ -125,6 +125,20 @@ def rocm_platform_plugin() -> str | None: except Exception as e: logger.debug("ROCm platform is not available because: %s", str(e)) + if not is_rocm and in_wsl(): + try: + import torch + + if ( + not vllm_version_matches_substr("cpu") + and getattr(torch.version, "hip", None) + and torch.accelerator.is_available() + ): + is_rocm = True + logger.debug("Confirmed ROCm platform is available in WSL via PyTorch.") + except Exception as e: + logger.debug("WSL ROCm fallback detection failed because: %s", str(e)) + return "vllm.platforms.rocm.RocmPlatform" if is_rocm else None