Repository navigation
[llm] Add get_bundle_indices_sorted_by_node utility - #61715
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the get_bundle_indices_sorted_by_node utility in ray.util.placement_group. The function reorders bundle indices from a placement group to group them by node, prioritizing the driver's node. This is intended to help with locality-aware scheduling in distributed applications. The changes include the function implementation and corresponding unit and integration tests. I have reviewed the code and have no comments.
|
Why do we need a separate public API for this? Looks like the public APIs already expose the necessary functionality -- the implementation of |
|
Chatted offline -- will move these utilities to serve llm which is where they are needed. For external libraries, they will handle such sorting on their own. And will improve placement group documentation to explicitly call out that bundles aren't necessarily sorted by physical ranks. |
Signed-off-by: Jeffrey Wang <[email protected]>
c655b0e to
1f34580
Compare
get_bundle_indices_sorted_by_node public utilityget_bundle_indices_sorted_by_node utility
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Signed-off-by: Jeffrey Wang <[email protected]>
78e4693 to
d74c168
Compare
Signed-off-by: Jeffrey Wang <[email protected]>
Signed-off-by: Jeffrey Wang <[email protected]>

Description
When a placement group is provisioned, adjacent bundle indices don't necessarily map to the same physical node. If users overlook this and don't sort the bundles on the application end, they may end up placing a single TP group across nodes.
We add
get_bundle_indices_sorted_by_node()utility toray/llm/_internal/serve/utils/pg_utils.pythat returns bundle indices reordered so that same-node bundles are adjacent, with the driver node's bundles first. Nodes other than the driver node are sorted by node ID.Also clarified such behavior under https://docs.ray.io/en/latest/ray-core/scheduling/placement-group.html (the new note section):

Why not sort by GPU ID within each node?
The placement group table (
bundles_to_node_id) only exposes which node each bundle is assigned to. It does not expose which physical GPU (CUDA_VISIBLE_DEVICESindex) a bundle maps to. GPU IDs are only available from inside the task/actor running on that bundle, viaray.get_gpu_ids(). They are not queryable from the placement group metadata.To enable GPU-aware ordering, we would need to either:
bundles_to_gpu_idin the placement group table (requires changes to the GCS placement group proto and_gen_placement_group_infoinray/_private/state.py). This approach would require the GCS scheduler to also resolve instance-level GPU assignments at PG creation time (now happens at task/actor scheduling time).ray.get_gpu_ids()and collect the results. This will add latency to the API.Approach 1 involves intricate changes in GCS scheduler, while approach 2 seems like a hack to me and could be done on the application side if necessary.
Related issues
N/A