vllm.distributed.weight_transfer.ipc_engine ¶
IPC-based weight transfer engine using CUDA IPC for communication.
IPCTrainerSendWeightsArgs dataclass ¶
Arguments for IPC trainer_send_weights method.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
llm_handle class-attribute instance-attribute ¶
llm_handle: Any = None
Ray ObjectRef to LLM handle (required for 'ray' mode).
url class-attribute instance-attribute ¶
url: str | None = None
Base URL for HTTP endpoint (required for 'http' mode).
__post_init__ ¶
Validate that required arguments are provided for the selected mode.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
IPCWeightTransferEngine ¶
Bases: WeightTransferEngine[IPCWeightTransferInitInfo, IPCWeightTransferUpdateInfo]
Weight transfer engine using CUDA IPC for communication between trainer and workers.
This implementation uses CUDA IPC to transfer weights from the trainer (rank 0) to all inference workers in a process group. IPC handles are used to share memory between processes on the same node.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
__init__ ¶
__init__(
config: WeightTransferConfig,
parallel_config: ParallelConfig,
) -> None
Initialize the IPC 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/ipc_engine.py
init_transfer_engine ¶
init_transfer_engine(
init_info: IPCWeightTransferInitInfo,
) -> None
Initialize the weight transfer mechanism. This is called once at the beginning of training. No initialization needed for IPC backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
init_info | IPCWeightTransferInitInfo | IPC initialization info (empty) | required |
Source code in vllm/distributed/weight_transfer/ipc_engine.py
receive_weights ¶
receive_weights(
update_info: IPCWeightTransferUpdateInfo,
load_weights: Callable[
[list[tuple[str, Tensor]]], None
],
) -> None
Receive weights from the trainer via CUDA IPC handles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_info | IPCWeightTransferUpdateInfo | IPC update info containing parameter names, dtypes, shapes, and IPC handles. Each IPC handle is a mapping between physical GPU UUID and the IPC handle tuple (func, args). | 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/ipc_engine.py
shutdown ¶
trainer_send_weights staticmethod ¶
trainer_send_weights(
iterator: Iterator[tuple[str, Tensor]],
trainer_args: dict[str, Any]
| IPCTrainerSendWeightsArgs,
) -> None
Send weights from trainer to inference workers via CUDA IPC.
Supports two modes: - 'ray': Sends weights via Ray RPC to a Ray-based LLM handle - 'http': Sends weights via HTTP POST to a vLLM HTTP server
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterator | Iterator[tuple[str, Tensor]] | Iterator of model parameters. Returns (name, tensor) tuples. Tensors should be on the same GPU as the inference workers. | required |
trainer_args | dict[str, Any] | IPCTrainerSendWeightsArgs | Dictionary containing IPC-specific arguments. Should contain keys from IPCTrainerSendWeightsArgs: - mode: 'ray' or 'http' - llm_handle: Ray ObjectRef (for 'ray' mode) - url: Base URL string (for 'http' mode) | required |
Example (Ray mode): >>> from vllm.distributed.weight_transfer.ipc_engine import ( ... IPCWeightTransferEngine, ... IPCTrainerSendWeightsArgs, ... ) >>> param_iter = ((n, p) for n, p in model.named_parameters()) >>> args = IPCTrainerSendWeightsArgs(mode="ray", llm_handle=llm_handle) >>> IPCWeightTransferEngine.trainer_send_weights(param_iter, asdict(args))
Example (HTTP mode): >>> args = IPCTrainerSendWeightsArgs( ... mode="http", url="http://localhost:8000" ... ) >>> IPCWeightTransferEngine.trainer_send_weights(param_iter, asdict(args))
Source code in vllm/distributed/weight_transfer/ipc_engine.py
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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
IPCWeightTransferInitInfo dataclass ¶
Bases: WeightTransferInitInfo
Initialization info for IPC weight transfer backend. No init needed for IPC.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
IPCWeightTransferUpdateInfo dataclass ¶
Bases: WeightTransferUpdateInfo
Update info for IPC weight transfer backend.
Accepts IPC handles either directly via ipc_handles (Ray transport) or as a base64-encoded pickle via ipc_handles_pickled (HTTP transport). Exactly one of the two must be provided; if ipc_handles_pickled is set it is unpickled into ipc_handles during __post_init__.
Source code in vllm/distributed/weight_transfer/ipc_engine.py
ipc_handles class-attribute instance-attribute ¶
IPC handles mapping physical GPU UUID to (func, args) tuple. Each handle is a dictionary mapping GPU UUID strings to IPC handle tuples.