mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[PR #347] Feature/sm free normal kernel #529
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#529
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/347
Author: @ZhiyiHu1999
Created: 7/31/2025
Status: 🔄 Open
Base:
antgroup-opt← Head:feature/sm_free_normal_kernel📝 Commits (9)
971ee33First version of SM Free Normal Kernel for Internode Dispatch/Combine26f06acaddress conflicts due to TMA in Combine kNVLAndRDMAForwarder2f93b35remove duplicate codes due to faults in addressing conflictsdc79091minor modifications and add an annotation83e27a2minor modificationa5782dcminor modificationsafa77d3minor modifications5e4093bminor modifications0b1ccdeadd arg return_recv_hook for get_dispatch_layout, so the kernel will be on compute stream in hook mode📊 Changes
12 files changed (+1515 additions, -535 deletions)
View changed files
➖
.github/workflows/format.yml(+0 -28)📝
csrc/config.hpp(+61 -10)📝
csrc/deep_ep.cpp(+185 -117)📝
csrc/deep_ep.hpp(+15 -9)📝
csrc/kernels/api.cuh(+21 -8)📝
csrc/kernels/buffer.cuh(+10 -10)📝
csrc/kernels/configs.cuh(+2 -0)📝
csrc/kernels/internode.cu(+353 -321)📝
csrc/kernels/utils.cuh(+279 -0)📝
deep_ep/buffer.py(+52 -27)📝
tests/test_internode.py(+5 -5)➕
tests/test_internode_hook.py(+532 -0)📄 Description
1. Motivation
In MOE training and the prefilling phase of inference, the current ring-based RDMA buffer implementation for normal kernels significantly wastes SM resources. Due to the small size of the ring buffer and its frequent reuse for token transmission, SMs are often stalled, continuously polling for RDMA buffer availability instead of performing useful computation. This inefficient resource usage severely limits overall system throughput.
To address this issue, this PR implements a SM-friendly buffer design that frees SMs from buffer polling duties. This design is inspired by the large RDMA buffer approach discussed in #39. By allocating a larger RDMA buffer in HBM, tokens can be moved from SMs to the RDMA buffer in one go. While the NIC handles transmission asynchronously in the background, SMs can immediately resume computation tasks. Once data transfer completes, SMs can process the received tokens without blocking.
2. Design
2.1. Feature
The SM Free mode decouples the execution phases of the native mode: when the user first launches internode dispatch/combine, only the send phase is executed and a recv hook is returned. The user can wait for the network transmission to complete and then launch the receive phase of the internode dispatch/combine using the recv hook.
Implementation
2.2.1. Principles
2.2.2. Highlights
return_recv_hook: Introduces a user-controllable argumentreturn_recv_hookto switch between native mode and hook mode.get_normal_hook_rdma_size_hint()to help users estimate the minimum required RDMA buffer size.3. Performance Evaluation
3.1. Experiment Setup
3.2. Effect
3.2.1. Estimated Performance (native mode → hook mode)
Dispatch Kernel Execution Time & Bandwidth
Kernel Execution Time
RDMA Bandwidth
Kernel Execution Time
RDMA Bandwidth
Combine Kernel Execution Time & Bandwidth
Kernel Execution Time
RDMA Bandwidth
3.3. Cost
3.3.1. HBM Cost
The main HBM cost in hook mode comes from two sides:
RDMA Buffer:
rdma_buffer_size = num_max_dispatch_tokens_per_rank × hidden_size × size_of(element) × num_nodes × 2
The HBM cost from using the large RDMA buffer increases with
num_max_dispatch_tokens_per_rankandnum_nodes; for our experiment setup, the HBM cost for the RDMA buffer on each rank is about 270 MB.NVLink Buffer:
nvl_buffer_size = num_max_nvl_chunked_recv_tokens × hidden_size × size_of(element) × num_nvl_peers × num_channels
HBM used for NVLink buffer increased with the number of SMs (channels) in the hook mode, but the number of tokens assigned to each channel is smaller, so the
nvl_recv_chunkcould be shrunk and the overall HBM cost for this part changed slightly.3.3.2. Bandwidth Cost
For SM Free mode, the data movement in the recv phase of dispatch and the send phase of combine are inter-GPU through NVLink. So the respective kernel execution time is also limited by the NVLink bandwidth.
4. RoadMap
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.