vllm.distributed.weight_transfer.ipc_engine ¶
IPC-based weight transfer engine using CUDA IPC for communication.
Classes:
-
IPCTrainerSendWeightsArgs–Arguments for IPC trainer_send_weights method.
-
IPCWeightTransferEngine–Weight transfer engine using CUDA IPC for communication between trainer and workers.
-
IPCWeightTransferInitInfo–Initialization info for IPC weight transfer backend. No init needed for IPC.
-
IPCWeightTransferUpdateInfo–Update info for IPC weight transfer backend.
IPCTrainerSendWeightsArgs dataclass ¶
Arguments for IPC trainer_send_weights method.
Methods:
-
__post_init__–Validate that required arguments are provided for the selected mode.
Attributes:
-
llm_handle(Any) –Ray actor handle or list of handles (required for 'ray' send_mode).
-
packed(bool) –Whether to use packed tensor transfer for bounded-memory chunking.
-
packed_buffer_size_bytes(int) –Size in bytes for each packed tensor buffer when packed=True.
-
send_mode(str | Callable[[IPCWeightTransferUpdateInfo], None]) –How to send updates to vLLM. Either a string ('ray' or 'http') for
-
url(str | None) –Base URL for HTTP endpoint (required for 'http' send_mode).
Source code in vllm/distributed/weight_transfer/ipc_engine.py
llm_handle = None class-attribute instance-attribute ¶
Ray actor handle or list of handles (required for 'ray' send_mode).
packed = False class-attribute instance-attribute ¶
Whether to use packed tensor transfer for bounded-memory chunking.
packed_buffer_size_bytes = DEFAULT_PACKED_BUFFER_SIZE_BYTES class-attribute instance-attribute ¶
Size in bytes for each packed tensor buffer when packed=True.
send_mode instance-attribute ¶
How to send updates to vLLM. Either a string ('ray' or 'http') for built-in transports, or a callable that receives an IPCWeightTransferUpdateInfo and performs the send.
url = None class-attribute instance-attribute ¶
Base URL for HTTP endpoint (required for 'http' send_mode).
__post_init__() ¶
Validate that required arguments are provided for the selected mode.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
IPCWeightTransferEngine ¶
Bases: WeightTransferEngine[IPCWeightTransferInitInfo, IPCWeightTransferUpdateInfo]
Weight transfer engine using CUDA IPC for communication between trainer and workers.
This implementation uses CUDA IPC to transfer weights from the trainer (rank 0) to all inference workers in a process group. IPC handles are used to share memory between processes on the same node.
Methods:
-
__init__–Initialize the IPC weight transfer engine.
-
init_transfer_engine–Initialize the weight transfer mechanism.
-
parse_update_info–Parse update dict, deserializing pickled IPC handles if present.
-
receive_weights–Receive weights from the trainer via CUDA IPC handles.
-
trainer_send_weights–Send weights from trainer to inference workers via CUDA IPC.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
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 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 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 | |
__init__(config, parallel_config, model) ¶
Initialize the IPC weight transfer engine.
Parameters:
-
(config¶WeightTransferConfig) –The configuration for the weight transfer engine
-
(parallel_config¶ParallelConfig) –The configuration for the parallel setup
-
(model¶Module) –The local model instance which will receive the weights
Source code in vllm/distributed/weight_transfer/ipc_engine.py
_all_gather_and_merge_handles(handles) staticmethod ¶
All-gather and merge IPC handle dicts across ranks in one call.
Each rank contributes a list of {gpu_uuid: ipc_args} dicts (one per parameter or one per chunk). A single all_gather_object collects every rank's full list, then rank 0 merges per-index so each dict maps every GPU UUID to its args.
Non-rank-0 returns a list of empty dicts. No-op (returns handles unchanged) when no distributed group exists.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
_do_send(args, names, dtype_names, shapes, ipc_handles, tensor_sizes=None, packed=False) staticmethod ¶
Send a single update payload via the configured transport.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
_is_rank_zero() staticmethod ¶
Return True if this is rank 0 or no distributed group exists.
_post_send_sync() staticmethod ¶
Barrier + ipc_collect after a send; no-op if single-GPU.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
_send_packed(iterator, args, gpu_uuid) staticmethod ¶
Send weights in bounded-memory chunks (packed mode).
Source code in vllm/distributed/weight_transfer/ipc_engine.py
_send_unpacked(iterator, args, gpu_uuid) staticmethod ¶
Send all weights in a single API call (non-packed mode).
Source code in vllm/distributed/weight_transfer/ipc_engine.py
init_transfer_engine(init_info) ¶
Initialize the weight transfer mechanism. This is called once at the beginning of training. No initialization needed for IPC backend.
Parameters:
-
(init_info¶IPCWeightTransferInitInfo) –IPC initialization info (empty)
Source code in vllm/distributed/weight_transfer/ipc_engine.py
parse_update_info(update_dict) ¶
Parse update dict, deserializing pickled IPC handles if present.
HTTP transport sends IPC handles as a base64-encoded pickle under the key ipc_handles_pickled. This method deserializes them back into ipc_handles before constructing the typed dataclass, keeping serialization concerns out of the dataclass itself.
Requires VLLM_ALLOW_INSECURE_SERIALIZATION=1 because the payload is deserialized via pickle.loads.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
receive_weights(update_info, load_weights) ¶
Receive weights from the trainer via CUDA IPC handles.
Parameters:
-
(update_info¶IPCWeightTransferUpdateInfo) –IPC update info containing parameter names, dtypes, shapes, and IPC handles. Each IPC handle is a mapping between physical GPU UUID and the rebuild_cuda_tensor args tuple.
-
(load_weights¶Callable[[list[tuple[str, Tensor]]], None]) –Callable that loads weights into the model. Called incrementally for each weight to avoid OOM.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
trainer_send_weights(iterator, trainer_args) staticmethod ¶
Send weights from trainer to inference workers via CUDA IPC.
Supports two transport modes ('ray' and 'http') and two transfer strategies: - Non-packed (default): all weights in a single API call. - Packed (packed=True): chunked transfer with bounded GPU memory.
For multi-GPU training, all ranks must call this method in parallel. IPC handles are all-gathered across ranks and merged so that each vLLM worker can find its own GPU UUID. Only rank 0 sends the payload to vLLM.
.. note:: This method calls update_weights internally. The caller must call start_weight_update before and finish_weight_update after this method.
Parameters:
-
(iterator¶Iterator[tuple[str, Tensor]]) –Iterator of (name, tensor) pairs. For multi-GPU, each rank should yield the full tensor on its own GPU (e.g. via FSDP full_tensor()).
-
(trainer_args¶dict[str, Any] | IPCTrainerSendWeightsArgs) –IPCTrainerSendWeightsArgs or equivalent dict.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
IPCWeightTransferInitInfo dataclass ¶
Bases: WeightTransferInitInfo
Initialization info for IPC weight transfer backend. No init needed for IPC.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
IPCWeightTransferUpdateInfo dataclass ¶
Bases: WeightTransferUpdateInfo
Update info for IPC weight transfer backend.
Attributes:
-
ipc_handles(list[dict[str, tuple]] | dict[str, tuple] | None) –IPC handles mapping physical GPU UUID to rebuild_cuda_tensor args.
-
ipc_handles_pickled(str | None) –Base64-encoded pickled IPC handles, used for HTTP transport.
-
packed(bool) –Whether this update uses packed tensor format.
-
tensor_sizes(list[int] | None) –Per-parameter sizes in bytes within the packed buffer.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
ipc_handles = None class-attribute instance-attribute ¶
IPC handles mapping physical GPU UUID to rebuild_cuda_tensor args. For non-packed mode: list of per-parameter handle dicts. For packed mode: single handle dict for the packed buffer.
ipc_handles_pickled = None class-attribute instance-attribute ¶
Base64-encoded pickled IPC handles, used for HTTP transport.
packed = False class-attribute instance-attribute ¶
Whether this update uses packed tensor format.
tensor_sizes = None class-attribute instance-attribute ¶
Per-parameter sizes in bytes within the packed buffer. Required when packed=True, unused otherwise.