Repository navigation
Add expert-parallel no-sync common helpers - #738
Merged
Merged
Conversation
Capacity-drop reorder (build_keep_reorder), single-all-gather tail-drop split sync (sync_tail_drop_allowed_splits_single_a2a), and dropped-token restore+unpermute (restore_drop_unpermute_1d) shared by the no-sync expert-parallel forward paths. Co-authored-by: Tianhua Tao <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
- Guard the optional nvtx import with the _nvtx fallback so it imports without the profiling extra. - Trim the dead env-gated debug helpers (_ep_sync_debug_* + their two commented call sites) to a single labeled hook plus a note on the OLMO_TBO_VERBOSE_DEBUG_PRINT switch, matching the comm.py cleanup. Drop the now-unused os import. - Add docstrings to the public helpers (build_keep_reorder, restore_drop_unpermute_1d). Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Validate build_keep_reorder (the per-expert capacity-drop stable partition) against an independent reference for partial-drop, no-drop, and full-drop-some-experts cases, and check the reorder/inverse permutations invert each other. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
AkshitaB
force-pushed
the
akshitab/moe-v2-ep-common
branch
from
June 30, 2026 00:39
4dba0ee to
3ebbed7
Compare
Contributor
Author
|
@codex review |
Match the merged v2 leaf convention: lowercase tuple[...] / X | Y instead of typing.Tuple / Union (the file already has 'from __future__ import annotations'), and rename the build_keep_reorder / restore_drop_unpermute_1d nvtx labels to match their function names (they had a spurious leading underscore). Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Add nn/moe/v2/_nvtx.py with an annotate(label, subsystem) helper that centralizes the optional-nvtx import (the _nvtx no-op fallback) and fixes the range color per subsystem (routing=blue, experts=purple, comm=green, tbo=orange). Convert every nvtx range in the fused MoE modules (router, shared/routed experts, model, no_ep, fp8, ep_no_sync_common) to use it, so call sites pick a subsystem instead of a raw color and labels follow one scheme (qualified ClassName.method / module_function names for whole callables, snake_case phases for inner blocks). This also removes the duplicated try/except nvtx import from each module. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the shared helpers used by the no-sync expert-parallel forward paths.
What's added
nn/moe/v2/ep_no_sync_common.py:build_keep_reorder— builds the per-expert capacity-drop reorder: stably partitions routed rows into kept-then-dropped, returning the permutation, its inverse, and a keep-mask.sync_tail_drop_allowed_splits_single_a2a— agrees a global tail-drop policy across expert-parallel ranks with a single all-gather of per-rank requested token counts.restore_drop_unpermute_1d— inverts the capacity drop (scatters kept expert outputs back, zero-filling dropped rows) and unpermutes + combines for the 1D no-sync path.These operate on plain tensors / a passed-in block; the EP forward families that consume them land in follow-up changes.
Notes
nvtximport uses the_nvtxfallback so the module imports without the profiling extra.OLMO_TBO_VERBOSE_DEBUG_PRINTnote.Testing
src/test/nn/moe/v2/ep_no_sync_common_test.py(CPU): validatesbuild_keep_reorderagainst an independent reference (partial-drop, no-drop, full-drop-some-experts) and that the reorder/inverse permutations invert each other.make checksclean.🤖 Generated with Claude Code