vllm.distributed.weight_transfer ¶
Weight transfer engines for syncing model weights from trainers to inference workers.
Modules:
| Name | Description |
|---|---|
base | Base class for weight transfer engines. |
factory | Factory for weight transfer engines with lazy loading. |
nccl_engine | NCCL-based weight transfer engine. |
packed_tensor | Packed tensor utilities for efficient weight transfer. |
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
Source code in vllm/distributed/weight_transfer/factory.py
_registry class-attribute instance-attribute ¶
_registry: dict[
str, Callable[[], type[WeightTransferEngine]]
] = {}
create_engine classmethod ¶
create_engine(
config: WeightTransferConfig,
parallel_config: ParallelConfig,
) -> WeightTransferEngine
Create a weight transfer engine instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | WeightTransferConfig | Weight transfer configuration containing the backend name | required |
parallel_config | ParallelConfig | Parallel configuration for the engine | required |
Returns:
| Type | Description |
|---|---|
WeightTransferEngine | An initialized weight transfer engine instance |
Raises:
| Type | Description |
|---|---|
ValueError | If the backend is not registered |
Source code in vllm/distributed/weight_transfer/factory.py
register_engine classmethod ¶
register_engine(
name: str,
module_path_or_cls: str | type[WeightTransferEngine],
class_name: str | None = None,
) -> None
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 | Type | Description | Default |
|---|---|---|---|
name | str | The name to register the engine under (e.g., "nccl") | required |
module_path_or_cls | str | type[WeightTransferEngine] | Either a module path string for lazy loading, or the engine class directly | required |
class_name | str | None | Name of the engine class (required if module_path is string) | None |
Raises:
| Type | Description |
|---|---|
ValueError | If an engine with the same name is already registered |