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. world_size is the full trainer+worker NCCL group size. rank (from TrainerInitInfo) identifies this trainer process; rank 0 is the sender.
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.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
NCCLTrainerWeightTransferEngine ¶
Bases: TrainerWeightTransferEngine[NCCLTrainerInitInfo]
Trainer-side NCCL weight transfer engine.
On the sender (rank 0) holds the NCCL communicator and drives the full update round trip: it runs the inference-side update_weights concurrently with the trainer-side broadcast (both rendezvous inside the same NCCL calls), then finishes the update. Non-sender trainer ranks hold no communicator; they only iterate the source to stay in the trainer-side collective (e.g. FSDP full_tensor()) and skip the client RPCs and the broadcast (all guarded on is_sender).
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
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 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 | |
_broadcast(source, meta) ¶
Iterate the source (materializing each tensor — a collective on all ranks) and, on the sender, broadcast from rank 0, packed or one-by-one. Non-sender ranks only replay the iteration to stay in the collective.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
_checked_iter(source, meta) staticmethod ¶
Yield the source'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. Sender-only: under pipeline parallelism a non-sender's yielded tensor is not meaningful.
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
NCCLWeightTransferEngine ¶
Bases: WeightTransferEngine[NCCLWeightTransferInitInfo, NCCLWeightTransferUpdateInfo]
Weight transfer engine using NCCL for communication between trainer and workers.
This implementation uses NCCL broadcast operations to transfer dense checkpoint-format weights from the trainer (rank 0) to all inference workers in a process group. Received weights are loaded via the model's load_weights using 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
105 106 107 108 109 110 111 112 113 114 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 | |
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) –NCCL update info containing parameter names, dtypes, and shapes
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.
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.
Whether the transfer is packed (and the buffer geometry) is a must-agree wire param carried on the init info (NCCLTrainerInitInfo / NCCLWeightTransferInitInfo), not here; this carries only the per-round parameter metadata.
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.