diff --git a/vllm/platforms/rocm.py b/vllm/platforms/rocm.py index 248f41d20d..9089d025e0 100644 --- a/vllm/platforms/rocm.py +++ b/vllm/platforms/rocm.py @@ -21,6 +21,7 @@ from .interface import DeviceCapability, Platform, PlatformEnum, in_wsl if TYPE_CHECKING: from vllm.config import VllmConfig from vllm.config.kernel import IrOpPriorityConfig + from vllm.utils.argparse_utils import FlexibleArgumentParser from vllm.v1.attention.selector import AttentionSelectorConfig logger = init_logger(__name__) @@ -493,6 +494,9 @@ class RocmPlatform(Platform): dist_backend: str = "nccl" # rocm shares the same device control env var as CUDA device_control_env_var: str = "CUDA_VISIBLE_DEVICES" + # Set in pre_register_and_update, so it exists only on the driver; Ray + # workers are separate processes and copy env vars by allowlist. + additional_env_vars: list[str] = ["GPU_PINNED_MIN_XFER_SIZE"] ray_noset_device_env_vars: list[str] = [ "RAY_EXPERIMENTAL_NOSET_HIP_VISIBLE_DEVICES", "RAY_EXPERIMENTAL_NOSET_CUDA_VISIBLE_DEVICES", @@ -862,6 +866,16 @@ class RocmPlatform(Platform): ) return torch.cuda.get_device_properties(device_id).total_memory + @classmethod + def pre_register_and_update( + cls, parser: "FlexibleArgumentParser | None" = None + ) -> None: + # Keep mmap'd weight pages on the HIP staging path: above this + # threshold the runtime registers the pageable source instead, and each + # registration's MMU notifier makes KFD suspend our queues. In KB, so + # 4 GiB. + os.environ.setdefault("GPU_PINNED_MIN_XFER_SIZE", str(4 * 1024 * 1024)) + @classmethod def apply_config_platform_defaults(cls, vllm_config: "VllmConfig") -> None: from vllm._aiter_ops import rocm_aiter_ops