vllm.distributed.weight_transfer.base ¶
Base class for weight transfer engines.
Classes:
-
WeightTransferEngine–Base class for weight transfer engines that handle transport of model weights
-
WeightTransferInitInfo–Base class for backend-specific initialization info.
-
WeightTransferInitRequest–API-level weight transfer initialization request.
-
WeightTransferUpdateInfo–Base class for backend-specific weight update info.
-
WeightTransferUpdateRequest–API-level weight update request.
WeightTransferEngine ¶
Bases: ABC, Generic[TInitInfo, TUpdateInfo]
Base class for weight transfer engines that handle transport of model weights from a trainer to inference workers.
This abstraction separates weight transfer transport logic from the worker implementation, allowing different backends (NCCL, CUDA IPC, RDMA[TODO]) to be plugged in.
Each engine owns its full weight-update lifecycle: start_weight_update, update_weights, and finish_weight_update. Layerwise reloading (used by checkpoint-format engines) is opted into per engine by running it inside start_weight_update/finish_weight_update. Engines that apply weights in place (e.g. sparse patches) leave those methods as no-ops.
Subclasses should define
init_info_cls: Type of backend-specific initialization info update_info_cls: Type of backend-specific update info
Methods:
-
__init__–Initialize the weight transfer engine.
-
finish_weight_update–Finalize the current weight update.
-
init_transfer_engine–Initialize the weight transfer mechanism.
-
parse_init_info–Construct typed init info from dict with validation.
-
parse_update_info–Construct typed update info from dict with validation.
-
receive_weights–Receive weights from the trainer and load them into the model.
-
shutdown–Shutdown the weight transfer engine.
-
start_weight_update–Prepare the engine for a new weight update.
-
trainer_send_weights–Send weights from trainer to inference workers.
-
update_weights–Receive one weight update chunk and load it into the model.
Source code in vllm/distributed/weight_transfer/base.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 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 | |
__init__(config, vllm_config, device, model) ¶
Initialize the weight transfer engine.
Parameters:
-
(config¶WeightTransferConfig) –The configuration for the weight transfer engine
-
(vllm_config¶VllmConfig) –The full vLLM config (provides parallel/model config)
-
(device¶device) –The device this worker's model lives on
-
(model¶Module) –The local model instance which will receive the weights
Source code in vllm/distributed/weight_transfer/base.py
finish_weight_update() abstractmethod ¶
Finalize the current weight update.
Checkpoint-format engines finalize layerwise reloading here; engines that apply weights in place leave this as a no-op.
Source code in vllm/distributed/weight_transfer/base.py
init_transfer_engine(init_info) abstractmethod ¶
Initialize the weight transfer mechanism. This is called once at the beginning of training.
Parameters:
-
(init_info¶TInitInfo) –Backend-specific initialization info
Source code in vllm/distributed/weight_transfer/base.py
parse_init_info(init_dict) ¶
Construct typed init info from dict with validation.
Parameters:
Returns:
-
TInitInfo–Typed backend-specific init info dataclass
Raises:
-
ValueError–If init_dict is invalid for this backend
Source code in vllm/distributed/weight_transfer/base.py
parse_update_info(update_dict) ¶
Construct typed update info from dict with validation.
Parameters:
Returns:
-
TUpdateInfo–Typed backend-specific update info dataclass
Raises:
-
ValueError–If update_dict is invalid for this backend
Source code in vllm/distributed/weight_transfer/base.py
receive_weights(update_info) abstractmethod ¶
Receive weights from the trainer and load them into the model.
Parameters:
-
(update_info¶TUpdateInfo) –Backend-specific update info containing parameter metadata and any backend-specific data
Source code in vllm/distributed/weight_transfer/base.py
shutdown() abstractmethod ¶
Shutdown the weight transfer engine. This should be called when the worker is shutting down.
start_weight_update() abstractmethod ¶
Prepare the engine for a new weight update.
Engines that receive weights in checkpoint format initialize layerwise reloading here, else this is typically a no-op. See: https://docs.vllm.ai/en/latest/training/layerwise/ for more details.
Source code in vllm/distributed/weight_transfer/base.py
trainer_send_weights(iterator, trainer_args) abstractmethod staticmethod ¶
Send weights from trainer to inference workers.
This is a static method that can be called from the trainer process to send weights to all inference workers.
Parameters:
-
(iterator¶Iterator[Any]) –Iterator of backend-specific items to send.
-
(trainer_args¶dict[str, Any] | Any) –Dictionary containing backend-specific arguments needed to send weights. The structure depends on the backend: - NCCL: Contains 'group', 'src', 'packed', etc. - IPC: Contains 'mode' ('http' or 'ray'), 'llm_handle' (for Ray), 'url' (for HTTP), etc.
Example
param_iter = ((n, p) for n, p in model.named_parameters()) engine.trainer_send_weights(param_iter, trainer_args)
Source code in vllm/distributed/weight_transfer/base.py
update_weights(update_info) ¶
Receive one weight update chunk and load it into the model.
Parameters: