vllm.distributed.weight_transfer.nccl_engine
¶
NCCL-based (dense) weight transfer engine.
Classes:
-
NCCLTrainerInitInfo–Trainer-side init info for the dense NCCL weight transfer backend.
-
NCCLTrainerWeightTransferEngine–Trainer-side NCCL weight transfer engine.
-
NCCLWeightTransferEngine–Weight transfer engine using NCCL for communication between trainer and workers.
-
NCCLWeightTransferInitInfo–Worker-side initialization info for NCCL-based weight transfer backends.
-
NCCLWeightTransferUpdateInfo–Per-round update info for the dense NCCL weight transfer backend.
NCCLTrainerInitInfo
dataclass
¶
Bases: TrainerInitInfo
Trainer-side init info for the dense NCCL weight transfer backend.
The sender opens its endpoint as NCCL rank 0, so it needs no rank_offset.
rank (from TrainerInitInfo) identifies this trainer process.
The trainer joins over a TCPStore rendezvous (master_address +
master_port). Torch-free trainers (e.g. JAX) that cannot join a TCPStore
mint an ncclUniqueId themselves and drive rank 0 out of band; they ship a
nccl_unique_id_b64 payload straight to the inference workers'
init_weight_transfer_engine (see NCCLWeightTransferInitInfo) rather than
going through this engine.
packed / buffer sizes are the transfer's wire params. The trainer
propagates them to the worker at trainer_init so the two sides cannot
disagree. Note this defaults to packed, unlike the worker-side
NCCLWeightTransferInitInfo, whose default only applies when no trainer
ships a value. backend is the factory dispatch key.
Attributes:
-
world_size(int) –Transfer group size: rank 0 and each distinct
ParamMeta.owners[0], plus
Source code in vllm/distributed/weight_transfer/nccl_engine.py
world_size
instance-attribute
¶
Transfer group size: rank 0 and each distinct ParamMeta.owners[0], plus
the inference workers (1 + num_workers for a single sender).
NCCLTrainerWeightTransferEngine
¶
Bases: TrainerWeightTransferEngine[NCCLTrainerInitInfo]
Trainer-side NCCL weight transfer engine.
Each parameter is broadcast by its first owner (rank 0 when unset); rank 0
also drives the client RPCs. See "Broadcasting ranks" in nccl.md.
Other trainer ranks hold no communicator and only drive iter_full() to
stay in the trainer-side gathers (e.g. FSDP full_tensor()).
packed / buffer sizes come from NCCLTrainerInitInfo; the sender
propagates them to the worker at trainer_init (on the worker-side init
info), so per-round payloads carry only parameter metadata.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 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 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
_broadcast(meta, src)
¶
Broadcast meta from group rank src: that rank sends from
iter_full(), every other group member receives and discards.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
_broadcast_plan(meta)
staticmethod
¶
The transfer group's trainer ranks, in group-rank order, and each broadcaster's parameters (in metadata order), in broadcaster order.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
_checked_iter(source, meta)
staticmethod
¶
Yield the sender's pairs, checking each against what the worker was told to expect.
The worker sizes its receive buffers — and in packed mode cuts its chunk
boundaries — from the update info, which is built from metadata. If
iteration disagrees with it, the two sides split the stream differently
and the transfer hangs in NCCL or loads garbage. Checking here costs one
comparison per parameter and turns that into an error naming the first
divergent parameter.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
_discard(meta, src)
¶
Receive another broadcaster's parameters and drop them.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
_post_send_sync()
¶
Wait for this rank's transfer work to land before returning.
Broadcasts are only enqueued by send_weights: the unpacked path on
the current stream, the packed path on the producer's own streams (which
it drains itself). Waiting here lets a caller mutate parameters, or
start the next step on another stream, as soon as send_weights
returns, instead of silently depending on same-stream ordering. Every
rank waits: a non-sender's full_tensor() gathers feed the sender's
broadcast, so they must have landed before it may touch its shards.
Unlike IPC there is no cross-rank barrier here. Nothing in this backend outlives the collective it travelled in (IPC's barrier keeps shared buffers alive until every consumer has opened them), so a barrier would only add a dependency on the default process group that this backend otherwise does not have.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
_send_update(meta, src, reuse)
¶
Rank 0's part of one broadcaster's turn: run its update_weights
concurrently with _broadcast.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
NCCLWeightTransferEngine
¶
Bases: WeightTransferEngine[NCCLWeightTransferInitInfo, NCCLWeightTransferUpdateInfo]
Weight transfer engine using NCCL for communication between trainer and workers.
Receives dense checkpoint-format weights broadcast from the trainer ranks
below rank_offset and loads them with the layerwise reload lifecycle.
Methods:
-
finish_weight_update–Finalize layerwise reloading after all weights have been received.
-
init_transfer_engine–Initialize NCCL process group with the trainer and record the
-
receive_weights–Receive weights from trainer via NCCL broadcast.
-
start_weight_update–Initialize layerwise reloading for the incoming checkpoint weights.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
115 116 117 118 119 120 121 122 123 124 125 126 127 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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
finish_weight_update()
¶
Finalize layerwise reloading after all weights have been received.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
init_transfer_engine(init_info)
¶
Initialize NCCL process group with the trainer and record the trainer-supplied wire params so the worker decodes exactly as the trainer encodes.
Parameters:
-
(init_info¶NCCLWeightTransferInitInfo) –NCCL initialization info containing master address, port, rank offset, world size, and the packed wire params
Source code in vllm/distributed/weight_transfer/nccl_engine.py
receive_weights(update_info)
¶
Receive weights from trainer via NCCL broadcast.
Whether to use packed broadcasting (and the buffer geometry) is read
from self.packed / self.packed_*, set at the init handshake from the
trainer's init info, so it is guaranteed to match how the trainer
encoded.
Parameters:
-
(update_info¶NCCLWeightTransferUpdateInfo) –Parameter names, dtypes, shapes and
src; empty lists reuse the previous call's from the samesrc
Source code in vllm/distributed/weight_transfer/nccl_engine.py
start_weight_update()
¶
Initialize layerwise reloading for the incoming checkpoint weights.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
NCCLWeightTransferInitInfo
dataclass
¶
Bases: WeightTransferInitInfo
Worker-side initialization info for NCCL-based weight transfer backends.
Keyword-only (kw_only): adding the optional nccl_unique_id_b64 field
means the rendezvous fields can no longer keep a fixed positional slot, so a
stale positional call fails loudly instead of silently swapping arguments.
Provide exactly one rendezvous mode:
master_address+master_port-- TCPStore /StatelessProcessGrouprendezvous (requires torch on every rank, including the trainer), ornccl_unique_id_b64-- standard (RFC 4648, not URL-safe) base64 of the 128 raw bytes fromncclGetUniqueId, for torch-free trainers (e.g. JAX) that mint the unique id out of band and share it (over HTTP, etc.). Note a JAX peer must usebase64.b64encode, noturlsafe_b64encode.
On the unique-id path all ranks must enter init concurrently (there is no
store barrier), and every peer must honor the warm-up handshake: the
worker's communicator issues a one-element all_reduce immediately after
ncclCommInitRank (see PyNcclCommunicator.from_unique_id_bytes), so a
foreign peer must issue a matching one-element all_reduce before any
other collective or all ranks deadlock.
Source code in vllm/distributed/weight_transfer/nccl_common.py
NCCLWeightTransferUpdateInfo
dataclass
¶
Bases: WeightTransferUpdateInfo
Per-round update info for the dense NCCL weight transfer backend.
Carries the parameter metadata and src, the broadcasting group rank; the
packed wire params live on the init info.
Empty lists reuse the previous update's metadata for the same model and src.
Methods:
-
__post_init__–Validate that all lists have the same length.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
__post_init__()
¶
Validate that all lists have the same length.