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, 00:30 UTC
[Bugfix] Improve GPU validation logging in Ray fallback scenarios (#25775)
Signed-off-by: Sairam Pillai <sairam.pillai61@gmail.com>
Sairam Pillai committed
Oct 30, 2025 at 17:27 UTC
74374386e27f9e7a056a37960d5e996093e45ac4
2 files changed
+49
-15
vllm/config/parallel.py
+5
-9
@@ -521,15 +521,11 @@ class ParallelConfig:
521
current_platform.is_cuda()
522
and cuda_device_count_stateless() < self.world_size
523
):
524
- if not ray_found:
525
- raise ValueError(
526
- "Unable to load Ray: "
527
- f"{ray_utils.ray_import_err}. Ray is "
528
- "required for multi-node inference, "
529
- "please install Ray with `pip install "
530
- "ray`."
531
- )
532
- backend = "ray"
524
+ gpu_count = cuda_device_count_stateless()
525
+ raise ValueError(
526
+ f"Tensor parallel size ({self.world_size}) cannot be "
527
+ f"larger than the number of available GPUs ({gpu_count})."
528
+ )
529
elif self.data_parallel_backend == "ray":
530
logger.info(
531
"Using ray distributed inference because "
vllm/v1/executor/ray_utils.py
+44
-6
@@ -255,12 +255,33 @@ def _wait_until_pg_ready(current_placement_group: "PlacementGroup"):
255
try:
256
ray.get(pg_ready_ref, timeout=0)
257
except ray.exceptions.GetTimeoutError:
258
- raise ValueError(
259
- "Cannot provide a placement group of "
260
- f"{placement_group_specs=} within {PG_WAIT_TIMEOUT} seconds. See "
261
- "`ray status` and `ray list nodes` to make sure the cluster has "
262
- "enough resources."
263
- ) from None
258
+ # Provide more helpful error message when GPU count is exceeded
259
+ total_gpu_required = sum(spec.get("GPU", 0) for spec in placement_group_specs)
260
+ # If more than one GPU is required for the placement group, provide a
261
+ # more specific error message.
262
+ # We use >1 here because multi-GPU (tensor parallel) jobs are more
263
+ # likely to fail due to insufficient cluster resources, and users may
264
+ # need to adjust tensor_parallel_size to fit available GPUs.
265
+ if total_gpu_required > 1:
266
+ raise ValueError(
267
+ f"Cannot provide a placement group requiring "
268
+ f"{total_gpu_required} GPUs "
269
+ f"(placement_group_specs={placement_group_specs}) within "
270
+ f"{PG_WAIT_TIMEOUT} seconds.\n"
271
+ f"Tensor parallel size may exceed available GPUs in your "
272
+ f"cluster. Check resources with `ray status` and "
273
+ f"`ray list nodes`.\n"
274
+ f"If running on K8s with limited GPUs, consider reducing "
275
+ f"--tensor-parallel-size to match available GPU resources."
276
+ ) from None
277
+ else:
278
+ raise ValueError(
279
+ "Cannot provide a placement group of "
280
+ f"{placement_group_specs=} within "
281
+ f"{PG_WAIT_TIMEOUT} seconds. See "
282
+ "`ray status` and `ray list nodes` to make sure the cluster "
283
+ "has enough resources."
284
+ ) from None
285
286
287
def _wait_until_pg_removed(current_placement_group: "PlacementGroup"):
@@ -299,6 +320,23 @@ def initialize_ray_cluster(
320
assert_ray_available()
321
from vllm.platforms import current_platform
322
323
+ # Prevalidate GPU requirements before Ray processing
324
+ if current_platform.is_cuda() and parallel_config.world_size > 1:
325
+ from vllm.utils import cuda_device_count_stateless
326
+
327
+ available_gpus = cuda_device_count_stateless()
328
+ if parallel_config.world_size > available_gpus:
329
+ logger.warning(
330
+ "Tensor parallel size (%d) exceeds available GPUs (%d). "
331
+ "This may result in Ray placement group allocation failures. "
332
+ "Consider reducing tensor_parallel_size to %d or less, "
333
+ "or ensure your Ray cluster has %d GPUs available.",
334
+ parallel_config.world_size,
335
+ available_gpus,
336
+ available_gpus,
337
+ parallel_config.world_size,
338
+ )
339
+
340
if ray.is_initialized():
341
logger.info("Ray is already initialized. Skipping Ray initialization.")
342
elif current_platform.is_rocm() or current_platform.is_xpu():