Skip to content

vllm.distributed.weight_transfer.sparse_disk_engine

Sparse disk weight transfer engine.

The trainer publishes each version's sparse patches as one file on storage that every inference host can read, while the engine serves. Each worker keeps its part of the checkpoint in host memory, as its load plan writes it; in the update it applies the new files there and copies that whole part into the model.

Classes:

Functions:

  • patch_file –

    The file that holds version's patches.

  • save_sparse_patches –

    Write version's patches, the changes from version - 1, to patch_dir.

SparseDiskTrainerInitInfo dataclass

Bases: TrainerInitInfo

Trainer-side init info for the sparse disk backend; the sender ships the worker-side fields at the handshake.

Attributes:

  • base_version (int) –

    Version of the checkpoint the inference servers started from; the first

  • patch_dir (str) –

    Directory to publish patch files to; every inference host must read it at

base_version = 0 class-attribute instance-attribute

Version of the checkpoint the inference servers started from; the first publish writes the next one.

patch_dir instance-attribute

Directory to publish patch files to; every inference host must read it at the same path.

SparseDiskTrainerWeightTransferEngine

Bases: TrainerWeightTransferEngine[SparseDiskTrainerInitInfo]

Trainer-side sparse disk weight transfer engine.

publish(patches) writes the next version while the engine serves; send_weights(), called in the pause, updates the inference side to it. Patches are in checkpoint coordinates, as for sparse NCCL, and only the sender's are published.

Methods:

  • publish –

    Write the next version's patches.

  • send_weights –

    Update the inference side to the last published version.

publish(patches)

Write the next version's patches.

send_weights()

Update the inference side to the last published version.

SparseDiskWeightTransferEngine

Bases: WeightTransferEngine[SparseDiskWeightTransferInitInfo, SparseDiskWeightTransferUpdateInfo]

Applies published patch files to this worker's host copy of its part of the checkpoint, then loads that whole part into the model.

The first update builds the copy from the startup checkpoint, at base_version, and replays the files after it; a restarted server does the same. The copy holds what the load plan writes on this worker, in pinned memory where available.

Methods:

  • init_transfer_engine –

    Check that the model can load through a load plan from its startup

  • receive_weights –

    Bring the host copy to the version, then load it into the model.

init_transfer_engine(init_info)

Check that the model can load through a load plan from its startup checkpoint files.

receive_weights(update_info)

Bring the host copy to the version, then load it into the model.

SparseDiskWeightTransferInitInfo dataclass

Bases: WeightTransferInitInfo

Worker-side init info for the sparse disk backend.

Attributes:

  • base_version (int) –

    Version of the checkpoint the inference servers started from.

  • patch_dir (str) –

    Directory the trainer publishes patch files to, at the same path on every

base_version = 0 class-attribute instance-attribute

Version of the checkpoint the inference servers started from.

patch_dir instance-attribute

Directory the trainer publishes patch files to, at the same path on every inference host.

SparseDiskWeightTransferUpdateInfo dataclass

Bases: WeightTransferUpdateInfo

Update info for the sparse disk backend.

_HostCopy

A worker's part of the checkpoint at version, as its load plan writes it: per checkpoint dtype, one host buffer of every box this worker loads. A name the plan leaves to load_weights holds its whole tensor there.

Methods:

  • load –

    Copy the whole part into the model and report it loaded.

  • map –

    Check every patch of the open file f against the checkpoint and

_index_geometry()

Device tensors to map patch elements in bulk: per checkpoint name, its shape and, per slot, one of its boxes on this worker with its copy offset; slots past its last box are empty.

_map_bulk(names, counts, indices, values)

Check and map every element, a chunk at a time on the worker's device, and yield the copy offset and value of each one in a box.

load(model)

Copy the whole part into the model and report it loaded.

map(f)

Check every patch of the open file f against the checkpoint and find where its values land in this copy, without touching it: (buffer dtype, positions in it, values as same-size integers).

_chunk_elements(device)

Patch elements to map at once: about 200 bytes each of free device memory, within bounds.

patch_file(patch_dir, version)

The file that holds version's patches.

save_sparse_patches(patches, patch_dir, version)

Write version's patches, the changes from version - 1, to patch_dir.

Patch values overwrite the checkpoint values at their flat indices, which must be strictly increasing; a tensor is patched at most once per version. Patches with values of one dtype are stored as one concatenated index and value tensor. A version is written once: publishing it again raises.