vllm.distributed.weight_transfer.base ¶
Base class for weight transfer engines.
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[TODO], RDMA[TODO]) to be plugged in.
Subclasses should define
init_info_cls: Type of backend-specific initialization info update_info_cls: Type of backend-specific update info
Source code in vllm/distributed/weight_transfer/base.py
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 | |
__init__ ¶
__init__(
config: WeightTransferConfig,
parallel_config: ParallelConfig,
) -> None
Initialize the weight transfer engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | WeightTransferConfig | The configuration for the weight transfer engine | required |
parallel_config | ParallelConfig | The configuration for the parallel setup | required |
Source code in vllm/distributed/weight_transfer/base.py
init_transfer_engine abstractmethod ¶
Initialize the weight transfer mechanism. This is called once at the beginning of training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
init_info | TInitInfo | Backend-specific initialization info | required |
Source code in vllm/distributed/weight_transfer/base.py
parse_init_info ¶
Construct typed init info from dict with validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
init_dict | dict[str, Any] | Dictionary containing backend-specific initialization parameters | required |
Returns:
| Type | Description |
|---|---|
TInitInfo | Typed backend-specific init info dataclass |
Raises:
| Type | Description |
|---|---|
ValueError | If init_dict is invalid for this backend |
Source code in vllm/distributed/weight_transfer/base.py
parse_update_info ¶
Construct typed update info from dict with validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_dict | dict[str, Any] | Dictionary containing backend-specific update parameters | required |
Returns:
| Type | Description |
|---|---|
TUpdateInfo | Typed backend-specific update info dataclass |
Raises:
| Type | Description |
|---|---|
ValueError | If update_dict is invalid for this backend |
Source code in vllm/distributed/weight_transfer/base.py
receive_weights abstractmethod ¶
receive_weights(
update_info: TUpdateInfo,
load_weights: Callable[
[list[tuple[str, Tensor]]], None
],
) -> None
Receive weights from the trainer and load them incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_info | TUpdateInfo | Backend-specific update info containing parameter metadata and any backend-specific data | required |
load_weights | Callable[[list[tuple[str, Tensor]]], None] | Callable that loads weights into the model. Called incrementally for each weight to avoid OOM. | required |
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.
trainer_send_weights abstractmethod staticmethod ¶
trainer_send_weights(
iterator: Iterator[tuple[str, Tensor]],
trainer_args: dict[str, Any] | Any,
) -> None
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:
| Name | Type | Description | Default |
|---|---|---|---|
iterator | Iterator[tuple[str, Tensor]] | Iterator of model parameters. Returns (name, tensor) tuples. The tensors should be on the appropriate device for the backend. | required |
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. | required |
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
WeightTransferInitInfo dataclass ¶
WeightTransferInitRequest dataclass ¶
WeightTransferUpdateInfo dataclass ¶
Bases: ABC
Base class for backend-specific weight update info.