Skip to content

Commit 089ec4f

Browse files
committed
Fix WPIWeightTransferEngine instantiation by implementing missing abstract lifecycle methods
Signed-off-by: Bill Du <yangspirit@google.com>
1 parent a60ea95 commit 089ec4f

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

tests/distributed/test_weight_transfer.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,20 @@ def test_create_engine_sparse_nccl(self):
267267
)
268268
assert isinstance(engine, SparseNCCLWeightTransferEngine)
269269

270+
def test_create_engine_wpi(self):
271+
from vllm.distributed.weight_transfer.wpi_engine import (
272+
WPIWeightTransferEngine,
273+
)
274+
275+
config = WeightTransferConfig(backend="wpi")
276+
engine = WeightTransferEngineFactory.create_engine(
277+
config,
278+
create_mock_vllm_config(),
279+
torch.device("cuda"),
280+
MagicMock(spec=torch.nn.Module),
281+
)
282+
assert isinstance(engine, WPIWeightTransferEngine)
283+
270284
def test_create_engine_invalid_backend(self):
271285
config = WeightTransferConfig(backend="invalid")
272286
with pytest.raises(ValueError, match="Invalid weight transfer backend"):

vllm/distributed/weight_transfer/wpi_engine.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,22 @@ def init_transfer_engine(self, init_info: WPIWeightTransferInitInfo) -> None:
316316
total_shards,
317317
)
318318

319+
def start_weight_update(self) -> None:
320+
"""Initialize layerwise reloading for the incoming checkpoint weights."""
321+
from vllm.model_executor.model_loader.reload import (
322+
initialize_layerwise_reload,
323+
)
324+
325+
initialize_layerwise_reload(self.model)
326+
327+
def finish_weight_update(self) -> None:
328+
"""Finalize layerwise reloading after all weights have been received."""
329+
from vllm.model_executor.model_loader.reload import (
330+
finalize_layerwise_reload,
331+
)
332+
333+
finalize_layerwise_reload(self.model, self.model_config)
334+
319335
def receive_weights(
320336
self,
321337
update_info: WPIWeightTransferUpdateInfo,

0 commit comments

Comments
 (0)