Skip to content

Fixes NCCLComm::abort() to use correct deregister API for window-registered handles - #181626

Closed
syed-ahmed wants to merge 1 commit into
pytorch:mainfrom
syed-ahmed:fix-window-deregister-abort-v2
Closed

Fixes NCCLComm::abort() to use correct deregister API for window-registered handles#181626
syed-ahmed wants to merge 1 commit into
pytorch:mainfrom
syed-ahmed:fix-window-deregister-abort-v2

Conversation

@syed-ahmed

@syed-ahmed syed-ahmed commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

NCCLComm::abort() unconditionally called ncclCommDeregister() on all entries in registeredSegmentHandles_. However, handles registered via ncclCommWindowRegister() (symmetric registration) require ncclCommWindowDeregister() instead. Using the wrong API causes NCCL to fail with "Deregister: Could not find handle" followed by a SIGABRT crash during ProcessGroupNCCL destruction.

The fix tracks whether each handle was window-registered by changing registeredSegmentHandles_ from map<void*, void*> to map<void*, pair<void*, bool>>, and dispatches to the correct deregister call in abort(), matching the existing logic in deregisterSegment().

Fixes: #181610

Assistant used: Claude Opus 4.7 (1M)

@pytorch-bot

pytorch-bot Bot commented Apr 27, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/181626

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit 2dc9e57 with merge base fc69434 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the release notes: distributed (c10d) release notes category label Apr 27, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Apr 27, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: syed-ahmed / name: Syed Tousif Ahmed (2dc9e57)

@syed-ahmed
syed-ahmed force-pushed the fix-window-deregister-abort-v2 branch from 08625fc to 7fa73cf Compare April 27, 2026 18:52
@syed-ahmed
syed-ahmed requested a review from kwen2501 April 27, 2026 19:08

@kwen2501 kwen2501 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change looks better than making the wrong dereg call.

One thing I am unsure is whether we can guarantee successful wind dereg when we are about to abort a communicator (most likely the communicator is already corrupted).

for (auto& it : registeredSegmentHandles_) {
void* handle = it.second;
void* handle = it.second.first;
bool window = it.second.second;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use is_window so that it is less ambiguous?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Addressed.

void* handle = it.second.first;
bool window = it.second.second;
#ifdef NCCL_HAS_COMM_WINDOW_REGISTER
if (window) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use if (window) as outer condition and #ifdef NCCL_HAS_COMM_WINDOW_REGISTER as inner condition, so that we can avoid duplicated code of the non-window call.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also addressed.

@syed-ahmed
syed-ahmed force-pushed the fix-window-deregister-abort-v2 branch from 7fa73cf to 284031d Compare April 27, 2026 19:49
@syed-ahmed

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 27, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 8 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

std::unordered_map<void*, void*> registeredSegmentHandles_;
// Stores handlers for tensors registered by NCCL.
// Maps ptr -> (handle, is_window_registered).
std::unordered_map<void*, std::pair<void*, bool>> registeredSegmentHandles_;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want update to ska_flat_hashmap at some point. Seems like this could be perf sensitive.

@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -r

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

…ered handles

NCCLComm::abort() unconditionally called ncclCommDeregister() on all
entries in registeredSegmentHandles_. However, handles registered via
ncclCommWindowRegister() (symmetric registration) require
ncclCommWindowDeregister() instead. Using the wrong API causes NCCL to
fail with "Deregister: Could not find handle" followed by a SIGABRT
crash during ProcessGroupNCCL destruction.

The fix tracks whether each handle was window-registered by changing
registeredSegmentHandles_ from map<void*, void*> to
map<void*, pair<void*, bool>>, and dispatches to the correct deregister
call in abort(), matching the existing logic in deregisterSegment().

Fixes: pytorch#181610
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased fix-window-deregister-abort-v2 onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout fix-window-deregister-abort-v2 && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the fix-window-deregister-abort-v2 branch from 284031d to 2dc9e57 Compare April 28, 2026 11:34
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Commit 284031d was HEAD when comment 4334824401 was posted but now the latest commit on the PR is 2dc9e57. Please re-issue the merge command to merge the latest commit.

Details for Dev Infra team Raised by workflow job

@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@syed-ahmed
syed-ahmed deleted the fix-window-deregister-abort-v2 branch April 28, 2026 15:28
@syed-ahmed

Copy link
Copy Markdown
Collaborator Author

Thanks @Skylion007 for merging!

aperson30 pushed a commit to aperson30/pytorch that referenced this pull request Jun 20, 2026
…stered handles (pytorch#181626)

`NCCLComm::abort()` unconditionally called `ncclCommDeregister()` on all entries in `registeredSegmentHandles_`. However, handles registered via `ncclCommWindowRegister()` (symmetric registration) require `ncclCommWindowDeregister()` instead. Using the wrong API causes NCCL to fail with "Deregister: Could not find handle" followed by a SIGABRT crash during ProcessGroupNCCL destruction.

The fix tracks whether each handle was window-registered by changing `registeredSegmentHandles_` from `map<void*, void*>` to `map<void*, pair<void*, bool>>`, and dispatches to the correct deregister call in `abort()`, matching the existing logic in `deregisterSegment()`.

Fixes: pytorch#181610

Assistant used: Claude Opus 4.7 (1M)
Pull Request resolved: pytorch#181626
Approved by: https://github.com/kwen2501, https://github.com/Skylion007
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…stered handles (pytorch#181626)

`NCCLComm::abort()` unconditionally called `ncclCommDeregister()` on all entries in `registeredSegmentHandles_`. However, handles registered via `ncclCommWindowRegister()` (symmetric registration) require `ncclCommWindowDeregister()` instead. Using the wrong API causes NCCL to fail with "Deregister: Could not find handle" followed by a SIGABRT crash during ProcessGroupNCCL destruction.

The fix tracks whether each handle was window-registered by changing `registeredSegmentHandles_` from `map<void*, void*>` to `map<void*, pair<void*, bool>>`, and dispatches to the correct deregister call in `abort()`, matching the existing logic in `deregisterSegment()`.

Fixes: pytorch#181610

Assistant used: Claude Opus 4.7 (1M)
Pull Request resolved: pytorch#181626
Approved by: https://github.com/kwen2501, https://github.com/Skylion007
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…stered handles (pytorch#181626)

`NCCLComm::abort()` unconditionally called `ncclCommDeregister()` on all entries in `registeredSegmentHandles_`. However, handles registered via `ncclCommWindowRegister()` (symmetric registration) require `ncclCommWindowDeregister()` instead. Using the wrong API causes NCCL to fail with "Deregister: Could not find handle" followed by a SIGABRT crash during ProcessGroupNCCL destruction.

The fix tracks whether each handle was window-registered by changing `registeredSegmentHandles_` from `map<void*, void*>` to `map<void*, pair<void*, bool>>`, and dispatches to the correct deregister call in `abort()`, matching the existing logic in `deregisterSegment()`.

Fixes: pytorch#181610

Assistant used: Claude Opus 4.7 (1M)
Pull Request resolved: pytorch#181626
Approved by: https://github.com/kwen2501, https://github.com/Skylion007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: distributed (c10d) release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NCCLComm::abort() crashes when deregistering window-registered (symmetric) memory segments

5 participants