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
¶
Bases: _LazyEngineFactory[WeightTransferEngine]
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.
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
WeightTransferTrainerFactory
¶
Bases: _LazyEngineFactory[TrainerWeightTransferEngine]
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:
-
trainer_init–Build and rendezvous a ready-to-send trainer engine.
trainer_init(init_info, *, client, source=None)
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).
The trainer side takes no WeightTransferConfig and no separate
backend argument: the backend is read from init_info.backend (a
ClassVar on each TrainerInitInfo subclass), and the static wire
params ride init_info.
Parameters:
-
(init_info¶TrainerInitInfo) –Backend-specific trainer init info. Its
backendselects the engine; it also carries the wire params (e.g.packed). -
(client¶VLLMWeightSyncClient) –Inference-side control-plane client.
-
(source¶WeightSource | None, default:None) –WeightSourceof(name, tensor)pairs to send each round, for full-resync backends (NCCL, IPC). Sparse backend omits it and passes its per-round payload tosend_weights.
Raises:
-
ValueError–If
init_info.backendis not registered.
_LazyEngineFactory
¶
Bases: Generic[_EngineT]
Registry-backed factory that imports engine classes lazily on demand.
Methods:
-
register_engine–Register an engine with lazy-loading or direct class reference.
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[_EngineT]) –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