vllm.distributed.device_communicators.cuda_communicator
¶
Classes:
CudaCommunicator
¶
Bases: DeviceCommunicatorBase
Methods:
-
broadcast–Broadcast a tensor from source rank to all ranks.
-
combine–Combine the hidden states and router logits from the appropriate device.
-
dispatch–Dispatch the hidden states and topk weights/ids to the appropriate device.
-
dispatch_router_logits–Dispatch the hidden states and router logits to the appropriate device.
-
recv–Receives a tensor from the source rank.
-
send–Sends a tensor to the destination rank in a blocking way.
_all_gather_batched_symm_mem(inputs)
¶
AllGather a list of tensors using NCCL symmetric memory (NVLS).
Uses group_start/group_end to batch the collectives. Only the output needs to be in symmetric memory (see _all_gather_symm_mem).
_all_gather_symm_mem(input_)
¶
AllGather a single tensor using NCCL symmetric memory (NVLS).
Only the output needs to be in symmetric memory; NCCL does not require the AG input to be symmetrically allocated.
_can_use_aiter_ag_rs(sizes)
¶
Whether the AITER custom AG/RS fast path may run for this collective.
Requires: - uniform batches - FULL CUDAgraphs
_get_symm_scratch(role, shape, dtype, device)
¶
Persistent, pre-registered NCCL symmetric-memory scratch buffer.
Allocating a fresh symm tensor per collective pays the
nccl_symm_mem_context snapshot + window-registration scan on every
call (~0.5 ms/RS+AG pair, dwarfing the NVLS transfer itself). Instead,
each (role, shape[1:], dtype, device) keeps a geometric high-water
allocation and returns a leading slice. Superseded allocations remain
referenced because a captured CUDA graph may still use their pointers;
geometric growth bounds their total capacity to less than twice the
current allocation.
These buffers are internal scratch. Returning one would let a later collective with the same cache key overwrite an earlier live result. MoE combines may reuse scratch when the producer and collective are ordered on the same stream. DBO microbatches use distinct cache entries.
_log_all_reduce_backend_selection()
¶
Log the all-reduce backends that are active for this group.
The dispatch chain in all_reduce tries backends in this order and
falls through to the next one if the current backend rejects the
input (size/dtype gates) or is disabled. The list of "enabled"
backends below is the subset of potential backends that may be
chosen at dispatch time for this group; the actual per-call choice
depends on the input tensor.
_reduce_scatter_symm_mem(input_tensor, output=None)
¶
ReduceScatter using NCCL symmetric memory (NVLS).
The MoE reduce_scatterv path passes explicit uniform sizes and calls this only with an already-registered input, so that path never stages. Uniform calls without a caller-owned output retain their existing opt-in behavior and stage ordinary input into registered scratch. The output may be ordinary memory.
broadcast(tensor, src=0)
¶
Broadcast a tensor from source rank to all ranks.
combine(hidden_states, is_sequence_parallel=False)
¶
Combine the hidden states and router logits from the appropriate device. This is a no-op in the base class.
dispatch(hidden_states, topk_weights, topk_ids, is_sequence_parallel=False, extra_tensors=None)
¶
Dispatch the hidden states and topk weights/ids to the appropriate device. This is a no-op in the base class.
dispatch_router_logits(hidden_states, router_logits, is_sequence_parallel=False, extra_tensors=None)
¶
Dispatch the hidden states and router logits to the appropriate device. This is a no-op in the base class.
recv(size, dtype, src=None)
¶
Receives a tensor from the source rank.
send(tensor, dst=None)
¶
Sends a tensor to the destination rank in a blocking way.