[Core] Use platform-agnostic device control for DP engine core (#17245)
Signed-off-by: Jade Zheng <zheng.shoujian@outlook.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import enum
|
||||
import os
|
||||
import platform
|
||||
import random
|
||||
from platform import uname
|
||||
@@ -161,6 +162,24 @@ class Platform:
|
||||
def is_sleep_mode_available(self) -> bool:
|
||||
return self._enum == PlatformEnum.CUDA
|
||||
|
||||
@classmethod
|
||||
def device_id_to_physical_device_id(cls, device_id: int):
|
||||
if cls.device_control_env_var in os.environ:
|
||||
device_ids = os.environ[cls.device_control_env_var].split(",")
|
||||
if device_ids == [""]:
|
||||
msg = (f"{cls.device_control_env_var} is set to empty string, "
|
||||
"which means current platform support is disabled. If "
|
||||
"you are using ray, please unset the environment "
|
||||
f"variable `{cls.device_control_env_var}` inside the "
|
||||
"worker/actor. Check "
|
||||
"https://github.com/vllm-project/vllm/issues/8402 for "
|
||||
"more information.")
|
||||
raise RuntimeError(msg)
|
||||
physical_device_id = device_ids[device_id]
|
||||
return int(physical_device_id)
|
||||
else:
|
||||
return device_id
|
||||
|
||||
@classmethod
|
||||
def get_attn_backend_cls(cls, selected_backend: _Backend, head_size: int,
|
||||
dtype: torch.dtype, kv_cache_dtype: Optional[str],
|
||||
|
||||
Reference in New Issue
Block a user