vllm.distributed.weight_transfer.factory ¶
Factory for weight transfer engines with lazy loading.
Classes:
-
WeightTransferEngineFactory–Factory for creating weight transfer engines with lazy loading.
-
WeightTransferTrainerFactory–Factory for creating trainer-side weight transfer engines.
WeightTransferEngineFactory ¶
Factory for creating weight transfer engines with lazy loading.
This factory implements a registry pattern that supports: - Lazy loading: Engine modules are only imported when actually needed - Extensibility: Custom engines can be registered at runtime - Centralized registration: All built-in engines registered in one place
Methods:
-
create_engine–Create a weight transfer engine instance.
-
register_engine–Register an engine with lazy-loading or direct class reference.
Source code in vllm/distributed/weight_transfer/factory.py
create_engine(config, vllm_config, device, model) classmethod ¶
Create a weight transfer engine instance.
Parameters:
-
(config¶WeightTransferConfig) –Weight transfer configuration containing the backend name
-
(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
Returns:
-
WeightTransferEngine–An initialized weight transfer engine instance
Raises:
-
ValueError–If the backend is not registered
Source code in vllm/distributed/weight_transfer/factory.py
register_engine(name, module_path_or_cls, class_name=None) classmethod ¶
Register an engine with lazy-loading or direct class reference.
Supports two calling conventions: 1. Lazy loading: register_engine(name, module_path, class_name) 2. Direct class: register_engine(name, engine_cls)
Parameters:
-
(name¶str) –The name to register the engine under (e.g., "nccl")
-
(module_path_or_cls¶str | type[WeightTransferEngine]) –Either a module path string for lazy loading, or the engine class directly
-
(class_name¶str | None, default:None) –Name of the engine class (required if module_path is string)
Raises:
-
ValueError–If an engine with the same name is already registered
Source code in vllm/distributed/weight_transfer/factory.py
WeightTransferTrainerFactory ¶
Factory for creating trainer-side weight transfer engines.
Parallel to WeightTransferEngineFactory, with its own lazy-import registry. The trainer-side and worker-side registries are kept separate: they share backend names by convention, but the trainer process never instantiates a worker engine and vice versa, so unifying them would only couple the import graphs.
Methods:
-
register_engine–Register a trainer engine. Same conventions as
-
trainer_init–Build and rendezvous a ready-to-send trainer engine.
Source code in vllm/distributed/weight_transfer/factory.py
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 | |
register_engine(name, module_path_or_cls, class_name=None) classmethod ¶
Register a trainer engine. Same conventions as WeightTransferEngineFactory.register_engine.
Source code in vllm/distributed/weight_transfer/factory.py
trainer_init(backend, config, init_info, *, client, source) classmethod ¶
Build and rendezvous a ready-to-send trainer engine.
Called on every trainer rank (multi-rank trainers construct on all ranks; the sender is resolved inside the engine's trainer_init).
Parameters:
-
(backend¶str) –Backend name (must be registered).
-
(config¶WeightTransferConfig) –Backend-specific weight transfer config.
-
(init_info¶WeightTransferInitInfo) –Backend-specific trainer init info.
-
(client¶VLLMWeightSyncClient) –Inference-side control-plane client.
-
(source¶WeightSource) –WeightSourceof(name, tensor)pairs to send each round.
Raises:
-
ValueError–If the backend is not registered.