mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[PR #521] Add NCCL Communication Backend for DeepEP #607
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepEP#607
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepEP/pull/521
Author: @aamirshafi
Created: 12/15/2025
Status: 🔄 Open
Base:
main← Head:nccl📝 Commits (10+)
2527ce7Support cuMem API in cross process shared memory management (#217)57d82f6Enable CUDA Graph for internode dispatch (#438)7ffa208Update README.me for Hybrid-EP Experimental Branche (#502)4cd23f0Update README for an experimental optimization branch (#512)10d110afix: Support multiple PyTorch distributed backendsb15f9a0Added NCCL GIN backend (only able to run init/finalize).90f30bdadding support for LL dispatch. this is WIP.079463dUpdating the scripts to work with slurmb02cc43Changing the scripts to run with MPI6b1b49bChanging the NCCL-GIN backend to enable the use of the high-level API. Removed redundant/dead code.📊 Changes
22 files changed (+2862 additions, -106 deletions)
View changed files
➕
README-NCCL.md(+168 -0)📝
csrc/config.hpp(+38 -2)📝
csrc/deep_ep.cpp(+48 -20)📝
csrc/deep_ep.hpp(+5 -1)📝
csrc/kernels/api.cuh(+24 -4)➕
csrc/kernels/backend_factory.cpp(+113 -0)➕
csrc/kernels/backend_factory.h(+14 -0)➕
csrc/kernels/communication_backend.h(+131 -0)📝
csrc/kernels/configs.cuh(+8 -1)📝
csrc/kernels/exception.cuh(+1 -0)📝
csrc/kernels/ibgda_device.cuh(+1 -0)📝
csrc/kernels/internode.cu(+771 -19)📝
csrc/kernels/internode_ll.cu(+583 -11)➕
csrc/kernels/nccl_gin_backend.cu(+461 -0)➕
csrc/kernels/nccl_gin_backend.h(+101 -0)📝
csrc/kernels/runtime.cu(+140 -7)📝
deep_ep/buffer.py(+20 -1)📝
setup.py(+49 -15)📝
tests/test_internode.py(+61 -9)📝
tests/test_intranode.py(+4 -4)...and 2 more files
📄 Description
Summary
This PR adds NCCL as an additional communication backend for DeepEP, leveraging NCCL's Device API for GPU-initiated
network operations. The integration introduces a
CommunicationBackendabstraction that allows users to use NVSHMEM orNCCL as communication backend. This enables users to select their preferred backend based on deployment requirements.
Build/Runtime Selection of NVSHMEM and NCCL Backends
Both backends are fully supported and can be selected at build/runtime:
NVSHMEM_DIR=/path/to/nvshmemENABLE_NCCL=1 NCCL_DIR=/path/to/ncclDEEP_EP_BACKEND=ncclWhy Support Both NVSHMEM and NCCL Backends:
Unchanged Buffer Interface
The
Bufferclass interface exported to AI frameworks remains completely unchanged. This means:dispatch(),combine(),low_latency_dispatch(), andlow_latency_combine()APIs work transparently with either backendCommunication Backend Interface
We introduce an abstract
CommunicationBackendinterface that decouples DeepEP kernels from the underlying communication library:Backend Selection:
NCCL Backend Integration
The NCCL backend uses the Device API for GPU-initiated network operations (GIN), translating between NVSHMEM's PGAS model and NCCL's window-based model:
put_nbi(dst_ptr, src_ptr, count, pe)put(peer, dstWin, dstOff, srcWin, srcOff, bytes)signal(),readSignal())quiet()flush()Key Integration Challenges:
Multi-Communicator Mapping: Each NCCL GIN context wraps a Queue Pair (QP), and NCCL provides 4 GIN contexts per communicator. DeepEP's QP requirements are met using ⌈QPs/4⌉ communicators:
Memory Registration: Buffers registered with all communicators; window handles stored in GPU memory for kernel access.
Signal-Based Synchronization: Pre-allocated signal layouts map memory atomics to NCCL signal primitives.
Semantic Preservation: Zero-byte
put()withSignalAddis semantically equivalent tonet.signal()but better performing in the current NCCL release.NCCL GIN Type Selection
For GPU-initiated network operations, NCCL supports multiple backends:
NCCL_GIN_TYPE23Performance Results
Benchmarked on H100 (900 GB/s NVLink) with 8×400 Gbit/s InfiniBand (~50 GB/s per NIC).
High-Throughput Kernels
4096 tokens, 7168 hidden, top-8 experts, BF16 dispatch, BF16 combine
Low-Latency Kernels
128 tokens, 7168 hidden, top-8 experts, FP8 dispatch, BF16 combine
Requirements
Tested configurations:
Usage
Future Work
Reduce Communicator Count: Currently, we initialize multiple NCCL communicators due to the limitation of 4 GIN contexts per communicator. Work is in progress on the NCCL roadmap to increase the number of GIN contexts per communicator, which will simplify the integration.
Unified Backend Interface for NVSHMEM: The current NVSHMEM code does not follow the
CommunicationBackendinterface in order to stay close to the upstream DeepEP main branch. Migrating NVSHMEM to use this interface should be addressed in consultation with DeepEP maintainers.References
📄 Paper: GPU-Initiated Networking for NCCL
🔗 NCCL Repository: https://github.com/NVIDIA/nccl
📄 NCCL README: NCCL README
Co-authored with @grtheod.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.