Feature/sm free normal kernel#347
Draft
ZhiyiHu1999 wants to merge 9 commits into
Draft
Conversation
ZhiyiHu1999
marked this pull request as draft
July 31, 2025 07:05
ZhiyiHu1999
marked this pull request as ready for review
August 1, 2025 12:30
Contributor
Maybe you mean "num_gpus_per_node"? |
Collaborator
|
The original implementation allows NVLink and RDMA transfers to be pipelined, enabling us to utilize both NVLink and RDMA bandwidth simultaneously. I think it is worthwhile to dedicate some SMs for this purpose. |
ZhiyiHu1999
force-pushed
the
feature/sm_free_normal_kernel
branch
from
August 29, 2025 02:10
afcd1aa to
3676f96
Compare
ZhiyiHu1999
force-pushed
the
feature/sm_free_normal_kernel
branch
from
September 11, 2025 09:42
3676f96 to
a35f83b
Compare
ZhiyiHu1999
force-pushed
the
feature/sm_free_normal_kernel
branch
from
November 8, 2025 16:28
f3df4f1 to
7ab53e3
Compare
…be on compute stream in hook mode
ZhiyiHu1999
force-pushed
the
feature/sm_free_normal_kernel
branch
from
November 8, 2025 16:33
7ab53e3 to
0b1ccde
Compare
ZhiyiHu1999
marked this pull request as draft
November 10, 2025 11:56
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.
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