[XPU] Use spawn with XPU multiprocessing (#20649)

Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
This commit is contained in:
Dmitry Rogozhkin
2025-07-09 00:34:28 -07:00
committed by GitHub
parent 6bbf1795b7
commit e760fcef22
3 changed files with 15 additions and 5 deletions
+9
View File
@@ -1535,6 +1535,13 @@ def cuda_is_initialized() -> bool:
return torch.cuda.is_initialized()
def xpu_is_initialized() -> bool:
"""Check if XPU is initialized."""
if not torch.xpu._is_compiled():
return False
return torch.xpu.is_initialized()
def cuda_get_device_properties(device,
names: Sequence[str],
init_cuda=False) -> tuple[Any, ...]:
@@ -2848,6 +2855,8 @@ def _maybe_force_spawn():
reason = None
if cuda_is_initialized():
reason = "CUDA is initialized"
elif xpu_is_initialized():
reason = "XPU is initialized"
elif is_in_ray_actor():
# even if we choose to spawn, we need to pass the ray address
# to the subprocess so that it knows how to connect to the ray cluster.