Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aDAG] Fix ranks ordering for custom NCCL group #47594

Merged
merged 2 commits into from
Sep 11, 2024
Merged
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
11 changes: 6 additions & 5 deletions python/ray/experimental/channel/torch_tensor_nccl_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,9 @@ def _get_ranks(
actors: List[ray.actor.ActorHandle], custom_nccl_group: Optional[GPUCommunicator]
) -> List[int]:
"""
Get sorted ranks for the NCCL group to use. If custom_nccl_group is specified,
return all ranks from it, otherwise, return list(range(len(actors))).
Get ranks for the NCCL group to use. If custom_nccl_group is specified,
return the ranks of the actors in the custom NCCL group, in the same
order of the actors; otherwise, return list(range(len(actors))).

Args:
actors: A list of actors that participate in the NCCL group.
Expand All @@ -493,18 +494,18 @@ def _get_ranks(
"The world size of the custom NCCL group does not match the number "
"of actors."
)
ranks = set()
ranks = []
for actor in actors:
rank = custom_nccl_group.get_rank(actor)
assert rank not in ranks, "Duplicate rank in custom NCCL group"
ranks.add(rank)
ranks.append(rank)
assert custom_nccl_group.get_world_size() == len(actors), (
"The world size of the custom NCCL group "
f"({custom_nccl_group.get_world_size()}) "
"does not match the number of actors "
f"({len(actors)})."
)
return sorted(ranks)
return ranks


def _init_nccl_group(
Expand Down