[Fix] Improve ROCm detection in WSL environments - #38434
Conversation
Adds fallback detection for ROCm platforms running in Windows Subsystem for Linux (WSL) by checking `torch.version.hip` when standard detection fails. This enables proper platform identification for ROCm setups in WSL where traditional detection methods may not work reliably. Also replaces `warning_once` with `warning` in GCN architecture detection to avoid circular import issues that arise when the distributed module attempts to query the current platform. Signed-off-by: Yizhou Liu <liu_yizhou@outlook.com>
There was a problem hiding this comment.
Code Review
This pull request introduces ROCm platform detection for WSL environments and resolves a circular import issue in the ROCm platform module by replacing warning_once with warning. Feedback suggests refining the ROCm detection logic to ensure it does not activate when vLLM is built for CPU-only, which prevents potential runtime conflicts between detected platforms.
| if getattr(torch.version, "hip", None): | ||
| is_rocm = True | ||
| logger.debug("Confirmed ROCm platform is available in WSL via torch.version.hip.") |
There was a problem hiding this comment.
This fallback detection for ROCm is a good addition for WSL. However, similar to cuda_platform_plugin, we should avoid activating the ROCm platform if vLLM was built for CPU-only, even if ROCm is available on the system. Otherwise, this can lead to conflicts where both CPU and ROCm platforms are detected as active, causing a runtime error.
Let's add a check for CPU-only builds here. Note that the existing amdsmi detection path also seems to be missing this check, which should probably be fixed in a separate change to ensure consistency.
| if getattr(torch.version, "hip", None): | |
| is_rocm = True | |
| logger.debug("Confirmed ROCm platform is available in WSL via torch.version.hip.") | |
| if getattr(torch.version, "hip", None): | |
| if not vllm_version_matches_substr("cpu"): | |
| is_rocm = True | |
| logger.debug("Confirmed ROCm platform is available in WSL via torch.version.hip.") | |
| else: | |
| logger.debug( | |
| "ROCm platform is not available because vLLM is built with CPU." | |
| ) |
|
Possibly related: ROCm/ROCm#5007 (comment) |
MengqingCao
left a comment
There was a problem hiding this comment.
LGTM, thanks for this fix, @tjtanaa could you take a look at this fix?
|
Hey @yiz-liu , Poked around a bit and wanted to flag a couple things in case it helps get this over the line: The torch.version.hip check alone doesn't confirm a device is actually visible (no is_available() / device_count() check), which is basically the CPU-only-build false-positive risk @gemini-code-assist called out above — probably worth tightening before merge. For reference, I put together an extended version of this same idea (device-visibility check, a VLLM_ROCM_GCN_ARCH env override, rocminfo fallback, plus tests) here if it's useful as a reference: https://github.com/Soluchann/vllm/tree/fix/rocm-wsl-platform-detection |
Purpose
Adds fallback detection for ROCm platforms running in WSL by checking
torch.version.hipasamd-smiandrocm-smiis unreachable in WSL now. This enables proper platform identification for ROCm setups in WSL where traditional detection methods may not work reliably.Also replaces
warning_oncewithwarningin GCN architecture detection to avoid circular import issues that arise when the distributed module attempts to query the current platform.Test Plan
Currently only tested with one device and
VLLM_ATTENTION_BACKEND=TRITON_ATTNTest Result
Details
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.