Skip to content

docs: add architecture + get_m2m_map diagrams and design walkthrough - #110

Merged
fecet merged 1 commit into
mainfrom
docs/m2m-diagrams
Jun 4, 2026
Merged

docs: add architecture + get_m2m_map diagrams and design walkthrough#110
fecet merged 1 commit into
mainfrom
docs/m2m-diagrams

Conversation

@jing-4369

@jing-4369 jing-4369 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Adds an M-to-N redistribution overview banner to the README header, plus a
get_m2m_map algorithm diagram and a step-by-step design walkthrough under
docs/design/.

  • docs/design/etha_arch.png — overview banner (README header)
  • docs/design/etha_m2m_map.png — get_m2m_map algorithm diagram
  • docs/design/get-m2m-map.md — step-by-step walkthrough (linked from README), added to the design toctree

Heads-up: the etha_m2m_map.png render still carries two known errors (Stage 2
formula is missing the c0*5 term; Stage 6 row 3·(0,1) should map to 3·(1,0)).
To be replaced with a corrected render before/after merge.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a top-level architecture diagram and a new “core” subsection explaining M-to-N DTensor redistribution mapping.
    • Added a detailed design guide with visual examples and a worked example showing how redistribution maps are constructed and applied.
    • Updated the design index to include the new guide and associated visuals.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds documentation for the DTensor M-to-N redistribution mapping: a README architecture image and core subsection introducing get_m2m_map, plus a new design document detailing the LCM-based alignment, stamping/distribution, decode/redistribute, and all-gather pipeline; index updated.

Changes

M-to-N DTensor redistribution documentation

