Skip to content

Add expert-parallel all-to-all comm transport - #725

Merged
AkshitaB merged 6 commits into
akshitab/moe-v2-corefrom
akshitab/moe-v2-ep-comm
Jun 30, 2026
Merged

AkshitaB merged 6 commits into
akshitab/moe-v2-corefrom
akshitab/moe-v2-ep-comm

Conversation

@AkshitaB

Copy link
Copy Markdown
Contributor

Adds nn/moe/v2/comm.py: the autograd-aware all-to-all dispatch/combine transport used by no-sync expert parallelism.

It provides the dispatch/combine torch.autograd.Functions for two transports:

  • the symmetric-memory VDev path (_DispatchVDevAutograd / _CombineVDevAutograd), and
  • the row-wise path including row-wise FP8 (_DispatchRowwise* / _RowwiseCombineWeighted*),

built on the symmetric-memory and MXFP8 / scaled-grouped-mm kernels. Everything operates on plain tensors, process groups, and symmetric-memory buffers — there is no dependency on the MoE block or model.

Depends only on olmo_core.kernels.* (already present) and torch; the kernel extensions load lazily, so the module imports on CPU. The all-to-all ops require multiple GPUs + symmetric memory to exercise, so correctness tests run on GPU hardware and are added with the GPU test pass.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@AkshitaB AkshitaB changed the title Add MoE-v2 expert-parallel all-to-all comm transport Add expert-parallel all-to-all comm transport Jun 12, 2026
TianhuaTao and others added 3 commits June 29, 2026 14:27
Adds `nn/moe/v2/comm.py`: the autograd-aware all-to-all dispatch/combine
transport for no-sync expert parallelism. Provides the dispatch/combine
autograd ops for the symmetric-memory "VDev" path and the row-wise (incl.
row-wise FP8) path, built on the symmetric-memory and MXFP8/scaled-grouped-mm
kernels. Operates on plain tensors + process groups + symmetric-memory buffers.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Use the builtin `tuple` annotation instead of `typing.Tuple`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Exercises _RowwiseCombineWeightedAutograd and _RowwiseCombineWeightedFP8Autograd
on CPU with the symmetric-memory kernels monkeypatched out, checking lifetime-lease
release and that the combine backward returns grads for the routing probabilities.
Ported from the dev branch; the bf16 combine call is updated to the current
forward() signature (expert_out_aliases_symm_expert_out + pre/post barriers).

Co-authored-by: Tianhua Tao <[email protected]>

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
@AkshitaB
AkshitaB force-pushed the akshitab/moe-v2-ep-comm branch from 1b688eb to 158a195 Compare June 29, 2026 21:39
AkshitaB and others added 3 commits June 29, 2026 15:14
Each comm autograd Function returns a long positional gradient tuple (one entry per
forward input, mostly None). Annotate every slot with its forward-input name and route the
tuple through a shared _check_input_grads() guard that asserts the count matches and that a
non-None gradient only lands on an input that requires one — catching the silent-misalignment
class of bug the bare tuples invite.

Also fixes _CombineVDevAutograd.backward, which returned 10 gradients for 9 forward inputs.
PyTorch silently ignores extra trailing None gradients (it only errors on too-few), so this
was latent; the count guard now makes it correct and explicit.

A TODO(autograd-grads) on the helper points at the deeper cleanups (a name-keyed gradient
builder, and collapsing the non-differentiable forward config args) for the EP consolidation.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Remove the 7 unused env-gated debug helpers and ~190 lines of commented-out
debug-print/sync call sites that traced the rowwise symmetric-memory all-to-all.
Replace them with one clearly-labeled commented hook at the combine_get site plus a
one-line note on the OLMO_ROWWISE_DEBUG_PRINT env switch, so the tracing technique
(routing-map dump + torch.cuda.synchronize to localize async RMA faults) is still
discoverable without shipping the dead bulk.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Cover the comm failure modes that are exercisable in one process: routing-map validation
(malformed src_ranks/probs shapes and negative nblocks are rejected before the kernel) and the
hand-written rowwise SwiGLU forward/backward math (vs a reference and autograd), alongside the
existing lifetime-lease / grad-probs tests. The cross-rank barrier/race and scatter modes are
inherently multi-process and are covered end-to-end by the EP-vs-no-EP parity test.

Co-authored-by: Tianhua Tao <[email protected]>

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
@AkshitaB
AkshitaB merged commit 3143bde into akshitab/moe-v2-core Jun 30, 2026
68 of 70 checks passed
@AkshitaB
AkshitaB deleted the akshitab/moe-v2-ep-comm branch June 30, 2026 00:19
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