[Ray] Auto-create placement group in RayEngine when none is detected (#22898)
This commit is contained in:
@@ -100,11 +100,33 @@ class RayEngine(Engine):
|
|||||||
"""
|
"""
|
||||||
pg = ray.util.get_current_placement_group()
|
pg = ray.util.get_current_placement_group()
|
||||||
if pg is None:
|
if pg is None:
|
||||||
raise RuntimeError(
|
from ray.util.placement_group import (
|
||||||
"use_ray=True requires a placement group, but none was detected. "
|
placement_group as create_placement_group,
|
||||||
"Schedule the Engine actor onto a placement group"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if server_args.enable_dp_attention:
|
||||||
|
total_gpus = server_args.tp_size * server_args.pp_size
|
||||||
|
else:
|
||||||
|
total_gpus = (
|
||||||
|
server_args.dp_size * server_args.tp_size * server_args.pp_size
|
||||||
|
)
|
||||||
|
|
||||||
|
nnodes = server_args.nnodes
|
||||||
|
gpus_per_node = total_gpus // nnodes
|
||||||
|
strategy = "STRICT_PACK" if nnodes == 1 else "SPREAD"
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
"No placement group detected. Auto-creating one with "
|
||||||
|
f"{nnodes} bundle(s), {gpus_per_node} GPU(s)/bundle, "
|
||||||
|
"placement group explicitly and schedule the Engine onto it."
|
||||||
|
)
|
||||||
|
|
||||||
|
pg = create_placement_group(
|
||||||
|
[{"CPU": 1, "GPU": gpus_per_node}] * nnodes,
|
||||||
|
strategy=strategy,
|
||||||
|
)
|
||||||
|
ray.get(pg.ready())
|
||||||
|
|
||||||
nnodes = server_args.nnodes
|
nnodes = server_args.nnodes
|
||||||
|
|
||||||
# co-located with the Engine and rank0 scheduler at the same node
|
# co-located with the Engine and rank0 scheduler at the same node
|
||||||
|
|||||||
Reference in New Issue
Block a user