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
|
|
|
|
|
|
2026-01-28 22:12:52 +08:00
|
|
|
from vllm_omni.platforms import current_omni_platform
|
2025-11-30 20:39:06 +08:00
|
|
|
|
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."""
|
2026-01-28 22:12:52 +08:00
|
|
|
local_rank = int(os.environ.get("LOCAL_RANK", 0))
|
|
|
|
|
return current_omni_platform.get_torch_device(local_rank)
|