Skip to content

vllm.distributed.weight_transfer.sparse_nccl_engine

Sparse NCCL weight transfer engine.

Sparse patches use checkpoint names, shapes, and flat indices. The model's native weight loader maps them to rank-local runtime parameters, including TP shards and packed parameters.

Classes:

SparseNCCLTrainerInitInfo dataclass

Bases: TrainerInitInfo

Trainer-side init info for the sparse NCCL weight transfer backend.

Same rendezvous shape as the dense NCCL backend (the sender opens its endpoint as NCCL rank 0), but with no packed wire params: each update carries its own batch size. backend is the factory dispatch key.

SparseNCCLTrainerWeightTransferEngine

Bases: TrainerWeightTransferEngine[SparseNCCLTrainerInitInfo]

Trainer-side sparse NCCL weight transfer engine.

Broadcasts flat-index (indices, values) patches from NCCL rank 0 while the inference-side update_weights runs concurrently on a side thread (the worker's recvs rendezvous inside the same NCCL broadcasts). send_weights owns a complete one-shot lifecycle. RL infrastructure that owns the generic client lifecycle can call send_weight_chunk between one start and finish.

Sparse patches differ every round, so they are not a stable WeightSource: the engine takes no source, and patches are passed directly to the send methods. An empty patch list is a no-op.

Only the designated trainer sender joins the transfer group; other trainer ranks skip sparse sends.

Methods:

  • send_weight_chunk –

    Broadcast one chunk inside a caller-owned weight update lifecycle.

  • send_weights –

    Broadcast one sparse update through a one-shot lifecycle.

_post_send_sync()

Wait for the broadcasts to land before returning, so a caller may rebuild or free the patch tensors as soon as a send method returns rather than relying on same-stream ordering. See NCCLTrainerWeightTransferEngine._post_send_sync for why there is no cross-rank barrier.

_validate_patch(patch) staticmethod

Reject a malformed patch before starting the NCCL transfer.

send_weight_chunk(patches=None)

Broadcast one chunk inside a caller-owned weight update lifecycle.

send_weights(patches=None)

Broadcast one sparse update through a one-shot lifecycle.

SparseNCCLWeightTransferEngine

Bases: WeightTransferEngine[NCCLWeightTransferInitInfo, SparseNCCLWeightTransferUpdateInfo]

Sparse weight transfer engine using NCCL.

Receives checkpoint-coordinate patches broadcast from the trainer and applies them through the model's native weight loader. Sparse updates modify initialized model tensors in place, so the layerwise reload lifecycle is not used.

Methods:

finish_weight_update()

No layerwise reload; rebuild model-level derived state once.

init_transfer_engine(init_info)

Initialize the NCCL process group with the trainer.

receive_weights(update_info)

Receive sparse flat-index patches from the trainer and apply them.

start_weight_update()

No-op: sparse patches are applied in place, no layerwise reload.

SparseNCCLWeightTransferUpdateInfo dataclass

Bases: WeightTransferUpdateInfo

Update info for the sparse NCCL weight transfer backend.

Methods:

  • batches –

    Split the patches into consecutive batches of at most wire_batch_bytes.

Attributes:

num_updates_list instance-attribute

Number of sparse entries to receive for each parameter in names.

wire_batch_bytes instance-attribute

Set by the trainer, so both ends cut the update at the same patches.

batches()

Split the patches into consecutive batches of at most wire_batch_bytes.

A patch larger than the limit is a batch by itself.

SparseWeightPatch dataclass

A sparse patch in checkpoint coordinates.

Attributes:

full_shape instance-attribute

Full checkpoint shape.