Skip to content

Add rowwise no-sync EP route-map and metrics helpers - #742

Merged
AkshitaB merged 12 commits into
akshitab/moe-v2-corefrom
akshitab/moe-v2-ep-rowwise-helpers
Jul 1, 2026
Merged

AkshitaB merged 12 commits into
akshitab/moe-v2-corefrom
akshitab/moe-v2-ep-rowwise-helpers

Conversation

@AkshitaB

Copy link
Copy Markdown
Contributor

First piece of the rowwise no-sync expert-parallel path (the production no-sync path).

What's added

nn/moe/v2/ep_no_sync_rowwise_helpers.py:

  • build_rowwise_route_maps — per-route destination rank/row maps for the rowwise all-to-all (tail-dropped routes encoded as -1).
  • accumulate_ / add_ / reset_ep_no_sync_rowwise_metrics — per-block drop-rate and symm-buffer-utilization counters, read by the block's auxiliary-metrics path (which already lazy-imports them).

Clean leaf — depends only on get_rank + torch (block ref is TYPE_CHECKING-only).

Notes

  • Removed the dead env-gated route-map debug instrumentation; the trace switch (OLMO_TBO_VERBOSE_DEBUG_PRINT) is noted in the module docstring.
  • nvtx via the shared _nvtx.annotate helper; lowercase tuple[...] hints; module docstring.

Testing

src/test/nn/moe/v2/ep_no_sync_rowwise_helpers_test.py (CPU): metric accumulation (drop rate + symm-buffer util with reduce types) and the zero-capacity ignore case. make checks clean.

🤖 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 and others added 10 commits June 30, 2026 02:39
build_rowwise_route_maps (per-rank routing maps for the rowwise all-to-all) and the rowwise
no-sync metric accumulators (add/accumulate/reset_ep_no_sync_rowwise_metrics) shared by the
rowwise no-sync forward paths and read by the block's auxiliary-metrics path.

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

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
- Remove the dead env-gated route-map debug instrumentation (the _rowwise_route_debug_*
  helpers + their commented call sites) and leave the trace note in the module docstring.
- Use the shared _nvtx.annotate helper; lowercase tuple[...] hints; drop now-unused os/dist
  imports; add a module docstring.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Port the metric-accumulation tests (accumulate/add/reset_ep_no_sync_rowwise_metrics): drop
rate + symm-buffer utilization with reduce types, and the zero-capacity ignore case. Uses a
SimpleNamespace fake block (annotated Any) so it runs on CPU.

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

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
combined_forward_ep_no_sync_rowwise: the production no-sync forward — dispatches/combines
tokens over the rowwise symmetric-memory all-to-all with on-the-wire MXFP8, runs the routed
experts, and overlaps the shared experts. Runs under the default OLMo-owned symm-mem backend.

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

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
combined_forward_ep_no_sync_tbo_rowwise and its stage pipeline: the two-batch-overlap variant
of the rowwise no-sync expert-parallel forward, overlapping one micro-batch's rowwise all-to-all
with the other's compute.

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

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
- Remove the dead env-gated debug instrumentation (_tbo_debug_* helpers + their commented
  call sites) and note the OLMO_TBO_VERBOSE_DEBUG_PRINT trace switch in the module docstring.
- Use the shared _nvtx.annotate helper (subsystem-colored ranges) with snake_case labels;
  lowercase tuple[...] / X | Y hints; drop now-unused os/dist imports.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Multi-GPU test: the rowwise no-sync EP forward produces the same output and (globally-summed)
gradients as the dropless no-EP reference, with deterministic top-k routing under a capacity that
keeps every token. The rowwise path runs on the default OLMo-owned symm-mem backend, so no env
override is needed. The rowwise-vs-sync and TBO-rowwise tests are deferred (sync EP family / the
dispatch test targets the pre-lazy-refactor block API).

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

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Per the docstring convention: add a module docstring to ep_no_sync_rowwise and docstrings to
the rowwise metric helpers and the TBO stage pipeline + its combined_forward entry point. Also
annotate down_anchor as torch.Tensor (it starts as a Parameter and is reassigned to a detached
Tensor) to fix a mypy narrowing error.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
apply_ep configures the rowwise symmetric-memory buffers and (under the default OLMo-owned
symm-mem backend) rejects the non-rowwise VDev path, so ep_no_sync_use_rowwise_all_to_all and the
nblocks must be set before apply_ep, not after.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
@AkshitaB
AkshitaB force-pushed the akshitab/moe-v2-ep-rowwise-helpers branch from 0ebc4f8 to bf5de07 Compare June 30, 2026 09:39
AkshitaB and others added 2 commits June 30, 2026 02:41
With both no-sync TBO families present, the 1d and rowwise stage functions take
different pending-context types, so aliasing them to a shared import name made
mypy report an incompatible-import (and the object-typed context failed the
rowwise arg type). Bind them through Any-typed locals instead; the runtime
family always matches the context type. No behavior change.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
… absent

The rowwise no-sync path uses the OLMo-owned symmetric-memory backend, which
needs the compiled GPU-side symm_mem_vdev2d extension. The CI image does not
build it, so the parity test errored in apply_ep with ModuleNotFoundError. Add a
requires_symm_mem_vdev2d guard (mirroring requires_grouped_gemm / requires_te)
that detects the compiled extension and skips when it is unavailable, and apply
it to the parity test. A TODO on the guard tracks rebuilding the CI image with
the extension so the test runs.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
@AkshitaB
AkshitaB merged commit 478ab8d into akshitab/moe-v2-core Jul 1, 2026
45 of 47 checks passed
@AkshitaB
AkshitaB deleted the akshitab/moe-v2-ep-rowwise-helpers branch July 1, 2026 05:21
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.

1 participant