Repository navigation
[PG][3/N] Add OneShot AllReduce and decouple algorithms from protocols - #4372
Conversation
bff86ca to
8b078cb
Compare
8b078cb to
8650fd6
Compare
8650fd6 to
2bdcef3
Compare
2bdcef3 to
3d0fa1f
Compare
3d0fa1f to
f86d698
Compare
|
@niwehao Could you take a look? |
|
Hi! Thanks for the PR! The PR looks great. Just one question: OneShot selection checks native atomic capability, but does it also account for P2P mapping failures? If a peer falls back to HostProxy, Relevant code: |
Thanks for pointing this out. The eligibility check in this PR uses hardware native-atomic capability and does not account for P2P mapping failures. This is addressed in #4791 (5/N), building on the coordinated endpoint installation introduced in #4575 (4/N). Under that change, ranks report their actual installed route capabilities. Automatic selection enables OneShot only when every directed pair of active ranks has a directly addressable route with native atomics; otherwise, Ring is selected. Given that backporting this logic into this PR is non-trivial and downstream PRs (#4747, #5099) already build on this base, would it make sense to leave route-aware selection to 5/N? Happy to hear your thoughts! |
Good, leaving this to to 5/N is good idea! I have no more question about this PR. @yuechen-sys |
Description
Part of #3483 (Phase 2), stacked on #3914.
This PR introduces a low-latency One-shot AllReduce path for small GPU messages and decouples collective algorithms from protocols.
Key changes
Decoupling of algorithm and protocol
The initial framework (#3484) tightly coupled the collective algorithm with the synchronization protocol, making future algorithm additions intrusive and difficult to maintain.
This PR separates them conceptually:
Note on current state: The decoupling in this PR is not yet 100% complete -- the current
Simpleimplementation retains some assumptions fromRing, andLLis similarly tailored toOne-shot. This is an intentional choice: I think refining abstraction boundaries when new algorithms introduce concrete requirements is better than prematurely generalizing protocols in this PR.One-shot data path
The One-shot path is designed to minimize latency for small AllReduce messages by writing tagged packets directly into peer-accessible GPU buffers, followed by local reduction.
In the hot path, cross-rank handshakes for buffer readiness and slot consumption are eliminated by combining dedicated per-communicator packet storage, a two-slot alternating buffer, and sequence tags. Minimal synchronization remains: receivers poll on packet tags, StrongStream preserves invocation order, and the multi-CTA path retains its startup and completion bookkeeping. LL reset barriers are deferred to cold path -- triggered only when the group view changed or when a tag reuse happened.
Resource ownership
The process-wide PG context owns the shared payload workspace. Per-communicator LL packet and signal allocations belong to an algorithm or protocol and scale with
max_group_size.To limit memory use, allocations are scoped as follows:
OneShotAllReduceAlgorithmper communicator, with capacity proportional tomax_group_size.max_group_size.Example logical resource usage
Consider a single process using one PG context with two communicators of
max_group_size = 4and two ofmax_group_size = 8, all with LL and One-shot resources allocated.These are logical slice sizes within DTS's peer-accessible region. Each PG context eagerly allocates 96 MiB: 32 MiB for the shared payload buffer and 64 MiB reserved for communicator resources, including the signals and One-shot packets above. A separate 32 MiB local staging region is allocated on demand.
Supported scope and limitations
MOONCAKE_PG_PREFERRED_GPU_COLLECTIVE_BACKEND=new; legacy remains the default.MOONCAKE_PG_COLLECTIVE_ALGORITHMacceptsauto(default),ring, oroneshot. The Coordinator reads it at startup and publishes one policy for all ranks in each group.ringselects Ring;oneshotremoves the size threshold while retaining hardware eligibility checks, with Ring as the fallback.Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Benchmark
As in PR #3484, this benchmark uses a minimal nccl-tests shim for Mooncake PG that forwards the required NCCL AllReduce API to the Mooncake PG C API. This avoids Python/PyTorch dispatch overhead and allows PG and NCCL to run under the same
nccl-testsharness.The sweep compares five execution modes on a single node of 8 × NVIDIA H20:
MOONCAKE_PG_COLLECTIVE_ALGORITHM=ring.MOONCAKE_PG_COLLECTIVE_ALGORITHM=oneshot.-R 0).-R 2), with NCCL selecting the symmetric kernel automatically.All five modes use float32 SUM, 50 warmup iterations, 500 measured iterations, and CUDA Graphs (
-G 10). The plot shows in-place latency, taking the median of three benchmark cycles (-N 3); lower is better.OneShot LL substantially reduces small-message latency compared with PG Ring Simple and PG Legacy, approaching NCCL symmetric at the smallest sizes.
Raw Results
Checklist
./scripts/code_format.shAI Assistance Disclosure
Codex was used to assist in designing and implementing this PR. All code and architectural changes have been thoroughly reviewed and verified by me in person.