2025-11-28 14:22:11 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
import torch
|
|
|
|
|
|
2025-11-30 20:39:06 +08:00
|
|
|
from vllm_omni.utils.platform_utils import detect_device_type
|
|
|
|
|
|
2025-11-28 14:22:11 +08:00
|
|
|
|
|
|
|
|
def get_local_device() -> torch.device:
|
2025-11-30 20:39:06 +08:00
|
|
|
"""Return the torch device for the current rank based on detected device type."""
|
|
|
|
|
device_type = detect_device_type()
|
|
|
|
|
local_rank = os.environ.get("LOCAL_RANK", 0)
|
|
|
|
|
return torch.device(f"{device_type}:{local_rank}")
|