Repository navigation
[c10d][nccl2] Record a split child's world ranks and stop it borrowing commName - #192115
Closed
tushar00jain wants to merge 5 commits into
Closed
tushar00jain wants to merge 5 commits into
tushar00jain wants to merge 5 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/192115
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 77aef85 with merge base dac77b5 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 4, 2026
Closed
Closed
Closed
tushar00jain
added a commit
that referenced
this pull request
Aug 4, 2026
…g commName
Summary:
nccl2's split() copies the parent's timeout, config, group name, group
description and abort policy into the child's Options, but never records the
child's membership in world-rank terms. Stock ProcessGroupNCCL::split() fills
global_ranks_in_group; nccl2 left it empty.
nccl2 never reads that map itself, and get_process_group_ranks() does not go
through it, so this is observability fidelity rather than a correctness bug.
The one consumer is the opt-in FlightRecorderHook, which falls back to identity
ranks when the map is absent -- so a child group's recorded membership claimed
world ranks it does not contain. A second-level split was worse: the ranks it
was handed are indices into the parent, so without the parent's map there is
nothing to resolve them against.
The child now maps each requested rank through *this* group's own
global_ranks_in_group rather than the Options it was passed. That distinction
matters after the per-backend Options change earlier in this stack ("Give each
backend its own Options when splitting or merging a process group"): the
Options reaching split() is a clone owned by the caller, while the live map
belongs to the group. An empty map means "spans the world in rank order", and
a merged group inherits its parent's shorter map, so a map shorter than
getSize() is treated the same way instead of being indexed out of bounds --
the same read that the NCCL split fix earlier in this stack closed.
Second, smaller change in the same function. config.commName was assigned
name.c_str() and then stored into the child's Options, leaving the child
holding a pointer that outlives the string it borrows. This is latent, not
live: every consumer of a stored config assigns commName from a live string
before handing it to NCCL -- createNcclComm(), reconfigure(), and split()
itself -- and populateNcclConfigFromHints() borrows from the caller's live
hints map rather than from a stored one. Storing nullptr records what the
child actually owns instead of a pointer that happens never to be read.
Both are nccl2's own defects. Stock is unaffected: its split() already records
the rank map, and it does not stash a borrowed commName.
Test Plan:
test_split_group_child_global_ranks in test/distributed/test_c10d_nccl2.py
(requires_nccl, 2 GPUs) splits a 2-rank world into halves and asserts:
python test/distributed/test_c10d_nccl2.py \
ProcessGroupNCCL2ObservabilityTest.test_split_group_child_global_ranks -v
- the child's global_ranks_in_group is its own half's world ranks
- a second-level split maps through the parent: the grandchild reports
[self.rank], which the identity fallback would report as [0]
- config.comm_name is not stored on the child
- an all_reduce on the child still produces sum(halves), i.e. the added
bookkeeping does not disturb the communicator
Pre-fix the first assertion fails with "mismatch: 0 != 2".
Recorded suite runs with this change present:
test_c10d_nccl2.py Ran 24 tests OK
test_c10d_nccl.py Ran 285 tests OK (skipped=15)
Authored with the assistance of an AI coding agent.
ghstack-source-id: 9d2e831
Pull-Request: #192115
d4l3k
approved these changes
Aug 5, 2026
d4l3k
left a comment
Member
There was a problem hiding this comment.
Re-approving due to switching to ghstack from sl
Contributor
Author
|
@pytorchbot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
ankitbhrdwj
pushed a commit
to ankitbhrdwj/pytorch
that referenced
this pull request
Aug 12, 2026
…g commName (pytorch#192115) Summary: nccl2's split() copies the parent's timeout, config, group name, group description and abort policy into the child's Options, but never records the child's membership in world-rank terms. Stock ProcessGroupNCCL::split() fills global_ranks_in_group; nccl2 left it empty. nccl2 never reads that map itself, and get_process_group_ranks() does not go through it, so this is observability fidelity rather than a correctness bug. The one consumer is the opt-in FlightRecorderHook, which falls back to identity ranks when the map is absent -- so a child group's recorded membership claimed world ranks it does not contain. A second-level split was worse: the ranks it was handed are indices into the parent, so without the parent's map there is nothing to resolve them against. The child now maps each requested rank through *this* group's own global_ranks_in_group rather than the Options it was passed. That distinction matters after the per-backend Options change earlier in this stack ("Give each backend its own Options when splitting or merging a process group"): the Options reaching split() is a clone owned by the caller, while the live map belongs to the group. An empty map means "spans the world in rank order", and a merged group inherits its parent's shorter map, so a map shorter than getSize() is treated the same way instead of being indexed out of bounds -- the same read that the NCCL split fix earlier in this stack closed. Second, smaller change in the same function. config.commName was assigned name.c_str() and then stored into the child's Options, leaving the child holding a pointer that outlives the string it borrows. This is latent, not live: every consumer of a stored config assigns commName from a live string before handing it to NCCL -- createNcclComm(), reconfigure(), and split() itself -- and populateNcclConfigFromHints() borrows from the caller's live hints map rather than from a stored one. Storing nullptr records what the child actually owns instead of a pointer that happens never to be read. Both are nccl2's own defects. Stock is unaffected: its split() already records the rank map, and it does not stash a borrowed commName. Test Plan: test_split_group_child_global_ranks in test/distributed/test_c10d_nccl2.py (requires_nccl, 2 GPUs) splits a 2-rank world into halves and asserts: python test/distributed/test_c10d_nccl2.py \ ProcessGroupNCCL2ObservabilityTest.test_split_group_child_global_ranks -v - the child's global_ranks_in_group is its own half's world ranks - a second-level split maps through the parent: the grandchild reports [self.rank], which the identity fallback would report as [0] - config.comm_name is not stored on the child - an all_reduce on the child still produces sum(halves), i.e. the added bookkeeping does not disturb the communicator Pre-fix the first assertion fails with "mismatch: 0 != 2". Recorded suite runs with this change present: test_c10d_nccl2.py Ran 24 tests OK test_c10d_nccl.py Ran 285 tests OK (skipped=15) Authored with the assistance of an AI coding agent. Pull Request resolved: pytorch#192115 Approved by: https://github.com/d4l3k ghstack dependencies: pytorch#192114
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Summary:
nccl2's split() copies the parent's timeout, config, group name, group
description and abort policy into the child's Options, but never records the
child's membership in world-rank terms. Stock ProcessGroupNCCL::split() fills
global_ranks_in_group; nccl2 left it empty.
nccl2 never reads that map itself, and get_process_group_ranks() does not go
through it, so this is observability fidelity rather than a correctness bug.
The one consumer is the opt-in FlightRecorderHook, which falls back to identity
ranks when the map is absent -- so a child group's recorded membership claimed
world ranks it does not contain. A second-level split was worse: the ranks it
was handed are indices into the parent, so without the parent's map there is
nothing to resolve them against.
The child now maps each requested rank through this group's own
global_ranks_in_group rather than the Options it was passed. That distinction
matters after the per-backend Options change earlier in this stack ("Give each
backend its own Options when splitting or merging a process group"): the
Options reaching split() is a clone owned by the caller, while the live map
belongs to the group. An empty map means "spans the world in rank order", and
a merged group inherits its parent's shorter map, so a map shorter than
getSize() is treated the same way instead of being indexed out of bounds --
the same read that the NCCL split fix earlier in this stack closed.
Second, smaller change in the same function. config.commName was assigned
name.c_str() and then stored into the child's Options, leaving the child
holding a pointer that outlives the string it borrows. This is latent, not
live: every consumer of a stored config assigns commName from a live string
before handing it to NCCL -- createNcclComm(), reconfigure(), and split()
itself -- and populateNcclConfigFromHints() borrows from the caller's live
hints map rather than from a stored one. Storing nullptr records what the
child actually owns instead of a pointer that happens never to be read.
Both are nccl2's own defects. Stock is unaffected: its split() already records
the rank map, and it does not stash a borrowed commName.
Test Plan:
test_split_group_child_global_ranks in test/distributed/test_c10d_nccl2.py
(requires_nccl, 2 GPUs) splits a 2-rank world into halves and asserts:
python test/distributed/test_c10d_nccl2.py
ProcessGroupNCCL2ObservabilityTest.test_split_group_child_global_ranks -v
[self.rank], which the identity fallback would report as [0]
bookkeeping does not disturb the communicator
Pre-fix the first assertion fails with "mismatch: 0 != 2".
Recorded suite runs with this change present:
test_c10d_nccl2.py Ran 24 tests OK
test_c10d_nccl.py Ran 285 tests OK (skipped=15)
Authored with the assistance of an AI coding agent.