[ROCm] Enable pinned memory on supported WSL2 kernels (#50126)
Signed-off-by: Flora Cui <flora.cui@amd.com>
Flora Cui committed
Aug 7, 2026 at 23:43 UTC
7e85d3a42cc180d8b8fa85ca815c3e90bf2cb970
2 files changed
+29
-3
.buildkite/scripts/xpu/create-xpu-ecr-manifest.sh
+2
-2
@@ -8,6 +8,6 @@ ARCH_TAG="${BUILDKITE_COMMIT}-$(uname -m)-xpu"
8
PLATFORM_TAG="${BUILDKITE_COMMIT}-xpu"
9
10
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REGISTRY}
11
-docker manifest rm ${REGISTRY}/${REPO}:${PLATFORM_TAG} || true
12
-docker manifest create ${REGISTRY}/${REPO}:${PLATFORM_TAG} ${REGISTRY}/${REPO}:${ARCH_TAG} --amend
11
+docker manifest rm "${REGISTRY}/${REPO}:${PLATFORM_TAG}" || true
12
+docker manifest create "${REGISTRY}/${REPO}:${PLATFORM_TAG}" "${REGISTRY}/${REPO}:${ARCH_TAG}" --amend
13
docker manifest push ${REGISTRY}/${REPO}:${PLATFORM_TAG}
\ No newline at end of file
vllm/platforms/rocm.py
+27
-1
@@ -2,6 +2,7 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
import os
5
+import platform
6
from datetime import timedelta
7
from functools import cache, lru_cache, wraps
8
from typing import TYPE_CHECKING
@@ -15,7 +16,7 @@ import vllm.envs as envs
16
from vllm.logger import init_logger
17
from vllm.v1.attention.backends.registry import AttentionBackendEnum
18
18
-from .interface import DeviceCapability, Platform, PlatformEnum
19
+from .interface import DeviceCapability, Platform, PlatformEnum, in_wsl
20
21
if TYPE_CHECKING:
22
from vllm.config import VllmConfig
@@ -113,6 +114,16 @@ def _rocm_device_count_stateless(cuda_visible_devices: str | None = None) -> int
114
return r
115
116
117
+@cache
118
+def _get_wsl_kernel_version() -> tuple[int, ...] | None:
119
+ try:
120
+ release = platform.uname().release
121
+ parts = release.split("-")[0].split(".")
122
+ return tuple(int(part) for part in parts[:3])
123
+ except (TypeError, ValueError):
124
+ return None
125
+
126
+
127
def _sync_hip_cuda_env_vars():
128
"""Ensure HIP_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES are consistent.
129
Treats empty string as unset. Raises on genuine conflicts."""
@@ -536,6 +547,21 @@ class RocmPlatform(Platform):
547
with contextlib.suppress(ImportError):
548
import vllm._rocm_C # noqa: F401
549
550
+ @classmethod
551
+ def is_pin_memory_available(cls) -> bool:
552
+ if in_wsl():
553
+ version = _get_wsl_kernel_version()
554
+ if version is None or version < (4, 19, 121):
555
+ # warning_once() causes a circular import on WSL, see #48397.
556
+ logger.warning(
557
+ "Using 'pin_memory=False' as WSL is detected and the "
558
+ "WSL2 kernel version is below 4.19.121. This may slow "
559
+ "down performance. Please run `wsl --update`."
560
+ )
561
+ return False
562
+
563
+ return True
564
+
565
@classmethod
566
def get_valid_backends(
567
cls,