vllm.distributed.weight_transfer.nccl_engine ¶
NCCL-based (dense) weight transfer engine.
Classes:
-
NCCLTrainerSendWeightsArgs–Arguments for NCCL trainer_send_weights method.
-
NCCLWeightTransferEngine–Weight transfer engine using NCCL for communication between trainer and workers.
-
NCCLWeightTransferInitInfo–Initialization info for NCCL-based weight transfer backends.
-
NCCLWeightTransferUpdateInfo–Update info for NCCL weight transfer backend.
NCCLTrainerSendWeightsArgs dataclass ¶
Arguments for NCCL trainer_send_weights method.
Attributes:
-
group(Any) –Process group (PyNcclCommunicator) for NCCL communication.
-
packed(bool) –Whether to use packed tensor broadcasting for efficiency.
-
packed_buffer_size_bytes(int) –Size in bytes for each packed tensor buffer.
-
packed_num_buffers(int) –Number of buffers for double/triple buffering during packed transfer.
-
post_iter_func(Callable[[tuple[str, Tensor]], Tensor] | None) –Optional function to apply to each (name, tensor) pair before broadcasting.
-
src(int) –Source rank (default 0, trainer is typically rank 0).
-
stream(Stream | None) –CUDA stream to use for broadcasting if packed is False.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
group instance-attribute ¶
Process group (PyNcclCommunicator) for NCCL communication.
packed = False class-attribute instance-attribute ¶
Whether to use packed tensor broadcasting for efficiency. When True, multiple tensors are batched together before broadcasting to reduce NCCL communication overhead.
packed_buffer_size_bytes = DEFAULT_PACKED_BUFFER_SIZE_BYTES class-attribute instance-attribute ¶
Size in bytes for each packed tensor buffer. Must match the value used in NCCLWeightTransferUpdateInfo.
packed_num_buffers = DEFAULT_PACKED_NUM_BUFFERS class-attribute instance-attribute ¶
Number of buffers for double/triple buffering during packed transfer. Must match the value used in NCCLWeightTransferUpdateInfo.
post_iter_func = None class-attribute instance-attribute ¶
Optional function to apply to each (name, tensor) pair before broadcasting. If None, extracts just the tensor.
src = 0 class-attribute instance-attribute ¶
Source rank (default 0, trainer is typically rank 0).
stream = None class-attribute instance-attribute ¶
CUDA stream to use for broadcasting if packed is False. If packed is True, new streams will be created for each buffer.
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.
-
receive_weights–Receive weights from trainer via NCCL broadcast.
-
start_weight_update–Initialize layerwise reloading for the incoming checkpoint weights.
-
trainer_send_weights–Broadcast dense weights from trainer to vLLM workers.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
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 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 | |
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.
Parameters:
-
(init_info¶NCCLWeightTransferInitInfo) –NCCL initialization info containing master address, port, rank offset, and world size
Source code in vllm/distributed/weight_transfer/nccl_engine.py
receive_weights(update_info) ¶
Receive weights from trainer via NCCL broadcast.
If update_info.packed is True, uses packed tensor broadcasting for efficient transfer of multiple weights in batches. Otherwise, uses simple one-by-one broadcasting.
Parameters:
-
(update_info¶NCCLWeightTransferUpdateInfo) –NCCL update info containing parameter names, dtypes, shapes, and packed flag
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
trainer_send_weights(iterator, trainer_args) staticmethod ¶
Broadcast dense weights from trainer to vLLM workers.
Parameters:
-
(iterator¶Iterator[tuple[str, Tensor]]) –Iterator of model parameters. Returns (name, tensor) tuples
-
(trainer_args¶dict[str, Any] | NCCLTrainerSendWeightsArgs) –Dictionary or NCCLTrainerSendWeightsArgs instance containing NCCL-specific arguments. If a dict, should contain keys from NCCLTrainerSendWeightsArgs.
Example
from vllm.distributed.weight_transfer.nccl_engine import ( ... NCCLWeightTransferEngine, ... NCCLTrainerSendWeightsArgs, ... ) param_iter = ((n, p) for n, p in model.named_parameters()) args = NCCLTrainerSendWeightsArgs(group=group, packed=True) NCCLWeightTransferEngine.trainer_send_weights(param_iter, args)
Source code in vllm/distributed/weight_transfer/nccl_engine.py
NCCLWeightTransferInitInfo dataclass ¶
Bases: WeightTransferInitInfo
Initialization info for NCCL-based weight transfer backends.
Source code in vllm/distributed/weight_transfer/nccl_common.py
NCCLWeightTransferUpdateInfo dataclass ¶
Bases: WeightTransferUpdateInfo
Update info for NCCL weight transfer backend.
Methods:
-
__post_init__–Validate that all lists have the same length.
Attributes:
-
packed(bool) –Whether to use packed tensor broadcasting for efficiency.
-
packed_buffer_size_bytes(int) –Size in bytes for each packed tensor buffer.
-
packed_num_buffers(int) –Number of buffers for double/triple buffering during packed transfer.
Source code in vllm/distributed/weight_transfer/nccl_engine.py
packed = False class-attribute instance-attribute ¶
Whether to use packed tensor broadcasting for efficiency. When True, multiple tensors are batched together before broadcasting to reduce NCCL communication overhead.
packed_buffer_size_bytes = DEFAULT_PACKED_BUFFER_SIZE_BYTES class-attribute instance-attribute ¶
Size in bytes for each packed tensor buffer. Both producer and consumer must use the same value.
packed_num_buffers = DEFAULT_PACKED_NUM_BUFFERS class-attribute instance-attribute ¶
Number of buffers for double/triple buffering during packed transfer. Both producer and consumer must use the same value.
__post_init__() ¶
Validate that all lists have the same length.