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] Use spawn with XPU multiprocessing (#20649)
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Dmitry Rogozhkin committed
Jul 9, 2025 at 00:34 UTC
e760fcef2265a62a6a9cfbafdb207e7c3d5c3b36
3 files changed
+15
-5
tests/utils.py
+4
-3
@@ -818,14 +818,15 @@ def create_new_process_for_each_test(
818
819
Args:
820
method: The process creation method. Can be either "spawn" or "fork".
821
- If not specified,
822
- it defaults to "spawn" on ROCm platforms and "fork" otherwise.
821
+ If not specified, it defaults to "spawn" on ROCm and XPU
822
+ platforms and "fork" otherwise.
823
824
Returns:
825
A decorator to run test functions in separate processes.
826
"""
827
if method is None:
828
- method = "spawn" if current_platform.is_rocm() else "fork"
828
+ use_spawn = current_platform.is_rocm() or current_platform.is_xpu()
829
+ method = "spawn" if use_spawn else "fork"
830
831
assert method in ["spawn",
832
"fork"], "Method must be either 'spawn' or 'fork'"
tests/v1/e2e/test_cascade_attention.py
+2
-2
@@ -5,10 +5,10 @@ import pytest
5
6
from vllm import LLM, SamplingParams
7
8
-from ...utils import fork_new_process_for_each_test
8
+from ...utils import create_new_process_for_each_test
9
10
11
-@fork_new_process_for_each_test
11
+@create_new_process_for_each_test()
12
@pytest.mark.parametrize("attn_backend",
13
["FLASH_ATTN_VLLM_V1", "FLASHINFER_VLLM_V1"])
14
def test_cascade_attention(example_system_message, monkeypatch, attn_backend):
vllm/utils/__init__.py
+9
@@ -1535,6 +1535,13 @@ def cuda_is_initialized() -> bool:
1535
return torch.cuda.is_initialized()
1536
1537
1538
+def xpu_is_initialized() -> bool:
1539
+ """Check if XPU is initialized."""
1540
+ if not torch.xpu._is_compiled():
1541
+ return False
1542
+ return torch.xpu.is_initialized()
1543
+
1544
+
1545
def cuda_get_device_properties(device,
1546
names: Sequence[str],
1547
init_cuda=False) -> tuple[Any, ...]:
@@ -2848,6 +2855,8 @@ def _maybe_force_spawn():
2855
reason = None
2856
if cuda_is_initialized():
2857
reason = "CUDA is initialized"
2858
+ elif xpu_is_initialized():
2859
+ reason = "XPU is initialized"
2860
elif is_in_ray_actor():
2861
# even if we choose to spawn, we need to pass the ray address
2862
# to the subprocess so that it knows how to connect to the ray cluster.