From 7e85d3a42cc180d8b8fa85ca815c3e90bf2cb970 Mon Sep 17 00:00:00 2001 From: Flora Cui Date: Fri, 7 Aug 2026 23:43:42 +0800 Subject: [PATCH] [ROCm] Enable pinned memory on supported WSL2 kernels (#50126) Signed-off-by: Flora Cui --- .../scripts/xpu/create-xpu-ecr-manifest.sh | 4 +-- vllm/platforms/rocm.py | 28 ++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.buildkite/scripts/xpu/create-xpu-ecr-manifest.sh b/.buildkite/scripts/xpu/create-xpu-ecr-manifest.sh index 78f2c33b36..9f21118d50 100644 --- a/.buildkite/scripts/xpu/create-xpu-ecr-manifest.sh +++ b/.buildkite/scripts/xpu/create-xpu-ecr-manifest.sh @@ -8,6 +8,6 @@ ARCH_TAG="${BUILDKITE_COMMIT}-$(uname -m)-xpu" PLATFORM_TAG="${BUILDKITE_COMMIT}-xpu" aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REGISTRY} -docker manifest rm ${REGISTRY}/${REPO}:${PLATFORM_TAG} || true -docker manifest create ${REGISTRY}/${REPO}:${PLATFORM_TAG} ${REGISTRY}/${REPO}:${ARCH_TAG} --amend +docker manifest rm "${REGISTRY}/${REPO}:${PLATFORM_TAG}" || true +docker manifest create "${REGISTRY}/${REPO}:${PLATFORM_TAG}" "${REGISTRY}/${REPO}:${ARCH_TAG}" --amend docker manifest push ${REGISTRY}/${REPO}:${PLATFORM_TAG} \ No newline at end of file diff --git a/vllm/platforms/rocm.py b/vllm/platforms/rocm.py index 35bc244261..dd577e1cd2 100644 --- a/vllm/platforms/rocm.py +++ b/vllm/platforms/rocm.py @@ -2,6 +2,7 @@ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import os +import platform from datetime import timedelta from functools import cache, lru_cache, wraps from typing import TYPE_CHECKING @@ -15,7 +16,7 @@ import vllm.envs as envs from vllm.logger import init_logger from vllm.v1.attention.backends.registry import AttentionBackendEnum -from .interface import DeviceCapability, Platform, PlatformEnum +from .interface import DeviceCapability, Platform, PlatformEnum, in_wsl if TYPE_CHECKING: from vllm.config import VllmConfig @@ -113,6 +114,16 @@ def _rocm_device_count_stateless(cuda_visible_devices: str | None = None) -> int return r +@cache +def _get_wsl_kernel_version() -> tuple[int, ...] | None: + try: + release = platform.uname().release + parts = release.split("-")[0].split(".") + return tuple(int(part) for part in parts[:3]) + except (TypeError, ValueError): + return None + + def _sync_hip_cuda_env_vars(): """Ensure HIP_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES are consistent. Treats empty string as unset. Raises on genuine conflicts.""" @@ -536,6 +547,21 @@ class RocmPlatform(Platform): with contextlib.suppress(ImportError): import vllm._rocm_C # noqa: F401 + @classmethod + def is_pin_memory_available(cls) -> bool: + if in_wsl(): + version = _get_wsl_kernel_version() + if version is None or version < (4, 19, 121): + # warning_once() causes a circular import on WSL, see #48397. + logger.warning( + "Using 'pin_memory=False' as WSL is detected and the " + "WSL2 kernel version is below 4.19.121. This may slow " + "down performance. Please run `wsl --update`." + ) + return False + + return True + @classmethod def get_valid_backends( cls,