pub struct NcclBackend { /* private fields */ }Expand description
NCCL communication backend for multi-GPU / multi-node EP.
Implementations§
Source§impl NcclBackend
impl NcclBackend
Sourcepub fn new(
rank: usize,
world_size: usize,
master_addr: &str,
master_port: u16,
stream: u64,
recv_capacity: usize,
) -> Result<Self>
pub fn new( rank: usize, world_size: usize, master_addr: &str, master_port: u16, stream: u64, recv_capacity: usize, ) -> Result<Self>
Initialize NCCL with TCP bootstrap.
Rank 0 listens on master_addr:master_port, generates a unique ID,
and sends it to all connecting ranks. All ranks then call
ncclCommInitRank which internally synchronizes.
recv_capacity is the largest all-reduce payload this backend will ever
be asked to carry, in bytes — compute it with required_recv_bytes
from the serve configuration. It is only consulted when
world_size == 2 (the send/recv fast path); other world sizes reduce
in-place via ncclAllReduce and allocate no receive buffer.
Trait Implementations§
Source§impl CommBackend for NcclBackend
impl CommBackend for NcclBackend
Source§fn all_reduce(&self, ptr: u64, bytes: usize) -> Result<()>
fn all_reduce(&self, ptr: u64, bytes: usize) -> Result<()>
All-reduce: sum across all ranks, result on all ranks.
Source§fn all_reduce_async(
&self,
ptr: u64,
bytes: usize,
compute_stream: u64,
) -> Result<()>
fn all_reduce_async( &self, ptr: u64, bytes: usize, compute_stream: u64, ) -> Result<()>
Async all-reduce using GPU-side event synchronization. Read more
Source§fn register_buffer(&self, ptr: u64, bytes: usize) -> Result<u64>
fn register_buffer(&self, ptr: u64, bytes: usize) -> Result<u64>
Pre-register a GPU buffer with the communication backend. Read more
Source§fn deregister_buffer(&self, handle: u64) -> Result<()>
fn deregister_buffer(&self, handle: u64) -> Result<()>
Deregister a previously registered buffer.
Source§fn symmetric_alloc(&self, bytes: usize) -> Result<u64>
fn symmetric_alloc(&self, bytes: usize) -> Result<u64>
Allocate a GPU buffer in NCCL’s symmetric-memory window
(NCCL ≥ 2.28 /
ncclMemAlloc). Returns the device pointer as u64. Read moreSource§fn symmetric_free(&self, ptr: u64) -> Result<()>
fn symmetric_free(&self, ptr: u64) -> Result<()>
Free a buffer previously returned by
symmetric_alloc.Source§fn set_add_kernel(&self, handle: u64)
fn set_add_kernel(&self, handle: u64)
Provide a kernel handle for the BF16 in-place addition kernel. Read more
Source§fn all_gather(&self, send_ptr: u64, recv_ptr: u64, bytes: usize) -> Result<()>
fn all_gather(&self, send_ptr: u64, recv_ptr: u64, bytes: usize) -> Result<()>
All-gather: each rank contributes a chunk, all ranks get full buffer.
Source§fn reduce_scatter(
&self,
send_ptr: u64,
recv_ptr: u64,
bytes: usize,
) -> Result<()>
fn reduce_scatter( &self, send_ptr: u64, recv_ptr: u64, bytes: usize, ) -> Result<()>
Reduce-scatter: reduce + scatter (inverse of all-gather).
Source§fn broadcast(&self, ptr: u64, bytes: usize, root: usize) -> Result<()>
fn broadcast(&self, ptr: u64, bytes: usize, root: usize) -> Result<()>
Broadcast from root rank to all ranks.
Source§fn send_to(
&self,
ptr: u64,
bytes: usize,
dest_rank: usize,
stream: u64,
) -> Result<()>
fn send_to( &self, ptr: u64, bytes: usize, dest_rank: usize, stream: u64, ) -> Result<()>
Send tokens to a specific rank (for EP token dispatch). Read more
Source§fn recv_from(
&self,
ptr: u64,
bytes: usize,
src_rank: usize,
stream: u64,
) -> Result<()>
fn recv_from( &self, ptr: u64, bytes: usize, src_rank: usize, stream: u64, ) -> Result<()>
Receive tokens from a specific rank (for EP token combine). Read more
Source§fn group_start(&self) -> Result<()>
fn group_start(&self) -> Result<()>
Begin a group of point-to-point operations (send_to/recv_from). Read more
Source§fn is_healthy(&self) -> bool
fn is_healthy(&self) -> bool
Check if the communicator is healthy (no async errors, no timeouts). Read more
Source§fn attempt_reconnect(&self) -> Result<()>
fn attempt_reconnect(&self) -> Result<()>
Attempt to recover a degraded communicator. Read more
Source§fn world_size(&self) -> usize
fn world_size(&self) -> usize
Total number of ranks.
Source§impl Drop for NcclBackend
impl Drop for NcclBackend
impl Send for NcclBackend
impl Sync for NcclBackend
Auto Trait Implementations§
impl !Freeze for NcclBackend
impl !RefUnwindSafe for NcclBackend
impl Unpin for NcclBackend
impl UnwindSafe for NcclBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more