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
Source code in vllm/distributed/pp_transport/copy_engine.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
__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.
Source code in vllm/distributed/pp_transport/copy_engine.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
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.
Source code in vllm/distributed/pp_transport/copy_engine.py
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
Source code in vllm/distributed/pp_transport/copy_engine.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
__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.
Source code in vllm/distributed/pp_transport/copy_engine.py
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.
Source code in vllm/distributed/pp_transport/copy_engine.py
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.
Source code in vllm/distributed/pp_transport/copy_engine.py
_Region
¶
Bases: NamedTuple
One tensor's region in a send or receive buffer.
Source code in vllm/distributed/pp_transport/copy_engine.py
_fabric_map(handle, size)
¶
Map a cuMem allocation for this GPU to a new address.
Source code in vllm/distributed/pp_transport/copy_engine.py
_fabric_open(handle, nbytes)
¶
As _ipc_open, for a buffer from _fabric_share.
Source code in vllm/distributed/pp_transport/copy_engine.py
_fabric_share(nbytes)
¶
As _ipc_share, through a FABRIC handle.
Source code in vllm/distributed/pp_transport/copy_engine.py
_ipc_share(nbytes)
¶
A zeroed buffer on this GPU: its pointer, the handle a peer opens it with, and its release.
Source code in vllm/distributed/pp_transport/copy_engine.py
_views(buf, layout, rows)
¶
The first rows[key] rows of each key's region of buf.