Skip to content

[docs] Document experimental one-sided window API (_new_window) - #201405

Closed
d4l3k wants to merge 26 commits into
gh/d4l3k/292/basefrom
gh/d4l3k/292/head
Closed

d4l3k wants to merge 26 commits into
gh/d4l3k/292/basefrom
gh/d4l3k/292/head

Conversation

@d4l3k

@d4l3k d4l3k commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Stack from ghstack (oldest at bottom):

dist._new_window / Window had no user docs, and the Window pybind class had no docstrings. Adds docstrings to the Window bindings and its option/attribute types in init.cpp, re-exports PutOptions, SignalOptions, WaitSignalOptions, WindowAttr and WindowAccessType from distributed_c10d (not in __all__, matching Window), and an experimental "One-sided communication" section to distributed.md: backend/NCCL requirements, the memory-pool requirement, a ring put/wait_signal example, and autodoc entries. Adds nccl-lazy to the window tests, plus a test for the register_mem_pool(symm=True) window flow and teardown the docs recommend.

Review points intentionally not addressed: nccl2 isn't listed separately since nccl resolves to it; only nccl-legacy is called out. The out-of-tree, deprecated torchcomms backend and the TORCH_DISTRIBUTED_DEBUG=DETAIL wrapper aren't covered, to keep the section to the common cases. _new_window/Window stay private and outside __all__ while experimental; this documents them without committing to a public API. test_symmetric_mem_pool_teardown has no try/finally: an earlier review asked to drop it, and cleanup after a failure would itself run collectives that can hang when ranks diverge.

Test plan:
Built torch from source and checked the docstrings. Ran the docs ring example on 2 GB200s with nccl and nccl-lazy (nightly + NCCL 2.32.3), and test/distributed/test_c10d_window.py passes for nccl2 and nccl-lazy. sphinx-build -M html source build in docs/; the section renders, cross-references resolve, and no new warnings vs main.

This PR was authored with the assistance of an AI coding agent.

[ghstack-poisoned]
@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Oct 19, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

🟡 AUTOMATED REVIEW - Changes requested:

The PR documents the experimental one-sided window API (`_new_window` /
`Window`) in distributed.md and the pybind docstrings, re-exports the window
option types, and adds `nccl-lazy` plus two new tests to test_c10d_window.py.
Most of it matches the nccl2 code, but one docstring overstates when
registration is collective, one new test can't tell apart the two behaviors it
is meant to separate, and two assertions tie the backend-agnostic test class to
NCCL. Recommendation: Request Changes.

Findings (3):

[major] torch/csrc/distributed/c10d/init.cpp:4204
The legacy `ProcessGroupNCCL.register_mem_pool` docstring says registration is
always collective: "This is collective, as are later allocations from the pool",
with no condition. That only holds for `symm=True`. `NCCLComm::registerSegment`
calls the collective `ncclCommWindowRegister(..., NCCL_WIN_COLL_SYMMETRIC)` only
when `window` is true (NCCLUtils.cpp:484-494). Otherwise it calls
`ncclCommRegister`, which each rank does on its own (NCCLUtils.cpp:496-497). The
allocator hook passes `window=symm`, so later allocations are also collective
only with `symm=True`. Users of the default `symm=Fals

[major] test/distributed/test_c10d_window.py:164
`test_signal_shared_across_windows` passes whether signal counts are per process
group or per window. `buf_a` (`world_size` floats) and `buf_b` (1 float) are
small allocations from the pool that `_probe_window_support` has already given a
small segment, so both end up in that same segment.
`WindowNCCL::tensor_register` takes the window handle from the segment
(`pg_->lookupSegmentWindow(...)`, nccl2/WindowNCCL.cpp:102), so `win_a` and
`win_b` get the same `ncclWindow_t`. The test would pass even if signal counts
were tracked per window, so it doesn't check the property its comment and the `w

[major] test/distributed/test_c10d_window.py:271
NCCL-only assertions sit in the backend-agnostic `AbstractWindowTest`. The file
header says new backends are covered by adding them to `WINDOW_BACKENDS`.
`assertEqual(attr.access_type, WindowAccessType.SEPARATE)` replaces the old
`assertIsInstance` and pins the hardcoded `SEPARATE` in WindowNCCL.cpp:328.
`test_signal_shared_across_windows` (line 156) assumes counts are shared per
process group, which the PR's own docstring calls NCCL-specific ("With NCCL,
counts are shared"). A backend with `UNIFIED` access, or with per-window signal
counts, would fail or hang on these tests even though it fo

Reviewed commit: fca0b72

Review run

🔗 Helpful Links

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

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

✅ No Failures

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

🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

  • Triviality
    • Not only docs: distributed_c10d.py adds five new re-exports (PutOptions, SignalOptions, WaitSignalOptions, WindowAttr, WindowAccessType)
    • init.cpp changes the pybind opts defaults from py::arg to py::arg_v, which changes the signature shown to users
    • test_c10d_window.py adds nccl-lazy to WINDOW_BACKENDS and changes how test classes are named, which adds new CI test classes
  • Socialization
    • The new distributed.md section is the first user doc for _new_window/Window, so it advertises an experimental API to users
    • It states NCCL semantics (segment registration, teardown order, signal counting) that a distributed maintainer should check against WindowNCCL.cpp
  • Review state
    • The Dr. CI comment in the PR metadata says a maintainer requested changes, so the feedback needs a human to resolve it

reason: not_trivial
Reviewed commit: 816e1ac (NOT the current head fca0b72)

Inference job

🐛 Report a wrong verdict

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

@d4l3k
d4l3k requested a review from kapilsh as a code owner October 19, 2026 07:00
@d4l3k
d4l3k marked this pull request as draft October 19, 2026 07:01
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 19, 2026
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

@pytorch-bot pytorch-bot Bot added the ciflow/torchtitan Run TorchTitan integration tests label Oct 19, 2026
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

… clean; forward nccl-lazy mem pool

[ghstack-poisoned]
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

@github-actions
github-actions Bot dismissed stale reviews from themself October 19, 2026 18:55

Withdrawn: the automated review of 1a62483 found nothing blocking.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

…ing=False; tests for SEPARATE and shared signals

[ghstack-poisoned]
github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review of fca0b72: changes requested before human review.

The PR documents the experimental one-sided window API (_new_window / Window) in distributed.md and the pybind docstrings, re-exports the window option types, and adds nccl-lazy plus two new tests to test_c10d_window.py. Most of it matches the nccl2 code, but one docstring overstates when registration is collective, one new test can't tell apart the two behaviors it is meant to separate, and two assertions tie the backend-agnostic test class to NCCL. Recommendation: Request Changes.

🔴 3 blocking findings are attached to the code below.

Please address the findings and push; a new commit normally gets a fresh automated review.

This review is AI-generated and advisory. Each new automated review replaces the previous one.

py::arg("pool"),
py::arg("symm") = false)
py::arg("symm") = false,
R"(Register ``pool``'s segments with this communicator. With ``symm=True``, unregistered segments are registered as NCCL symmetric windows instead; already registered segments are left as is. This is collective, as are later allocations from the pool. ``symm`` is ignored when PyTorch is built against NCCL older than 2.27.)")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 The legacy ProcessGroupNCCL.register_mem_pool docstring says registration is always collective: "This is collective, as are later allocations from the pool", with no condition. That only holds for symm=True. NCCLComm::registerSegment calls the collective ncclCommWindowRegister(..., NCCL_WIN_COLL_SYMMETRIC) only when window is true (NCCLUtils.cpp:484-494). Otherwise it calls ncclCommRegister, which each rank does on its own (NCCLUtils.cpp:496-497). The allocator hook passes window=symm, so later allocations are also collective only with symm=True. Users of the default `symm=Fals

self._probe_window_support(pool)
with torch.cuda.use_mem_pool(pool):
buf_a = torch.zeros(self.world_size, device=self.device)
buf_b = torch.zeros(1, device=self.device)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 test_signal_shared_across_windows passes whether signal counts are per process group or per window. buf_a (world_size floats) and buf_b (1 float) are small allocations from the pool that _probe_window_support has already given a small segment, so both end up in that same segment. WindowNCCL::tensor_register takes the window handle from the segment (pg_->lookupSegmentWindow(...), nccl2/WindowNCCL.cpp:102), so win_a and win_b get the same ncclWindow_t. The test would pass even if signal counts were tracked per window, so it doesn't check the property its comment and the `w


