Skip to content

Add the 1D no-sync two-batch-overlap forward - #741

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

AkshitaB merged 6 commits into
akshitab/moe-v2-corefrom
akshitab/moe-v2-ep-tbo-1d

Conversation

@AkshitaB

Copy link
Copy Markdown
Contributor

Adds the two-batch-overlap (TBO) variant of the 1D no-sync expert-parallel forward.

What's added

nn/moe/v2/ep_no_sync_tbo_1d.py — combined_forward_ep_no_sync_tbo and its stage pipeline (ep_no_sync_stage_a / stage_c_launch / stage_d_launch / stage_e / stage_tail, plus the _NoSyncTboPendingContext carried between stages). It splits a micro-batch into two halves and overlaps one half's symmetric-memory all-to-all with the other half's compute. Driven by the model's forward_tbo / _tbo_last_step (which lazy-import it).

Depends only on the comm transport, the no-sync common helpers, and the symmetric-memory buffer pool (all on moe-v2-core).

Notes

  • nvtx ranges use the shared _nvtx.annotate(label, subsystem) helper.

Testing

The applicable dev test (v2_tbo_test.py, no-sync variant — TBO output must match the non-TBO no-sync forward) compares against the non-TBO combined_forward_ep_no_sync_1d, so it lands once that forward (ep_no_sync_1d) is on the branch. The sync-TBO variant needs the sync EP family. Both are multi-GPU.

🤖 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 2 commits June 30, 2026 00:53
combined_forward_ep_no_sync_tbo and its stage pipeline (stage_a / stage_c_launch /
stage_d_launch / stage_e / stage_tail): the two-batch-overlap variant of the 1D no-sync
expert-parallel forward, overlapping one micro-batch's all-to-all with the other's compute over
the symmetric-memory transport.

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

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
- Use the shared _nvtx.annotate helper (subsystem-colored ranges) instead of raw nvtx;
  snake_case the range labels and normalize colors to the subsystem scheme (routed-experts ->
  experts, attn+router -> routing, TBO stages -> tbo).
- Use lowercase tuple[...] / X | Y type hints.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
@AkshitaB
AkshitaB force-pushed the akshitab/moe-v2-ep-tbo-1d branch from 25d9ab0 to 56cdc13 Compare June 30, 2026 07:53
AkshitaB and others added 3 commits June 30, 2026 00:57
Multi-GPU test asserting the two-batch-overlap no-sync forward produces the same loss and
gradients as the non-TBO no-sync forward (ep_no_sync_1d, now on core). Ported from the dev branch;
sets OLMO_USE_OWN_SYMM_MEM=0 (the VDev-1d machinery uses the legacy symm-mem backend) and installs
a deterministic top-k router via routed_experts_router.forward (the dev test patched a no-longer-
present block.router_forward). The sync-EP TBO variant is deferred until the sync EP family lands.

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

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
MoEFusedV2TransformerBlockConfig takes one layer_norm (it builds both attention and
feed-forward norms from it), not the attention_norm/feed_forward_norm split the dev config used.
Passing the split fields was an unexpected-keyword mypy error (and would fail at runtime).

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
model.forward_tbo calls block.combined_forward_ep_tbo unconditionally, which
imported the (not-yet-landed) ep_sync_tbo module before any sync/no-sync
dispatch could run, so no-sync TBO models failed with ModuleNotFoundError. The
dev branch makes this dispatch inside ep_sync_tbo.combined_forward_ep_tbo;
hoist it to the block method so the no-sync path routes to
combined_forward_ep_no_sync_tbo without importing the sync module, and the
sync import stays deferred to the sync branch.

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-tbo-1d branch from 5affee1 to d3bcde6 Compare June 30, 2026 08:52
_tbo_last_step eagerly imported both no-sync TBO families (ep_no_sync_tbo_1d
and ep_no_sync_tbo_rowwise) at the top of the function to drive isinstance
dispatch, so a model running the VDev-1d no-sync TBO path still required the
rowwise module to be importable and failed with ModuleNotFoundError when it was
absent. Dispatch on the producing block's ep_no_sync_use_rowwise_all_to_all flag
instead (it already selects the family in combined_forward_ep_no_sync_tbo) and
import only the family in use, matching the lazy-dispatch convention the rest of
block/model already follow.

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-tbo-1d branch from 04d6007 to bfa3978 Compare June 30, 2026 09:12
@AkshitaB
AkshitaB merged commit e9407ef into akshitab/moe-v2-core Jun 30, 2026
46 of 47 checks passed
@AkshitaB
AkshitaB deleted the akshitab/moe-v2-ep-tbo-1d branch June 30, 2026 09:36
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