Replace hardcoded CUDA device with get_device() for XPU support (#13599)

Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
This commit is contained in:
Kalyan Kumar
2026-05-01 07:13:46 +08:00
committed by GitHub
co-authored by Ma Mingfei
parent c5f1339773
commit 8a9e424faa
4 changed files with 54 additions and 14 deletions
@@ -32,7 +32,7 @@ from sglang.srt.environ import envs
from sglang.srt.model_executor.forward_batch_info import ForwardBatch
from sglang.srt.observability.metrics_collector import ExpertDispatchCollector
from sglang.srt.server_args import ServerArgs
from sglang.srt.utils import Withable, get_int_env_var
from sglang.srt.utils import Withable, get_device, get_int_env_var
if TYPE_CHECKING:
from sglang.srt.eplb.expert_location import ExpertLocationMetadata
@@ -475,6 +475,9 @@ def _list_sum(a: List, b: List) -> List:
class _LayerBasedGpuSinglePassGatherer(_SinglePassGatherer):
def __init__(self, *args, enable_global_physical_experts: bool, **kwargs):
super().__init__(*args, **kwargs)
device = get_device()
self._enable_global_physical_experts = enable_global_physical_experts
self._data = torch.zeros(
(
@@ -486,7 +489,7 @@ class _LayerBasedGpuSinglePassGatherer(_SinglePassGatherer):
),
),
dtype=torch.int,
device="cuda",
device=device,
)
def reset(self):