vllm.distributed.pp_transport.copy_engine
¶
PP transport on CUDA copy engines, synchronized on the GPU (one NVLink domain).
Each rank shares one buffer holding its flags and a receive region laid out like its persistent intermediate tensors. Per stage boundary, step N:
- sender: once the previous peer copy is done, pack the outputs into a local
send buffer; on a side stream, wait
empty >= N - 1, peer-copy into the receiver's region and writefull = N. - receiver: wait
full >= N, copy the region into the persistent tensors and writeempty = N.
Each flag lives on the GPU that waits on it and the peer writes it with stream memory ops, so neither SMs nor the CPU wait on the transfer. Metadata goes over the CPU group.
The waits omit CU_STREAM_WAIT_VALUE_FLUSH, which x86 hosts do not support. As in NCCL's zero-SM copy-engine path, this relies on NVLink delivering the peer copy before the flag write that follows it, so all PP GPUs must be NVLink peers.
With TP or PCP > 1, each (PCP, TP) position's PP chain is its own transport, sending to the same position in the next stage: a stage's TP ranks hold the same outputs and each sends all of them, and each PCP rank sends its own tokens.
The platform's flag ops and peer copy come from _CudaCopyEngines, or on ROCm
(gfx950) from rocm_sdma.SdmaCopyEngines, which uses HIP's stream memory ops
and SDMA engines.
A chain on one node shares its receive buffers through CUDA (or HIP) IPC. A chain that spans nodes (multi-node NVLink, e.g. GB200/GB300 NVL72; CUDA only) shares them through FABRIC handles, which need an IMEX channel; mapping a peer's FABRIC memory only succeeds within its NVLink domain. Stream memory ops cannot write another node's memory, so there a flag is written to local staging and peer-copied, after the data on the same stream.
Classes:
-
CopyEngineTransport– -
CopyEngineUnavailable–Copy engines are not usable. Raised on every rank alike.
CopyEngineTransport
¶
Bases: PPTransport
Methods:
-
__init__–Collective over the PP, TP and PCP groups. Raises
CopyEngineUnavailable -
recv–This step's tensors, as views of the persistent tensors. The wait
__init__(vllm_config, pp_group, persistent)
¶
Collective over the PP, TP and PCP groups. Raises CopyEngineUnavailable
on every rank alike, with nothing left allocated, if copy engines are
not usable on some rank.
recv(pp_group)
¶
This step's tensors, as views of the persistent tensors. The wait
for the previous stage and the copy are queued on the current stream
when .tensors is first read, so GPU work queued before then (input
preparation) overlaps the transfer, as with NCCL.
CopyEngineUnavailable
¶
Bases: RuntimeError
Copy engines are not usable. Raised on every rank alike.
_CudaCopyEngines
¶
CUDA's flag ops (stream memory ops) and, for a sender, its peer copy to the next stage (memcpys on copy engines).
Methods:
-
__init__–words: this rank's shared-buffer bytes for the staging offull -
copy–Queue on
streamthe copy of each key's firstrowsrows into the -
write_remote_flag–As
write_flag, foraddron another node, which stream memory ops
__init__(send_buf, peer_recv_buf, peer_full, words, peer_pci, cross_node)
¶
words: this rank's shared-buffer bytes for the staging of full
when the peer is on another node (cross_node); peer_pci is for SDMA
and unused here.
copy(stream, layout, rows, seq)
¶
Queue on stream the copy of each key's first rows rows into the
peer's receive region, then the write of full = seq.
write_remote_flag(stream, addr, value, staging)
classmethod
¶
As write_flag, for addr on another node, which stream memory ops
cannot write: through staging (local) and a peer copy.
_Region
¶
_fabric_map(handle, size)
¶
Map a cuMem allocation for this GPU to a new address.
_fabric_open(handle, nbytes)
¶
As _ipc_open, for a buffer from _fabric_share.
_fabric_share(nbytes)
¶
As _ipc_share, through a FABRIC handle.
_ipc_share(nbytes)
¶
A zeroed buffer on this GPU: its pointer, the handle a peer opens it with, and its release.
_views(buf, layout, rows)
¶
The first rows[key] rows of each key's region of buf.