[CPU][Fix CI] Solidate torch version for sgl-kernel-cpu and fix device orientation error (#17460)
This commit is contained in:
@@ -4,7 +4,7 @@ requires = ["setuptools>=61.0", "setuptools-scm>=8.0", "wheel", "grpcio-tools==1
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "sglang"
|
||||
name = "sglang-cpu"
|
||||
dynamic = ["version"]
|
||||
description = "SGLang is a fast serving framework for large language models and vision language models."
|
||||
readme = "README.md"
|
||||
|
||||
@@ -238,8 +238,21 @@ class GroupCoordinator:
|
||||
self.cpu_group = None
|
||||
self.local_size = get_int_env_var("LOCAL_SIZE", 0)
|
||||
|
||||
if is_cuda_alike():
|
||||
device_id = (
|
||||
0 if envs.SGLANG_ONE_VISIBLE_DEVICE_PER_PROCESS.get() else local_rank
|
||||
)
|
||||
self.device = torch.device(f"cuda:{device_id}")
|
||||
elif _is_npu:
|
||||
self.device = torch.device(f"npu:{local_rank}")
|
||||
elif _is_xpu:
|
||||
self.device = torch.device(f"xpu:{local_rank}")
|
||||
else:
|
||||
self.device = torch.device("cpu")
|
||||
self.device_module = torch.get_device_module(self.device)
|
||||
|
||||
for ranks in group_ranks:
|
||||
active_ranks = torch.ones(len(ranks), dtype=torch.int32, device="cuda")
|
||||
active_ranks = torch.ones(len(ranks), dtype=torch.int32, device=self.device)
|
||||
active_ranks_cpu = torch.ones(len(ranks), dtype=torch.int32)
|
||||
if "mooncake" in torch_distributed_backend:
|
||||
from mooncake.ep import MooncakeBackendOptions
|
||||
@@ -275,17 +288,6 @@ class GroupCoordinator:
|
||||
assert self.cpu_group is not None
|
||||
assert self.device_group is not None
|
||||
|
||||
if is_cuda_alike():
|
||||
device_id = (
|
||||
0 if envs.SGLANG_ONE_VISIBLE_DEVICE_PER_PROCESS.get() else local_rank
|
||||
)
|
||||
self.device = torch.device(f"cuda:{device_id}")
|
||||
elif _is_npu:
|
||||
self.device = torch.device(f"npu:{local_rank}")
|
||||
else:
|
||||
self.device = torch.device("cpu")
|
||||
self.device_module = torch.get_device_module(self.device)
|
||||
|
||||
# Import communicators
|
||||
self.use_pynccl = use_pynccl
|
||||
self.pynccl_use_current_stream = pynccl_use_current_stream
|
||||
|
||||
Reference in New Issue
Block a user