@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / c7742d6113
Fork 0

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 14, 23:45 UTC

[Bugfix] Always set RAY_ADDRESS for Ray actor before spawn (#21540)

Signed-off-by: Rui Qiao <ruisearch42@gmail.com>

Rui Qiao committed Jul 25, 2025 at 17:08 UTC c7742d61134783b50098ab249f6815051a4c4a2a
1 file changed +10 -9
vllm/utils/__init__.py
+10 -9
@@ -2883,26 +2883,27 @@ def _maybe_force_spawn():
2883 if os.environ.get("VLLM_WORKER_MULTIPROC_METHOD") == "spawn":
2884 return
2885
2886 - reason = None
2887 - if cuda_is_initialized():
2888 - reason = "CUDA is initialized"
2889 - elif xpu_is_initialized():
2890 - reason = "XPU is initialized"
2891 - elif is_in_ray_actor():
2886 + reasons = []
2887 + if is_in_ray_actor():
2888 # even if we choose to spawn, we need to pass the ray address
2889 # to the subprocess so that it knows how to connect to the ray cluster.
2890 # env vars are inherited by subprocesses, even if we use spawn.
2891 import ray
2892 os.environ["RAY_ADDRESS"] = ray.get_runtime_context().gcs_address
2897 - reason = "In a Ray actor and can only be spawned"
2893 + reasons.append("In a Ray actor and can only be spawned")
2894 +
2895 + if cuda_is_initialized():
2896 + reasons.append("CUDA is initialized")
2897 + elif xpu_is_initialized():
2898 + reasons.append("XPU is initialized")
2899
2899 - if reason is not None:
2900 + if reasons:
2901 logger.warning(
2902 "We must use the `spawn` multiprocessing start method. "
2903 "Overriding VLLM_WORKER_MULTIPROC_METHOD to 'spawn'. "
2904 "See https://docs.vllm.ai/en/latest/usage/"
2905 "troubleshooting.html#python-multiprocessing "
2905 - "for more information. Reason: %s", reason)
2906 + "for more information. Reasons: %s", "; ".join(reasons))
2907 os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
2908
2909