Skip to content

[MoE][Docs] Explain router-score absorption memory and recompute tradeoffs - #5977

Draft
Mystri wants to merge 4 commits into
pytorch:mainfrom
Mystri:codex/absorption-docs-5543
Draft

Mystri wants to merge 4 commits into
pytorch:mainfrom
Mystri:codex/absorption-docs-5543

Conversation

@Mystri

@Mystri Mystri commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary (human-written)

Why

Follow-up to #5543 and Tianyu's request for more motivation about memory and compute overhead. The existing guide explains score placement, but does not clearly explain the backward dependency or the tradeoff between saving and replaying W2.

For a bias-free routed row:

Score after W2:  ds = dot(g, W2(h))  -> retain or rebuild W2's output
Absorption:     ds = dot(W2.T @ g, h) -> reuse W2's required input gradient

Absorption enables saving W2 without retaining its routed output for scoring. FullAC still replays W2 unless its region is saved.

What changed

  • Expand only torchtitan/models/common/moe/ROUTER_SCORE_ABSORPTION.md.
  • Reuse [MoE] Apply router scores before W2 projection #5543's original graph with a caption clarifying its assumptions, and add backward equations explaining the dependency removal.
  • Compare no remat, selective W2 SAVE, and FullAC; include an explicit W2 SAVE policy.
  • Separate analytical routed-output storage savings from combined-output pin cleanup and measured peak memory.
  • Describe FP32 multiplication, BF16 rounding, GPT-OSS bias, dtype casts, postprocessing, and extra scaled-input storage without remat.

User-facing changes

Before After
Score-placement guide with limited motivation Illustrated backward dependencies and memory/recompute tradeoffs
Remat savings easy to overgeneralize Explicit W2 SAVE versus FullAC distinction and limits

Validation

Docs only; no executable or numerical behavior changes. Storage and FLOP examples are analytical, with no new end-to-end performance or convergence claim.

  • SKIP=pyrefly-check pre-commit run --all-files: all enabled hooks passed. Final Markdown changes also passed targeted hooks and git diff --check.
  • Checked the original image attachment and local Markdown targets.
  • An isolated CPU experiment with pinned torch_remat 0.2.2 confirmed that FullAC executes W2 twice in both scoring forms. Saving W2 executes it once; post-W2 scoring retains its routed output, while absorption removes that retention dependency.
  • Full-project Pyrefly reports the same 50 errors on the base and implementation branch; this docs branch changes no Python files.

HybridEP implementation and its GPU validation remain a separate follow-up, so this explanation can merge independently.

Follow up pytorch#5543 with forward/backward diagrams and policy-specific motivation for the existing DeepEP path. Distinguish FullAC replay from selective W2 saving and qualify bias, postprocess, precision, and storage examples.
Keep the pytorch#5543 motivation and memory/recompute explanation in ROUTER_SCORE_ABSORPTION.md. Leave README and remat communication-policy updates to the HybridEP support follow-up.
Embed the original PR schematic in the motivation section, with a short caption scoping activation labels, hidden-width storage, and the W2 SAVE replay benefit.
@pytorch-bot pytorch-bot Bot added the ciflow/rl label Nov 9, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 9, 2026
@pytorch-bot

pytorch-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/rl

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

Follow SHARDING.md with an implementation intro, illustrated Overview, Configurations tables, and Submodule behavior notes. Consolidate duplicate diagrams while retaining the pytorch#5543 graph, backward dependency, remat tradeoffs, analytical examples, and correctness caveats.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant