-
Notifications
You must be signed in to change notification settings - Fork 1k
Feature/sm free normal kernel #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: antgroup-opt
Are you sure you want to change the base?
Feature/sm free normal kernel #347
Conversation
Maybe you mean "num_gpus_per_node"? |
|
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. |
afcd1aa to
3676f96
Compare
3676f96 to
a35f83b
Compare
f3df4f1 to
7ab53e3
Compare
…be on compute stream in hook mode
7ab53e3 to
0b1ccde
Compare
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