attr = win.get_attr((self.rank + 1) % self.world_size)
self.assertIsInstance(attr.access_type, WindowAccessType)
self.assertEqual(attr.access_type, WindowAccessType.SEPARATE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 NCCL-only assertions sit in the backend-agnostic AbstractWindowTest. The file header says new backends are covered by adding them to WINDOW_BACKENDS. assertEqual(attr.access_type, WindowAccessType.SEPARATE) replaces the old assertIsInstance and pins the hardcoded SEPARATE in WindowNCCL.cpp:328. test_signal_shared_across_windows (line 156) assumes counts are shared per process group, which the PR's own docstring calls NCCL-specific ("With NCCL, counts are shared"). A backend with UNIFIED access, or with per-window signal counts, would fail or hang on these tests even though it fo

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #201436

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #201436

1 similar comment
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #201436

pytorchmergebot pushed a commit that referenced this pull request Oct 20, 2026
…ctory (#201413)

`distributed/elastic/run.md` was the only subdirectory page using a bare `:toctree: generated`, so a docs build wrote stubs to `docs/source/distributed/elastic/generated/`, which isn't ignored, isn't removed by `make clean`, and isn't recognized by the `generated/` checks in conf.py (edit button, last-updated date). Point it at `../../generated` like the other subdirectory pages, add redirects from the old URLs, exclude `distributed/elastic/generated/` from the build so stale local stubs don't clash with the redirects, and drop the stale `docs/source/compile/generated/` `.gitignore` entries (`docs/source/compile/` no longer exists).

Test plan:
Built docs locally; the torchrun stubs land in `docs/source/generated/`, `git status` is clean, and the redirect pages for the old URLs are generated.

This PR was authored with the assistance of an AI coding agent.
Pull Request resolved: #201413
Approved by: https://github.com/kapilsh
ghstack dependencies: #201403, #201404, #201432, #201405
pytorchmergebot pushed a commit that referenced this pull request Oct 20, 2026
ProcessGroup pre/post/abort hooks, their argument types, and the built-in FlightRecorderHook/NanCheckHook/HealthCheckHook had one-line or no docstrings and no docs page. This adds docstrings to the pybind bindings (semantics: issue-time vs completion, op_id pairing, hook_id ordering/replacement, exception behavior, abort hook idempotence, auto-attach env vars), re-exports HookOpName/PreHookArgs/PostHookArgs from torch.distributed.distributed_c10d like the window types, and adds a "Hooks" section to distributed.md.

Review points intentionally not addressed: exhaustive per-op hook coverage and HookOpName mapping exceptions (monitored_barrier, coalesced Work, sparse allreduce, gather_into_tensor, barrier tensor lists), split_group not attaching NanCheckHook, and TORCH_NCCL_NAN_CHECK; docs are kept to common cases.

Test plan:

```
pip install -e . -v --no-build-isolation
python test/test_public_bindings.py
cd docs && sphinx-build -M html source build -j 24 -T --keep-going -D katex_prerender=0
```

Also ran the docs example on a single-rank gloo group and checked the rendered docstrings.

This PR was authored with an AI assistant (Claude).
Pull Request resolved: #201436
Approved by: https://github.com/kapilsh
ghstack dependencies: #201403, #201404, #201432, #201405, #201413
pytorchmergebot pushed a commit that referenced this pull request Oct 22, 2026
…ed comments, link nearby threads (#201479)

minimizing obsolete automatic reviews did not hide their review comments, meaning the identical comments from different review iterations could pile up on the same line.
this PR deletes obsolete comments (that don't have maintainer replies), and also edits the obsolete review to wrap them in `<details>` so they render better on mobile (which doesn't currently support minimization).

---

✴️ iz2: On PRs with many re-reviews (e.g. #201405: 24 automated reviews, 67 open inline threads), minimizing a replaced review hides only its body. Its inline comments stay listed on the Files tab and in GitHub Mobile, because `GITHUB_TOKEN` can't resolve threads here.

When a newer automated review replaces an earlier one, this change:
- folds the earlier review's body into a collapsed `<details>` section (the marker stays the first line; no cross-links)
- deletes its inline comments that nobody replied to or reacted to. A comment is deleted only if its review thread, read by GraphQL cursor, holds that one comment. Answered comments and their replies stay.
- posts a new blocking finding within 3 lines of an earlier comment someone replied to in the review body, with a link to that thread, instead of opening another inline thread. The match is by position only, so the link text says only that the thread is nearby.

Reviews hidden by earlier runs get the same fold and delete from a backfill. The backfill runs after any clean-verdict dismissal and is capped at 50 writes, 1 second apart, and 90 seconds per run, so a PR like #201405 is cleaned over a few runs. A change request that may still stand is never folded or emptied.

Known limits:
- A reply that isn't visible yet, because it was posted after the threads were read or is still pending in someone's unsubmitted review, does not protect its root comment. The API shows neither, so a maintainer who is mid-reply when a new push is reviewed can lose the comment they were answering.
- Throttled deletes on the takedown path, before a clean verdict's dismissal, are not time-bounded.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes all 472 tests, including new cases for overlapping runs, reply, reaction and thread-count protection, retraction, and the backfill's budget, pacing, clock and change-request gate.
Pull Request resolved: #201479
Approved by: https://github.com/huydhn, https://github.com/albanD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/torchtitan Run TorchTitan integration tests in progress PR is being worked on by the author, until the automated review accepts it Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants