Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/sglang/srt/ray/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from sglang.srt.ray.engine import RayEngine
from sglang.srt.ray.engine import RayEngine, get_scheduler_actor_name

__all__ = ["RayEngine"]
__all__ = ["RayEngine", "get_scheduler_actor_name"]
34 changes: 30 additions & 4 deletions python/sglang/srt/ray/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@ def _validate_custom_placement_group(pg: PlacementGroup, world_size: int) -> Non
)


def get_scheduler_actor_name(
*,
rank0_node_ip: str,
dp_rank: int,
pp_rank: int,
tp_rank: int,
port: int,
bundle_idx: int,
) -> str:
"""Return the Ray actor name for a SchedulerActor.

The name is fully determined by the engine's node, http port, ranks and
bundle index, so a caller that launched the engine can rebuild it and
``ray.get_actor()`` the schedulers instead of scanning
``ray.util.list_named_actors()`` for substring matches.
"""
return (
f"sglang_scheduler_node{rank0_node_ip}"
f"_dp{dp_rank}_pp{pp_rank}_tp{tp_rank}"
f"_port{port}_bundle{bundle_idx}"
)


def _create_scheduler_actor(
pg: PlacementGroup,
bundle_idx: int,
Expand Down Expand Up @@ -203,10 +226,13 @@ def _create_scheduler_actor(
return SchedulerActor.options(
num_cpus=0,
num_gpus=1,
name=(
f"sglang_scheduler_node{rank0_node_ip}"
f"_dp{dp_rank}_pp{pp_rank}_tp{tp_rank}"
f"_pg{pg.id.hex()[:8]}_bundle{bundle_idx}"
name=get_scheduler_actor_name(
rank0_node_ip=rank0_node_ip,
dp_rank=dp_rank,
pp_rank=pp_rank,
tp_rank=tp_rank,
port=server_args.port,
bundle_idx=bundle_idx,
),
scheduling_strategy=PlacementGroupSchedulingStrategy(
placement_group=pg,
Expand Down
Loading