Layer / File(s) Summary
README architecture and core M-to-N subsection
README.md
Adds an architecture image and a "The core: the M-to-N communication map" subsection that references get_m2m_map and includes a design image.
Design document and documentation index
docs/design/get-m2m-map.md, docs/design/index.md
Introduces get-m2m-map.md describing the full get_m2m_map pipeline (per-dimension LCM alignment, middle-grid stamping, gather/send, target re-slice and decode, all-gather) with a worked example; updates the design toctree.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🐰 A tiny map I sketched neat,
Cells aligned in LCM beat,
Stamps that tell each shard's home,
Sent and sliced, no path to roam,
Redistributed — hop, complete!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main changes: adding architecture and algorithm diagrams plus a design document walkthrough.
Description check ✅ Passed Description covers what was done and includes concrete file details, but omits the template sections for new test cases, test results, and other comments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/m2m-diagrams

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@README.md`:
- Line 20: The heading "The core: the M-to-N communication map" is currently an
h3 and skips h2; change its markdown level from ### to ## so it becomes a proper
h2 and restores the document heading hierarchy.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: e312538c-bd99-4b15-a93d-f456a92f10ef

📥 Commits

Reviewing files that changed from the base of the PR and between efed75e and b768fb7.

⛔ Files ignored due to path filters (2)
  • docs/design/etha_arch.png is excluded by !**/*.png
  • docs/design/etha_m2m_map.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • README.md
  • docs/design/get-m2m-map.md
  • docs/design/index.md

Comment thread README.md Outdated
@jing-4369
jing-4369 force-pushed the docs/m2m-diagrams branch from b768fb7 to 0f334d7 Compare June 3, 2026 08:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
README.md (1)

20-20: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix heading level to follow markdown hierarchy.

The heading jumps from h1 (line 1) to h3 without an intervening h2. Change to h2 (##) to maintain proper document structure.

📐 Proposed fix
-### The core: the M-to-N communication map
+## The core: the M-to-N communication map
🤖 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 `@README.md` at line 20, The heading "The core: the M-to-N communication map"
is currently an h3 (###) and skips an h2 level; update that heading to h2 (##)
in README.md so it follows the document hierarchy and sits under the top-level
title, i.e., replace the "### The core: the M-to-N communication map" line with
"## The core: the M-to-N communication map".
🤖 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.

Duplicate comments:
In `@README.md`:
- Line 20: The heading "The core: the M-to-N communication map" is currently an
h3 (###) and skips an h2 level; update that heading to h2 (##) in README.md so
it follows the document hierarchy and sits under the top-level title, i.e.,
replace the "### The core: the M-to-N communication map" line with "## The core:
the M-to-N communication map".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4d68b2b-3b8b-4d6e-8e57-9d7fdea521ea

📥 Commits

Reviewing files that changed from the base of the PR and between b768fb7 and 0f334d7.

⛔ Files ignored due to path filters (2)
  • docs/design/etha_arch.png is excluded by !**/*.png
  • docs/design/etha_m2m_map.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • README.md
  • docs/design/get-m2m-map.md
  • docs/design/index.md
✅ Files skipped from review due to trivial changes (1)
  • docs/design/index.md

@jing-4369
jing-4369 force-pushed the docs/m2m-diagrams branch 3 times, most recently from 274a332 to fa38df9 Compare June 3, 2026 08:59
Add an M-to-N redistribution overview banner to the README header and a
get_m2m_map algorithm diagram with a step-by-step design walkthrough under
docs/design/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jing-4369
jing-4369 force-pushed the docs/m2m-diagrams branch from fa38df9 to 502e1c2 Compare June 4, 2026 02:44

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

47-49: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Correct the source Partial behavior description to match the real contract.

The current note says source Partial is collapsed via a pre-send all-reduce, but the implementation contract is more specific: source-side Partial is traced as Replicate and then reduce-only shadow entries are added; target-side Partial is rejected. Please align this wording to avoid misleading users about when/where reduction happens.

Based on learnings: “Partial in placements can corrupt map tracing via full_tensor(); it does not silently fall back to Replicate behavior.”

🤖 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 `@README.md` around lines 47 - 49, Update the README description under
"Placements" to accurately describe source-side Partial semantics: state that
source `Partial` is traced as `Replicate` for map tracing and additionally has
reduce-only shadow entries added on the source (not an all-reduce collapse
before send), while target `Partial` remains rejected; mention that using
`Partial` can affect map tracing via `full_tensor()` rather than silently
falling back to `Replicate`. Reference the placement names `Shard`, `Replicate`,
`Partial` and the `full_tensor()` behavior so readers see the exact contract.
🧹 Nitpick comments (1)
docs/design/get-m2m-map.md (1)

15-15: ⚡ Quick win

Add fenced code block languages to satisfy markdown lint.

Please annotate these fences (for example with text) so MD040 does not flag the document.

Also applies to: 43-43, 58-58, 74-74, 97-97, 115-115

🤖 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/design/get-m2m-map.md` at line 15, The markdown file has several fenced
code blocks without language annotations causing MD040; update each backtick
fence (the code blocks at the locations mentioned) to include a language token
(e.g., add "text" after the opening ```). Locate the empty fences in
get-m2m-map.md (the code block markers around the sample snippets) and change
them from ``` to ```text for each occurrence so the linter stops flagging MD040.
🤖 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/design/get-m2m-map.md`:
- Around line 59-60: The sentence "each rank's row-shard is gathered back into
the whole 4×2 tensor, then sent" is misleading; update the wording to state that
each source rank performs a per-source send (fan-out) to its assigned target
rank(s) rather than implying a single global send. Specifically locate that
exact phrase and change it to something like "each source rank gathers its
row-shard into the 4×2 tensor and then sends that shard to one or more assigned
target ranks (per-source fan-out)," and make the same edit for the identical
occurrence at the other location.

---

Outside diff comments:
In `@README.md`:
- Around line 47-49: Update the README description under "Placements" to
accurately describe source-side Partial semantics: state that source `Partial`
is traced as `Replicate` for map tracing and additionally has reduce-only shadow
entries added on the source (not an all-reduce collapse before send), while
target `Partial` remains rejected; mention that using `Partial` can affect map
tracing via `full_tensor()` rather than silently falling back to `Replicate`.
Reference the placement names `Shard`, `Replicate`, `Partial` and the
`full_tensor()` behavior so readers see the exact contract.

---

Nitpick comments:
In `@docs/design/get-m2m-map.md`:
- Line 15: The markdown file has several fenced code blocks without language
annotations causing MD040; update each backtick fence (the code blocks at the
locations mentioned) to include a language token (e.g., add "text" after the
opening ```). Locate the empty fences in get-m2m-map.md (the code block markers
around the sample snippets) and change them from ``` to ```text for each
occurrence so the linter stops flagging MD040.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90c47bca-d26d-4039-9dd6-6e96ef7dfe40

📥 Commits

Reviewing files that changed from the base of the PR and between 0f334d7 and 502e1c2.

⛔ Files ignored due to path filters (2)
  • docs/design/etha_arch.png is excluded by !**/*.png
  • docs/design/etha_m2m_map.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • README.md
  • docs/design/get-m2m-map.md
  • docs/design/index.md
✅ Files skipped from review due to trivial changes (1)
  • docs/design/index.md

Comment on lines +59 to +60
each rank's row-shard is gathered back into the whole 4×2 tensor, then sent

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Clarify “sent once” to avoid an incorrect transfer model.

This wording implies a single global send, but the implementation sends from each source rank to one or more assigned target ranks. Please rephrase to reflect per-source-rank send fan-out where applicable.

Also applies to: 123-123

🤖 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/design/get-m2m-map.md` around lines 59 - 60, The sentence "each rank's
row-shard is gathered back into the whole 4×2 tensor, then sent" is misleading;
update the wording to state that each source rank performs a per-source send
(fan-out) to its assigned target rank(s) rather than implying a single global
send. Specifically locate that exact phrase and change it to something like
"each source rank gathers its row-shard into the 4×2 tensor and then sends that
shard to one or more assigned target ranks (per-source fan-out)," and make the
same edit for the identical occurrence at the other location.

@fecet fecet self-assigned this Jun 4, 2026
@fecet
fecet self-requested a review June 4, 2026 07:10
@fecet
fecet merged commit 6a04729 into main Jun 4, 2026
7 checks passed
@fecet
fecet deleted the docs/m2m-diagrams branch June 4, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants