A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 02:15 UTC
[XPU][CI] enhance xpu test support (#20652)
Signed-off-by: Ma, Liangliang <liangliang.ma@intel.com> Co-authored-by: zhenwei-intel <zhenweiliu@habana.ai>
Liangliang Ma committed
Jul 10, 2025 at 00:53 UTC
a3e4e85ece3c01cf58ffe049540b988e3751001c
5 files changed
+18
-12
tests/conftest.py
+3
-2
@@ -759,7 +759,8 @@ class VllmRunner:
759
- `trust_remote_code`: Set to `True` instead of `False` for convenience.
760
- `seed`: Set to `0` instead of `None` for test reproducibility.
761
- `max_model_len`: Set to `1024` instead of `None` to reduce memory usage.
762
- - `block_size`: Set to `16` instead of `None` to reduce memory usage.
762
+ - `block_size`: To reduce memory usage, set default to `64` if on XPU
763
+ devices, otherwise default to `16`.
764
- `enable_chunked_prefill`: Set to `False` instead of `None` for
765
test reproducibility.
766
- `enforce_eager`: Set to `False` to test CUDA graph.
@@ -777,7 +778,7 @@ class VllmRunner:
778
dtype: str = "auto",
779
disable_log_stats: bool = True,
780
tensor_parallel_size: int = 1,
780
- block_size: int = 16,
781
+ block_size: int = 16 if not torch.xpu.is_available() else 64,
782
enable_chunked_prefill: Optional[bool] = False,
783
swap_space: int = 4,
784
enforce_eager: Optional[bool] = False,
vllm/distributed/device_communicators/xpu_communicator.py
+3
@@ -53,3 +53,6 @@ class XpuCommunicator(DeviceCommunicatorBase):
53
else:
54
output_tensor = None
55
return output_tensor
56
+
57
+ def broadcast(self, input_: torch.Tensor, src: int = 0) -> None:
58
+ dist.broadcast(input_, src=src, group=self.device_group)
vllm/distributed/parallel_state.py
+6
-4
@@ -240,6 +240,8 @@ class GroupCoordinator:
240
241
if current_platform.is_cuda_alike():
242
self.device = torch.device(f"cuda:{local_rank}")
243
+ elif current_platform.is_xpu():
244
+ self.device = torch.device(f"xpu:{local_rank}")
245
elif current_platform.is_out_of_tree():
246
self.device = torch.device(
247
f"{current_platform.device_name}:{local_rank}")
@@ -1317,13 +1319,13 @@ def in_the_same_node_as(pg: Union[ProcessGroup, StatelessProcessGroup],
1319
1320
def is_global_first_rank() -> bool:
1321
"""
1320
- Check if the current process is the first rank globally across all
1322
+ Check if the current process is the first rank globally across all
1323
parallelism strategies (PP, TP, DP, EP, etc.).
1322
-
1324
+
1325
Unlike group-specific checks like `get_tensor_model_parallel_rank() == 0`
1326
or `get_pp_group().is_first_rank`, this function checks the global rank
1327
across all parallelism dimensions.
1326
-
1328
+
1329
Returns:
1330
bool: True if this is the global first rank (rank 0), False otherwise.
1331
Returns True if distributed is not initialized (single process).
@@ -1352,7 +1354,7 @@ def _node_count(pg: Union[ProcessGroup, StatelessProcessGroup]) -> int:
1354
1355
Args:
1356
pg: The process group to analyze
1355
-
1357
+
1358
Returns:
1359
int: The total number of nodes
1360
"""
vllm/platforms/xpu.py
+5
-5
@@ -91,6 +91,7 @@ class XPUPlatform(Platform):
91
92
# FIXME: Temporarily forcing eager mode
93
# remove after t.compile support stabilizes.
94
+
95
if (envs.VLLM_USE_V1 and vllm_config.model_config is not None
96
and not vllm_config.model_config.enforce_eager):
97
from vllm.config import CompilationLevel
@@ -111,9 +112,6 @@ class XPUPlatform(Platform):
112
"mode.")
113
model_config.enforce_eager = True
114
114
- if vllm_config.device_config is not None:
115
- assert vllm_config.device_config.device_type == "xpu"
116
-
115
# check and update parallel config
116
parallel_config = vllm_config.parallel_config
117
parallel_config.worker_cls = "vllm.v1.worker.xpu_worker.XPUWorker"
@@ -131,8 +129,10 @@ class XPUPlatform(Platform):
129
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
130
logger.warning(
131
"Please use spawn as start method if you want to use mp.")
134
- elif parallel_config.distributed_executor_backend != "ray" and \
135
- parallel_config.distributed_executor_backend != "uni":
132
+ elif (parallel_config.distributed_executor_backend != "ray"
133
+ and parallel_config.distributed_executor_backend != "uni"
134
+ and parallel_config.distributed_executor_backend
135
+ != "external_launcher"):
136
logger.warning(
137
"%s is not supported on XPU, fallback to ray distributed"
138
" executor backend.",
vllm/v1/worker/xpu_model_runner.py
+1
-1
@@ -27,7 +27,7 @@ class XPUModelRunner(GPUModelRunner):
27
self.cascade_attn_enabled = False
28
29
def _init_device_properties(self) -> None:
30
- pass
30
+ self.num_sms = None
31
32
def _sync_device(self) -> None:
33
torch.xpu.synchronize()