[RFC/NFM] docs: distributed programming guides — collectives, benchmarking, and API reference - #2162
Conversation
📝 WalkthroughWalkthroughThis documentation-focused change adds English and Chinese distributed-programming, API-reference, and benchmarking guides, updates operation references and getting-started pages, and expands Python API docstrings. No executable logic or public signatures change. ChangesDistributed documentation
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e2172dbf6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Nitpick comments (1)
docs/en/user/06-benchmarking-guide.md (1)
28-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFix the mirrored Markdownlint warnings.
Add appropriate language identifiers to fenced blocks and remove or prefix blank lines inside blockquotes in both language versions.
docs/en/user/06-benchmarking-guide.md#L28-L28: tag the output fence.docs/en/user/06-benchmarking-guide.md#L58-L58: tag the API-signature fence.docs/en/user/06-benchmarking-guide.md#L114-L114: tag the span-tree fence.docs/en/user/06-benchmarking-guide.md#L193-L193: tag the variance-output fence.docs/en/user/06-benchmarking-guide.md#L264-L264: tag the formula fence.docs/en/user/06-benchmarking-guide.md#L285-L285: tag the worked-example fence.docs/en/user/06-benchmarking-guide.md#L324-L324: fix the blank blockquote line.docs/en/user/06-benchmarking-guide.md#L329-L329: fix the blank blockquote line.docs/en/user/06-benchmarking-guide.md#L334-L334: fix the blank blockquote line.docs/en/user/06-benchmarking-guide.md#L363-L363: tag the span-tree fence.docs/zh-cn/user/06-benchmarking-guide.md#L27-L27: tag the output fence.docs/zh-cn/user/06-benchmarking-guide.md#L57-L57: tag the API-signature fence.docs/zh-cn/user/06-benchmarking-guide.md#L113-L113: tag the span-tree fence.docs/zh-cn/user/06-benchmarking-guide.md#L188-L188: tag the variance-output fence.docs/zh-cn/user/06-benchmarking-guide.md#L257-L257: tag the formula fence.docs/zh-cn/user/06-benchmarking-guide.md#L278-L278: tag the worked-example fence.docs/zh-cn/user/06-benchmarking-guide.md#L312-L312: fix the blank blockquote line.docs/zh-cn/user/06-benchmarking-guide.md#L316-L316: fix the blank blockquote line.docs/zh-cn/user/06-benchmarking-guide.md#L320-L320: fix the blank blockquote line.docs/zh-cn/user/06-benchmarking-guide.md#L346-L346: tag the span-tree fence.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/en/user/06-benchmarking-guide.md` at line 28, Fix the mirrored Markdownlint issues in docs/en/user/06-benchmarking-guide.md at lines 28, 58, 114, 193, 264, 285, and 363 by adding appropriate language identifiers to the output, API-signature, span-tree, variance-output, formula, worked-example, and span-tree fences; prefix the blank blockquote lines at 324, 329, and 334. Apply the same corresponding fixes in docs/zh-cn/user/06-benchmarking-guide.md at lines 27, 57, 113, 188, 257, 278, and 346 for fences, and 312, 316, and 320 for blank blockquote lines, preserving the existing bilingual content.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/en/user/02-operation_reference.md`:
- Around line 289-298: The capability matrices in
docs/en/user/02-operation_reference.md lines 289-298 and
docs/zh-cn/user/02-operation_reference.md lines 289-298 incorrectly place Put’s
AtomicType.None_ / Add values in the ReduceOps column. Update both matrices to
represent Put’s atomic types in a separate, appropriate capability column while
leaving ReduceOps distinct and preserving the equivalent English and Chinese
content.
In `@docs/en/user/04-distributed-api-reference.md`:
- Around line 243-244: Update the descriptions of
rt.release_inherited_host_tensor_refs() in both
docs/en/user/04-distributed-api-reference.md (lines 243-244) and
docs/zh-cn/user/04-distributed-api-reference.md (lines 240-241) to state that
runtime-held host references are dropped after fork, without promising
unconditional destruction of the host tensor.
- Around line 157-160: Update the benchmark() documentation in
docs/en/user/04-distributed-api-reference.md lines 157-160 to replace the
incorrect RuntimeError claim with the documented zero-sample fallback when
SIMPLER_HOST_STRACE is disabled. Apply the same corrected benchmark contract in
docs/zh-cn/user/04-distributed-api-reference.md lines 155-158, keeping both API
references consistent.
- Around line 220-227: The DeviceTensor examples are not executable or
worker-safe because they omit torch, allocate outside the prepared runtime, and
invoke compiled directly. In docs/en/user/04-distributed-api-reference.md lines
220-227 and docs/zh-cn/user/04-distributed-api-reference.md lines 217-224,
import torch, move rt.alloc_tensor into the compiled.prepare() lifecycle, and
dispatch the compiled call through rt(...), preserving the documented
DeviceTensor usage in both language versions.
- Around line 231-236: Correct the documented compiled.prepare() signature to
remove inherited_host_tensors and list the actual supported parameters in
docs/en/user/04-distributed-api-reference.md lines 231-236 and
docs/zh-cn/user/04-distributed-api-reference.md lines 226-233, keeping both
bilingual API references consistent.
In `@docs/en/user/05-distributed-guide.md`:
- Around line 35-45: Define SIZE before the type annotations in both mirrored
HelloAllReduce examples, using the same documented extent such as 256:
docs/en/user/05-distributed-guide.md lines 35-45 and
docs/zh-cn/user/05-distributed-guide.md lines 31-42 each require this direct
change.
- Around line 155-164: Update both handshake examples in
docs/en/user/05-distributed-guide.md (lines 155-164) and
docs/zh-cn/user/05-distributed-guide.md (lines 149-159) to document and enforce
the precondition tag >= 1 before the notify/wait sequence; keep the existing
signal cell and wait behavior unchanged.
In `@docs/en/user/06-benchmarking-guide.md`:
- Line 87: The benchmarking documentation inconsistently describes non-STRACE
behavior. Update docs/en/user/06-benchmarking-guide.md lines 87 and 320-328 and
docs/zh-cn/user/06-benchmarking-guide.md lines 85 and 308-315 so both languages
consistently state that non-STRACE benchmarking raises before returning
statistics, removing the implication that zero-valued statistics are returned.
In `@docs/zh-cn/user/00-getting_started.md`:
- Around line 407-459: 将 HelloAllReduce 示例引导语中的“可直接复制运行”改为明确表明这是 InCore
kernel/sample 的措辞,避免暗示无需额外配置即可执行;保留现有内核代码及分布式指南链接不变,除非补充完整的 host、COMPILER 和
distributed 运行设置。
In `@python/pypto/language/distributed/op/tensor_ops.py`:
- Around line 541-544: Update the affected Python docstrings near the
signal-shape documentation to replace the Unicode multiplication and minus
symbols with ASCII `x` and `-`, including the additional occurrences around the
referenced lines. Do not add inline Ruff suppressions; preserve the documented
shape expressions and wording otherwise.
In `@python/pypto/language/dsl_api.py`:
- Around line 715-724: Update the “Three usage forms at a glance” table to show
the capture form as `with pl.spmd(n) as tid:` and indicate that optional
`deps=[...]` may be added, rather than presenting deps as required. Keep the
existing descriptions of dispatch/inline behavior and captured producer TaskId.
---
Nitpick comments:
In `@docs/en/user/06-benchmarking-guide.md`:
- Line 28: Fix the mirrored Markdownlint issues in
docs/en/user/06-benchmarking-guide.md at lines 28, 58, 114, 193, 264, 285, and
363 by adding appropriate language identifiers to the output, API-signature,
span-tree, variance-output, formula, worked-example, and span-tree fences;
prefix the blank blockquote lines at 324, 329, and 334. Apply the same
corresponding fixes in docs/zh-cn/user/06-benchmarking-guide.md at lines 27, 57,
113, 188, 257, 278, and 346 for fences, and 312, 316, and 320 for blank
blockquote lines, preserving the existing bilingual content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6354b3a2-bc3b-4fe9-ac31-591dc7526bdf
📒 Files selected for processing (17)
docs/en/user/00-getting_started.mddocs/en/user/02-operation_reference.mddocs/en/user/04-distributed-api-reference.mddocs/en/user/05-distributed-guide.mddocs/en/user/06-benchmarking-guide.mddocs/zh-cn/user/00-getting_started.mddocs/zh-cn/user/02-operation_reference.mddocs/zh-cn/user/04-distributed-api-reference.mddocs/zh-cn/user/05-distributed-guide.mddocs/zh-cn/user/06-benchmarking-guide.mdpython/pypto/ir/distributed_compiled_program.pypython/pypto/language/distributed/op/system_ops.pypython/pypto/language/distributed/op/tensor_ops.pypython/pypto/language/distributed/op/tile_ops.pypython/pypto/language/dsl_api.pypython/pypto/pypto_core/ir.pyipython/pypto/runtime/bench.py
Fixes from CodeRabbit:
- CR1: Separate Put's AtomicType (None_/Add) from ReduceOps column in
capability matrix, adding a dedicated "Atomic" column.
- CR2: Fix all_zero_device description to remove "or non-STRACE builds"
(non-STRACE raises RuntimeError, does not return zero-valued stats).
- CR3: Make DeviceTensor example executable and worker-safe — add import
torch, wrap in compiled.prepare() context, dispatch via rt(...).
- CR5: Clarify release_inherited_host_tensor_refs() — drops runtime-held
references, not unconditional host-tensor destruction.
- CR6: Define SIZE=256 in HelloAllReduce kernel examples in both EN/zh-cn
distributed guides, so the code compiles as-written.
- CR7: Document handshake tag>=1 precondition — passing tag=0 causes
permanent hang with the Ge expected=1 wait.
- CR9: Clarify zh-cn HelloAllReduce wording from "可直接复制运行" to note
this is an InCore kernel sample requiring additional host/runtime setup.
- CR10: Replace Unicode math symbols (×, −) with ASCII (x, -) in
tensor_ops.py docstrings.
- CR11: Update spmd table to show optional deps, capture form as
`with pl.spmd(n) as tid:`.
Nit: Add language tags (text, python) to bare fenced code blocks in
EN benchmarking guide.
AI Review Comment Fixes — All AddressedAll 17 review comments from CodeRabbit and chatgpt-codex-connector have been addressed in the latest commit. Here's a summary: chatgpt-codex-connector (6 comments — already fixed in previous commits, verified clean):
CodeRabbit (11 comments — all fixed in this commit):
Nit:
|
e0d3ce5 to
ee56f06
Compare
YunjiQin
left a comment
There was a problem hiding this comment.
Thanks for putting these together — the distributed and benchmarking surface has needed user-facing documentation for a while, and the structure here is good. I checked the prose against the implementation rather than reading for style; most of it holds up.
Verified correct (spot-checking the claims that are easiest to get wrong):
- C1
pl.Level.HOST+pl.Role.Orchestrator— matchesdecorator.py:776andir.pyi:837/896. - C2
SIMPLER_HOST_STRACE/SIMPLER_DFXas compile-time macros defaulting to1—profiling_config.h:15-24;SIMPLER_DEVICE_STRACE_ENABLEreally is agetenv(c_api_shared.cpp:474). Good catch, this one was genuinely misdocumented before. benchmark()signature — byte-for-byte withbench.py:840-849; everyBenchmarkStatsfield and property in the guide exists.- Ring signal
[2(NR-1), NR]+ the factory-function pattern — matchestest_l3_allreduce_ring.py:71-84,205. - allreduce-inside-a-loop rejection —
synthesize_allreduce_signals_pass.cpp:190. pld.*short-form / no-short-form table — exactly matchesdistributed/__init__.py's__all__.RunConfig(ring_task_window=256, ring_heap=1024)— both satisfy the power-of-2 constraints inrunner.py:307-312.
Blocking, in rough priority order (details inline):
05— the "InCore Hand-Rolled vs Host-Level Builtin" section is built on a dichotomy that does not exist; InCore composites are a first-class path with their own ST suite.05— the Hello World HOST orchestrator will not compile (missing chip-orch layer, rank mismatch, tensor-into-pl.store,pl.dynamicused as a runtime shape).05vs06— contradictory claims about a missing.share_memory_(); the runtime raisesTypeError.tensor_ops.pyx6 +04/05— the "1-D host / 2-D InCore" signal-shape rule; the host rail accepts both.04—window/alloc_window_bufferfiled underpld.system.*; they arepld.tensor.*.06—prepare(ring_task_window=...)and the "prewarm" paragraph describe an API that does not exist.04/05—cmake -DSIMPLER_HOST_STRACE=1is a no-op; nothing in the build reads it.
Scope / hygiene:
04— thepl.*DSL-constructs andpl.system.*cross-core sections are L2 / intra-chip material and do not belong in a distributed API reference.04(and to a lesser degree06) — thePYPTO_BENCH*table documents pypto-lib-owned variables that have no effect in this repo.04—ScopeModeispl.ScopeMode;bench.py— the new RST table does not parse;05is 581 lines against the 500-line cap in.claude/rules/documentation-length.md.
All of the above apply equally to docs/zh-cn/user/, which mirrors the English text faithfully — including the errors. Worth fixing both sides in the same pass.
…rectories - Create distributed/ (6 files) and performance/ (5 files) in EN + zh-cn - Merge content from 04-distributed-api-reference, 05-distributed-guide, and 06-benchmarking-guide into the new chapter structure - Remove old flat files in EN and zh-cn - All new files <= 210 lines; 7 docstring backfill files unchanged
…rectories - Create distributed/ (6 files) and performance/ (5 files) in EN + zh-cn - Merge content from 04-distributed-api-reference, 05-distributed-guide, and 06-benchmarking-guide into the new chapter structure - Remove old flat files in EN and zh-cn - All new files <= 210 lines; 7 docstring backfill files unchanged
…iew findings Rebases the restructured PR hw-native-sys#2162 chapters onto main's MkDocs site scaffold (hw-native-sys#2193) and the docs/zh-cn -> docs/zh locale rename, adds the new distributed/ and performance/ chapters to mkdocs.yml nav and the top-level user manual index, and retargets cross-references that still pointed at the deleted flat 04/05/06 files. Also fixes markdownlint failures introduced by the restructure commit, and addresses the outstanding technical-accuracy review comments: - distributed/00-model.md: the Quickstart HelloAllReduce example now matches the working test_l3_allreduce.py reference (adds the missing Orchestration dispatch layer, fixes a rank mismatch from pl.slice, drops a redundant store, and uses pld.world_size() for the signal window). - distributed/02-primitives.md: window/alloc_window_buffer moved out of the pld.system.* table into their actual pld.tensor.* namespace. - distributed/01-collectives.md and tensor_ops.py (6 docstrings): corrects the host-builtin signal shape (rank-1 or rank-2, not only 1-D) and replaces the InCore-hand-rolled-vs-HOST-builtin dichotomy with the real three-way split (hand-rolled / InCore composite / HOST builtin), since ring mode is InCore-composite-only. - distributed/03-execution.md, performance/00-methodology.md: drops fabricated PYPTO_BENCH* defaults that belong to pypto-lib, not this repo. - distributed/04-debugging.md: removes a non-functional `cmake -D...` example for compile-time macros that no CMakeLists.txt in the repo reads. - performance/02-distributed.md: corrects Ring Sizing to reflect that RunConfig must be passed to every dispatch, not just prepare(), and states the real power-of-2 size constraints. - 02-operation_reference.md: drops a stale branch reference and an unverified dtype restriction from the AllReduce capability matrix. - bench.py: fixes a malformed RST table (column marker narrower than its widest cell). All changes mirrored in docs/zh/user/.
f3705b3 to
60c1b49
Compare
Update: Rebased onto main, wired into the site, and addressed all review commentsThis PR is now rebased onto current Rebase onto
|
|
converting to draft, no need for review yet, needs some work and polishing |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bfb602d42
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
This PR will be broken down to smaller parts as discussed offline with @lyfne123. Making it draft, and will step by step break it down and to smaller ones. |
Adds the Distributed Programming and Performance & Benchmarking chapters to the PyPTO user manual (distributed/, performance/), wires them into mkdocs.yml nav (EN + ZH), and tightens accuracy across the collectives/API-surface docs and a handful of related docstrings and one type stub found stale during review. Squashed from the PR's incremental history (10 commits) to make rebasing onto main's own concurrent doc restructuring (hw-native-sys#2198) a single conflict-resolution pass instead of ten.
c715702 to
72f446e
Compare
Corrects several stale/incorrect docstrings and one shipped type stub found while writing the distributed programming and benchmarking user-manual chapters (split out of PR hw-native-sys#2162): - ir.pyi: ReduceOp's docstring claimed only Sum is operational and the others "raise a C++ deducer error if passed to any collective." That's wrong — allreduce accepts all four; only reduce_scatter is actually Sum-only. Restated per-operation. - tensor_ops.py: per-operation signal-shape docstrings (allreduce accepts rank-1 or rank-2 on the HOST builtin path; barrier/ broadcast/reduce_scatter are rank-1-only; allgather/all_to_all accept both) — previously uniform and wrong for several ops. - system_ops.py, tile_ops.py, dsl_api.py, bench.py, distributed_compiled_program.py: docstring completeness fixes (missing benchmark() keyword params, DistributedConfig field docs, dispatch examples, spmd form table, code examples).
Corrects several stale/incorrect docstrings and one shipped type stub found while writing the distributed programming and benchmarking user-manual chapters (split out of PR hw-native-sys#2162): - ir.pyi: ReduceOp's docstring claimed only Sum is operational and the others "raise a C++ deducer error if passed to any collective." That's wrong — allreduce accepts all four; only reduce_scatter is actually Sum-only. Restated per-operation. - tensor_ops.py: per-operation signal-shape docstrings (allreduce accepts rank-1 or rank-2 on the HOST builtin path; barrier/ broadcast/reduce_scatter are rank-1-only; allgather/all_to_all accept both) — previously uniform and wrong for several ops. - system_ops.py, tile_ops.py, dsl_api.py, bench.py, distributed_compiled_program.py: docstring completeness fixes (missing benchmark() keyword params, DistributedConfig field docs, dispatch examples, spmd form table, code examples).
## Summary Split out of #2162 (which is being broken into smaller PRs — see that PR's description). This piece is fully independent of the rest: pure Python docstring / type-stub corrections found while writing the distributed-programming and benchmarking user-manual chapters. - **`ir.pyi`**: `ReduceOp`'s docstring claimed only `Sum` is operational and that `Max`/`Min`/`Prod` "raise a C++ deducer error if passed to any collective." That's wrong — `allreduce` accepts all four (both InCore and HOST paths); only `reduce_scatter` is actually `Sum`-only. Restated per-operation. - **`tensor_ops.py`**: per-operation signal-shape docstrings. Previously uniform ("rank-1 or rank-2" for every collective) — actually only `allreduce`/`allgather`/`all_to_all` accept both ranks on the HOST builtin path; `barrier`/`broadcast`/`reduce_scatter` are rank-1-only. - **`system_ops.py`, `tile_ops.py`, `dsl_api.py`, `bench.py`, `distributed_compiled_program.py`**: docstring completeness fixes — `DistributedConfig` field documentation, dispatch examples, the `spmd` three-form table, and a couple of missing code examples. Addressed review feedback (see PR discussion) in a follow-up commit: - Added real HOST-only parser enforcement for `alloc_window_buffer` (previously only claimed by the docstring), with tests. - Fixed the `num_sub_workers=0` docstring to match actual runtime semantics (`max(num_sub_workers, len(sub_worker_fns))`). - Corrected a wrong issue reference in the allreduce signal-reuse note. - Added a pointer to where the mesh partial-valid / symbolic-extent constraints are documented (unchanged, just relocated out of this docstring). - Converted two non-rendering RST tables to Markdown (the docs site renders docstrings as Markdown, not RST), extending the `BenchmarkStats` one to cover the per-dispatch API added by #2223. - Fixed `DistributedConfig`'s docstring section header (`Fields:` → `Attributes:`) and stale `allgather` prose referring to a since-renamed parameter. - Dropped an unverifiable "legacy reasons" history claim from `notify`'s docstring note. `notify`/`wait`'s signal parameter type (`Tensor` vs. `DistributedTensor`) was intentionally **not** narrowed here: doing so broke `pyright` on two legitimate call sites where a loop-carried `DistributedTensor` value loses its static type through `pl.range`/`pl.while_`. That's tracked separately in #2234, along with the type-narrowing itself. No behavior changes beyond the `alloc_window_buffer` scope check (makes parse-time behavior match what was already enforced at runtime). ## Verification - `python -c "import ast; ast.parse(...)"` on every changed file - `pre-commit run --files <changed files>` (ruff check/format, pyright, headers) — all pass - Full `pytest tests/ut` suite (8433 passed, 13 skipped, 0 failed) run via the `pypto3-hw-native-sys:sim` Docker image - Manually rendered the two converted docstrings through `markdown.markdown(..., extensions=["tables"])` to confirm they now produce real `<table>` elements (previously collapsed to one paragraph under RST simple-table syntax)
…nual Split out of PR hw-native-sys#2162 — the final piece, wiring the two new chapters (hw-native-sys#2219, hw-native-sys#2220) into the existing manual: - index.md (+ zh): new Contents/capability-table rows for the two chapters, a 4th reading path ("I want to run across multiple devices"), dropped the now-superseded dev-doc pointer for distributed collectives. - 00-getting_started.md (+ zh): short pointer paragraphs into the new chapters from the existing benchmark/distributed sections. - 02-operation_reference.md (+ zh): new "Distributed / Collective Operations" capability matrix cross-linking into the distributed chapter. Depends on hw-native-sys#2219 (Distributed) and hw-native-sys#2220 (Performance) merging first — this branch references pages that only exist once both land, so `mkdocs build --strict` will fail here until then. Verified together with both dependencies via a local integration merge (all green: markdownlint, EN/ZH parity, nav, pre-commit, mkdocs build --strict); opening this now so the full picture of the split is visible.
## Summary Split out of #2162 (which is being broken into smaller PRs — see that PR's description). Adds `docs/en/user/distributed/` (+ full `docs/zh/` mirror) and wires it into `mkdocs.yml` nav. - **`index.md`** — PyPTO's distributed model in one page: symmetric memory + signals, comm domains, and how PyPTO's simplified L2 (single-chip) / L3 (cross-rank) vocabulary relates to the `simpler` runtime's own finer L0–L6 hierarchy. - **`00-model.md`** — A minimal end-to-end `HelloAllReduce` walkthrough: host orchestrator, per-chip orchestration function, InCore kernel, window buffers, and the launch model (a distributed program launches as plain `python script.py` — PyPTO forks the per-chip workers internally). - **`01-collectives.md`** — Every collective (`allreduce`, `barrier`, `broadcast`, `allgather`, `reduce_scatter`, `all_to_all`), the three execution paths (InCore hand-rolled, InCore composite, HOST builtin) and when to reach for each, supported `ReduceOp`/dtype per operation, worked examples. - **`02-primitives.md`** — Lower-level building blocks: `notify`/`wait` handshakes, window buffer allocation, tile-level RMA, one-sided `put`/`get` with chunking/pipelining constraints, composing primitives into a hand-rolled collective. - **`03-execution.md`** — `DistributedWorker` lifecycle, `DistributedConfig`, dispatch. - **`04-debugging.md`** — Common failure modes with symptoms and fixes. **Note:** this chapter cross-references a Performance chapter that is being split out as a separate PR. Those specific links are omitted here and will be added back once that PR (and this one) land — see #2162 for the full picture of how the pieces fit together. ## Verification - `npx markdownlint-cli2 --config tests/lint/.markdownlint.yaml` - `python3 tests/lint/check_docs_en_zh_parity.py` - `python3 tests/lint/check_docs_nav.py` - `pre-commit run --all-files` - `mkdocs build --strict` (clean, no broken links)
…nual Split out of PR hw-native-sys#2162 — the final piece, wiring the two new chapters (hw-native-sys#2219, hw-native-sys#2220) into the existing manual: - index.md (+ zh): new Contents/capability-table rows for the two chapters, a 4th reading path ("I want to run across multiple devices"), dropped the now-superseded dev-doc pointer for distributed collectives. - 00-getting_started.md (+ zh): short pointer paragraphs into the new chapters from the existing benchmark/distributed sections. - 02-operation_reference.md (+ zh): new "Distributed / Collective Operations" capability matrix cross-linking into the distributed chapter. Depends on hw-native-sys#2219 (Distributed) and hw-native-sys#2220 (Performance) merging first — this branch references pages that only exist once both land, so `mkdocs build --strict` will fail here until then. Verified together with both dependencies via a local integration merge (all green: markdownlint, EN/ZH parity, nav, pre-commit, mkdocs build --strict); opening this now so the full picture of the split is visible.
This PR grew too large to review comfortably (36 files, ~3000 lines) and has
been split into four small, independently-reviewable PRs carrying the exact
same content:
docs/en/user/distributed/+ zh mirror)docs/en/user/performance/+ zh mirror)(draft — depends on docs(user): add the Distributed Programming chapter #2219 and docs(user): add the Performance & Benchmarking chapter #2220 merging first)
All four were cut from this branch's final commit and independently verified
(markdownlint, EN/ZH parity, nav coverage,
pre-commit run --all-files,mkdocs build --strict); a full end-to-end integration of all four togetherwas also verified to build cleanly with zero broken links and no lost or
duplicated content versus this branch.
Closing this PR without merging — please review and merge #2218–#2221 instead.
Original description (superseded, kept for reference)
Summary
Adds the Distributed Programming and Performance & Benchmarking
chapters to the PyPTO user manual, covering PyPTO's L3 distributed execution
model and its benchmarking/tuning workflow end to end. Structure and scope
follow the site's documentation plan and slot directly into the existing
mkdocs.ymlnav (EN + ZH).What's in this PR
Distributed Programming (
docs/en/user/distributed/)index.md— PyPTO's distributed model in one page: symmetric memoryL3 (cross-rank) vocabulary relates to the
simplerruntime's own finerL0–L6 hierarchy.
00-model.md— A minimal end-to-endHelloAllReducewalkthrough:host orchestrator, per-chip orchestration function, InCore kernel, window
buffers, and how to launch it (a distributed program launches as a plain
python script.py— PyPTO forks the per-chip workers internally, there'sno external multi-process launcher).
01-collectives.md— Every collective (allreduce,barrier,broadcast,allgather,reduce_scatter,all_to_all), the threeexecution paths (InCore hand-rolled, InCore composite, HOST builtin) and
when to reach for each, supported
ReduceOp/dtype per operation, andworked examples for each collective.
02-primitives.md— The lower-level building blocks for anyonewriting a custom protocol:
notify/waitsignal handshakes, windowbuffer allocation, tile-level RMA (
remote_load/remote_store),one-sided
put/getwith their chunking/pipelining constraints, and howto compose primitives into a hand-rolled collective.
03-execution.md—DistributedWorkerlifecycle,DistributedConfig,and how a compiled distributed program is dispatched.
04-debugging.md— Common failure modes (hangs, dispatch-time typeerrors, misconfigured
device_ids) with symptoms and fixes.Performance & Benchmarking (
docs/en/user/performance/)index.md/00-methodology.md— A decision tree for where to lookfirst (compiler hints, span tree, op-simulator, memory map, dependency
graph) and the programmatic
benchmark()API: signature,BenchmarkStatsfields, aggregates, and span-tree rendering.
01-single-node.md— Single-node tuning: partitioning/parallelism(
pl.split,pl.spmd,pl.cluster), pipelining/unrolling, the matmulpath, memory placement (
target_memory,MemorySpace), and schedulingcontrols (
predicate=,no_dep,manual_scope).02-distributed.md— L3-specific performance: ring sizing andRunConfigprewarming, and a bus-bandwidth estimation formula.03-cases.md— End-to-end worked cases (status: additional casesplanned).
Every page is mirrored in full under
docs/zh/user/....Operation Reference
docs/en/user/02-operation_reference.mdgains a Distributed / CollectiveOperations section: a capability matrix covering every
pld.*op (API,modes,
ReduceOp, atomic support, supported dtypes per execution path, andnotes), cross-linked to the new chapters above.
Site wiring
mkdocs.yml:Distributed:andPerformance:nav sections underUser Manual:, withnav_translationsentries for the ZH sidebar.Supporting docstring updates
A handful of docstrings in
tensor_ops.py,system_ops.py,tile_ops.py,dsl_api.py,distributed_compiled_program.py,bench.py, and their.pyitype stub were tightened to match the semantics described in thenew guides (per-operation
ReduceOpsupport, per-operation signal-shaperank acceptance, and similar precision fixes) so the in-editor docs and the
manual agree.
Verification
npx markdownlint-cli2(project config)python3 tests/lint/check_docs_en_zh_parity.pypython3 tests/lint/check_docs_nav.pypre-commit run --all-filesmkdocs build --strictWhat this does NOT cover
stub only
performance/01-single-node.md(the ZH mirror is intentionally morecondensed in a few places; tracked as a follow-up)
for this PR; a good candidate for a follow-up lint rule)