Repository navigation
Add symmetric-memory and NCCL-RMA P2P comm kernels - #712
Merged
Merged
Conversation
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
from
June 6, 2026 01:06
b2f0b31 to
e0b1de3
Compare
AkshitaB
force-pushed
the
akshitab/moe-permute-reorder
branch
from
June 9, 2026 01:05
590b903 to
6149204
Compare
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
from
June 9, 2026 01:05
e0b1de3 to
e80566a
Compare
AkshitaB
force-pushed
the
akshitab/moe-permute-reorder
branch
from
June 9, 2026 05:16
6149204 to
23fa8cc
Compare
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
from
June 9, 2026 05:16
e80566a to
ac7aeee
Compare
AkshitaB
force-pushed
the
akshitab/moe-permute-reorder
branch
from
June 9, 2026 05:25
23fa8cc to
ee8ffee
Compare
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
from
June 9, 2026 05:25
ac7aeee to
ec04a9c
Compare
AkshitaB
force-pushed
the
akshitab/moe-permute-reorder
branch
from
June 9, 2026 05:29
ee8ffee to
e76dd17
Compare
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
from
June 9, 2026 05:29
ec04a9c to
dc52b2a
Compare
AkshitaB
force-pushed
the
akshitab/moe-permute-reorder
branch
from
June 9, 2026 05:45
e76dd17 to
52b51f8
Compare
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
from
June 9, 2026 05:45
dc52b2a to
743a5e9
Compare
AkshitaB
force-pushed
the
akshitab/moe-permute-reorder
branch
from
June 9, 2026 06:25
52b51f8 to
f8a2371
Compare
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
from
June 9, 2026 06:25
743a5e9 to
49bf190
Compare
AkshitaB
force-pushed
the
akshitab/moe-permute-reorder
branch
from
June 9, 2026 06:38
f8a2371 to
eb25f6a
Compare
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
3 times, most recently
from
June 9, 2026 07:14
962e277 to
089dd4e
Compare
Base automatically changed from
akshitab/moe-permute-reorder
to
akshitab/moe-v2-core
June 9, 2026 07:47
Three low-level comm-primitive wrappers used by the all-to-all / dispatch path:
* symm_mem_vdev2d - 2D virtual-device symmetric-memory primitives, backed by a
CMake-built NVSHMEM extension (kernels/cuda/CMakeLists.txt). The Python wrapper
loads the prebuilt _symm_mem_vdev2d_ext_gpu module lazily; the companion
build_symm_mem_vdev2d_ext.py is a CLI to build the extension AOT against a
local NVSHMEM install.
* olmo_symm_mem - thin helpers layered on symm_mem_vdev2d for setup and
group handling.
* nccl_rma_p2p - NCCL RMA-based point-to-point send/recv extension
(JIT-built via load_cuda_extension).
nvtx is guarded in symm_mem_vdev2d.py; all wrappers are import-safe on CPU.
Co-Authored-By: Akshita Bhagia <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
AkshitaB
force-pushed
the
akshitab/moe-symm-mem
branch
from
June 9, 2026 07:49
089dd4e to
d191769
Compare
- Extend LazyCudaExtension with with_cuda and a dynamic_build_kwargs hook (load-time-computed build args), and convert nccl_rma_p2p's bespoke loader to it -- the NCCL include/lib paths are discovered in the hook so the module stays import-safe without NCCL. (symm_mem_vdev2d keeps its CMake/importlib loader; olmo_symm_mem reuses it.) - Add docstrings + __all__ to the public symm-mem/RMA entry points (nccl_rma_p2p, olmo_symm_mem, symm_mem_vdev2d). The build CLI script gets docstrings but no __all__. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
run_distributed_test defaults the gloo backend to "fork", but the test
initializes CUDA in the child processes, which fails ("Cannot re-initialize
CUDA in forked subprocess"). Force start_method="spawn"; gloo stays as the
coordination PG while the RMA path uses its own NCCL communicator.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The first nccl_rma_p2p call JIT-compiles the extension. Previously only rank 0
hit that (via get_unique_id) while rank 1 waited inside broadcast_object_list,
so rank 0's slow compile stalled the collective and rank 1's gloo connection
dropped ("connection closed by peer"). Trigger the build on every rank up front
with a barrier, so the compile happens outside the collective and a genuine
build failure surfaces symmetrically with its real error.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The nccl_rma_p2p extension uses NCCL's one-sided RMA "window" API (ncclPutSignal/ncclWaitSignal/ncclWaitSignalDesc_t), present only in recent NCCL (~2.28+). The NCCL bundled with the current torch build is older, so the extension fails to compile. Skip the test with a clear reason and a note to re-enable once the kernels CI image ships a new enough NCCL. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Covers the cuda-extension loader, grouped_mm/scaled_grouped_mm, FP8 weight store, permute/reorder kernels, and the symm-mem/NCCL-RMA comm kernels. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The extension uses NCCL's one-sided RMA window API (ncclPutSignal / ncclWaitSignal), present only in recent NCCL (~2.28+). Before compiling, inspect the resolved nccl.h for those symbols and raise a clear RuntimeError (naming the found NCCL version and how to point at a newer one) instead of letting it fail deep in nvcc with "'ncclPutSignal' was not declared". The check runs at load time, so the module stays import-safe. 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.
What this adds
Symmetric-memory and NCCL-RMA point-to-point communication kernels used for expert-parallel all-to-all and RMA-based transport:
kernels/symm_mem_vdev2d.py+kernels/cuda/symm_mem_vdev2d{.cpp,_kernel.cu}— a 2D virtual-device symmetric-memory kernel, built ahead-of-time via CMake against NVSHMEM (build_symm_mem_vdev2d_ext.py+kernels/cuda/CMakeLists.txt), loaded lazily.kernels/olmo_symm_mem.py— symmetric-memory helpers built through the JIT extension loader.kernels/nccl_rma_p2p.py+kernels/cuda/nccl_rma_p2p.cpp— NCCL RMA put/signal/wait primitives, built through the JIT extension loader.All Python wrappers are CPU-import-safe; the CUDA/NVSHMEM extensions build lazily on first use.
nvtxis used only for optional profiler annotations, behind the no-op fallback.Testing
src/test/kernels/nccl_rma_p2p_test.py— a 2-GPU test (@requires_multi_gpu) that allocates an RMA window, does a bidirectionalput_signal/wait_signalexchange between two ranks, and checks the received payloads. Skips cleanly when fewer than 2 GPUs are present.The symmetric-memory (
symm_mem_vdev2d) path additionally requires a multi-GPU NVSHMEM build and is exercised by hardware tests.make checkspasses; the test skips cleanly without multiple GPUs.