Repository navigation
[MORI] Manage v2 CCO through the all2all manager - #6618
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
TennyWang1223
left a comment
There was a problem hiding this comment.
has_mori() only checks the top-level package. With an older MoRI (no mori.cco / dispatch_combine_v2) the manager constructs fine and fails later inside get_handle. Please gate on the v2 submodules in init.
Good catch. I’ll validate and import both mori.cco and mori.ops.dispatch_combine_v2 in MoriV2All2AllManager.init, so installations without the v2 API fail during manager construction. I’ll also add regression coverage for an older MoRI package missing these submodules. |
|
@TennyWang1223 Could you please take the primary communication review for the current head? This changes MORI v2 CCO management through the all-to-all manager, so the capability gate, handle lifetime, compatibility with the existing MORI path, and multi-GPU failure behavior need communication-owner sign-off. I will co-review the integration after your pass. For reference, my preliminary co-review found two lifecycle risks:
The added tests are CPU/mock tests; the multi-GPU job is skipped. Please include real multi-rank initialization, partial-failure cleanup, concurrent destroy, and final cleanup coverage before approval. |
|
@zufayu Thanks for the lifecycle review. I revisited the requested safeguards against the actual caller and the CCO construction contract, and narrowed the implementation in 9c4f2b4. I kept the EP-group per_rank_vmm agreement check because equal symmetric VMM capacity is a real CCO invariant. I also kept handle-before-communicator cleanup and terminal destroy semantics. A rank-0 UID error is carried in the UID broadcast itself, so it does not add another collective. I removed the full get_handle/destroy lifecycle lock and the post-construction failure all-gathers. The manager now explicitly requires collective lifecycle calls to be issued in the same order from one control thread per rank; current callers do not create handles concurrently with teardown. More importantly, adding a status all-gather to every get_handle call makes cache hits collective, while still being unable to recover a peer that is already blocked inside collective CCO/window construction. That would add a new synchronization requirement without providing reliable partial-failure recovery. The tests were reduced to match this contract: capacity disagreement, communicator creation/reuse, ordered final cleanup, and terminal destroy. The focused manager suite passes (18 tests), and Black/Ruff checks pass. Could you please take another look at the narrowed version? |
|
Thanks for narrowing the lifecycle contract — I agree with not making get_handle cache hits collective. A few remaining issues against that same contract:
|
|
@TennyWang1223 Addressed items 1 and 2 in d083f5b. MORI v2 now keeps every created handle in a manager-owned strong-reference list in creation order. The existing Cache remains responsible only for config/index lookup; a handle is appended to the ordered list only inside the cache-miss creation callback, after construction succeeds. This prevents rank-local GC from causing one rank to recreate collective CCO resources while another rank hits its cache. During teardown, handles are closed in reverse creation order before the communicator is destroyed, so collective window deregistration follows the same LIFO order on every rank. I added regression coverage that drops the caller reference and runs GC to verify the same handle remains cached, plus a two-handle teardown test that verifies handle 2 closes before handle 1 and both close before communicator destruction. The focused suite passes: 19 tests. |
aiter's MoriV2All2AllManager (ROCm/aiter#6618) owns the EP group's cco communicator and lends it through get_or_create_cco_communicator(). MegaMoE now takes it from there instead of creating and caching one of its own: - make_mori_v2_prepare_finalize hands the all2all manager to MoriV2PrepareAndFinalize, which passes it to init_mega_transport. - The capacity is asked for in full before the communicator exists: the arena's required_vmm_bytes() plus the DevComm's granule. - The communicator cannot grow, so it serves the first MegaMoE; a second, differently shaped one, or one on an aiter whose manager lends none, gets its own as before (with a warning in the first case). - close_mega_transports() closes every MegaMoE; ModelRunner.exit calls it before destroy_dist_env(), so the arenas go before the manager destroys the communicator. The recipe is built with aiter's nested ExpertComputeConfig, and the per-layer recipe check and the creation log read it from recipe.compute. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…/stage2 switches) (#2765) * feat(moe): map mega stage1/stage2_fused to aiter, add decode combine quant * feat(moe): build MegaMoE from an aiter MegaMoERecipe On an aiter that has MegaMoERecipe (ROCm/aiter#6430), init_mega_transport hands aiter a recipe instead of the stage flags: ATOM still picks the dispatch, the combine and the wires from ATOM_MEGA_STAGE1_FUSED / ATOM_MEGA_STAGE2_FUSED / MEGA_DISPATCH_WIRE / ATOM_MEGA_COMBINE_WIRE, the layer supplies the expert GEMM, and whether the pairing can run is aiter's to say. - The shared instance is keyed by (recipe, geometry). - The communicator is sized by MegaMoEGfx1250.required_vmm_bytes(recipe, geometry) -- the arena exactly -- plus the granule the DevComm created right after takes. - It is built with MegaMoEGfx1250.from_recipe, and the log and the per-layer recipe check read mega.recipe. - Each step names its combine as a wire (combine_wire=bf16|fp8|fp4); combine_quant_for_step is now combine_wire_for_step. An aiter without MegaMoERecipe keeps the flag path as it was. The Triton experts path still drives MegaMoE's _dispatch/_combine, which aiter keeps. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * refactor(moe): MegaMoE borrows the EP all2all manager's cco communicator aiter's MoriV2All2AllManager (ROCm/aiter#6618) owns the EP group's cco communicator and lends it through get_or_create_cco_communicator(). MegaMoE now takes it from there instead of creating and caching one of its own: - make_mori_v2_prepare_finalize hands the all2all manager to MoriV2PrepareAndFinalize, which passes it to init_mega_transport. - The capacity is asked for in full before the communicator exists: the arena's required_vmm_bytes() plus the DevComm's granule. - The communicator cannot grow, so it serves the first MegaMoE; a second, differently shaped one, or one on an aiter whose manager lends none, gets its own as before (with a warning in the first case). - close_mega_transports() closes every MegaMoE; ModelRunner.exit calls it before destroy_dist_env(), so the arenas go before the manager destroys the communicator. The recipe is built with aiter's nested ExpertComputeConfig, and the per-layer recipe check and the creation log read it from recipe.compute. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(moe): MegaMoE takes the MoRI v2 manager, closes cleanly; drop the v2 gather path - ATOM_MORI_V2 asks for the "mori_v2" all2all manager before anything reads .all2all_manager, so MegaMoE borrows its cco communicator; an aiter without that manager keeps the default one. - Communicators ATOM creates for MegaMoE itself are destroyed after the MegaMoE instances close; every close is attempted, and destroy_dist_env() runs even if one fails. - Remove the unreachable v2 gather transport (init_mori_v2_op and its prepare/finalize); fix the stale weight-check message. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(moe): Triton experts branch passes _recv_bound only the arena rows - MoriV2ModularKernel's triton_experts branch called _recv_bound with (topk_ids, arena_rows) and raised TypeError on its first forward. - tests/model_ops/test_mori_v2_triton_experts.py drives that branch with MegaMoE and triton_mega_moe stand-ins, no GPU. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(moe): MegaMoE review follow-ups - Layers share one MegaMoE by recipe and geometry; a layer with other Situv2 betas is refused - The borrowed communicator is tracked explicitly; each DevComm closes before its communicator, in a documented order - Ranks with different MegaMoE settings are refused at the first build - Combine-wire support is left to aiter; recipe kinds compare as enum members - The MegaMoE tests cover the recipe path and teardown, and run without aiter; the DeepSeek-V4 log example matches the new format Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(moe): MegaMoE communicators, settings check order, exit teardown - Each MegaMoE that cannot borrow the manager's communicator gets its own - The EP-rank settings check now includes the gate mode and runs before the recipe is built - ModelRunner.exit releases the dist env, CUDA graphs, KV cache and model even when a MegaMoE close fails - Tests cover the production communicator path, the check order and the exit teardown Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * refactor(moe): call the MoRI v2 all2all manager directly - moe.py asks the EP device communicator for the "mori_v2" manager directly; mori_v2_all2all_manager is gone - MegaMoE borrows the manager's cco communicator without probing for the method Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * refactor(moe): drop the pre-recipe aiter path - MegaMoE is built from a recipe only; the stage-flag path and the per-token VMM fallback are gone - The default bf16 combine wire is passed once - The Situv2 betas check compares what ATOM built with Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: yanboshao <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: JiaoliangYu <[email protected]>
Summary
mori_v2all-to-all backend whose manager owns the shared MORI CCO communicatorEpDispatchCombineOphandles while exposing the manager-owned communicator to higher-level users such as MegaMoEMotivation
MORI v2 currently brings up its CCO communicator in framework integration code. Moving that lifecycle into AITER gives the v2 backend the same explicit, demand-driven ownership model as the existing all-to-all managers.
MegaMoEGfx1250remains outside the communication manager and may only borrow the communicator; this PR does not move model or expert-GEMM configuration into the distributed layer.Testing
ruff checkon the changed implementation and testsruff format --checkon the changed Python filespytest op_tests/test_mori_v2_all2all_manager.py -q(14 passedin a CPU/mock environment)ROCm/GPU collective coverage is left to CI because the local Windows environment has no ROCm runtime.
Follow-up
After this lands, ATOM can request
get_or_create_all2all_manager("mori_v2"), useget_handle(...)for the gather path, and useget_or_create_cco_communicator(...)when constructing MegaMoE.