[RL] Release weight-transfer communicators without stopping inference (#61060)
Signed-off-by: aoshen02 <aoshen@inferact.ai> Signed-off-by: fh3 <a@b>
This commit is contained in:
@@ -218,6 +218,27 @@ class TestSparseNCCLWeightTransferUpdateInfoValidation:
|
||||
# --- Unit Tests: Engine Parsing ---
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"engine_type",
|
||||
[
|
||||
NCCLWeightTransferEngine,
|
||||
NCCLTrainerWeightTransferEngine,
|
||||
SparseNCCLWeightTransferEngine,
|
||||
SparseNCCLTrainerWeightTransferEngine,
|
||||
],
|
||||
)
|
||||
def test_nccl_shutdown_destroys_communicator_once(engine_type):
|
||||
engine = object.__new__(engine_type)
|
||||
group = MagicMock()
|
||||
engine.model_update_group = group
|
||||
|
||||
engine.shutdown()
|
||||
engine.shutdown()
|
||||
|
||||
group.destroy.assert_called_once_with()
|
||||
assert engine.model_update_group is None
|
||||
|
||||
|
||||
class TestNCCLEngineParsing:
|
||||
"""Test NCCLWeightTransferEngine parsing methods."""
|
||||
|
||||
@@ -1292,6 +1313,9 @@ class TestTrainerClients:
|
||||
handle.finish_weight_update.remote.assert_called_once_with()
|
||||
handle.update_weight_version.remote.assert_called_once_with("step-42")
|
||||
|
||||
client.shutdown_weight_transfer_engine()
|
||||
handle.shutdown_weight_transfer_engine.remote.assert_called_once_with()
|
||||
|
||||
def test_http_client_pickles_ipc_handles_for_json(self, monkeypatch):
|
||||
"""HTTP update_weights must encode raw ipc_handles as a base64 pickle."""
|
||||
captured = {}
|
||||
@@ -1322,6 +1346,7 @@ class TestTrainerClients:
|
||||
captured = {}
|
||||
|
||||
def fake_post(self, path, json=None):
|
||||
captured["path"] = path
|
||||
captured["json"] = json
|
||||
|
||||
monkeypatch.setattr(HTTPVLLMWeightSyncClient, "_post", fake_post)
|
||||
@@ -1333,6 +1358,9 @@ class TestTrainerClients:
|
||||
client.finish_weight_update("step-42")
|
||||
assert captured["json"] == {"weight_version": "step-42"}
|
||||
|
||||
client.shutdown_weight_transfer_engine()
|
||||
assert captured == {"path": "shutdown_weight_transfer_engine", "json": None}
|
||||
|
||||
|
||||
class TestModuleSource:
|
||||
"""`ModuleSource` metadata vs. materialized iteration (dense, no GPU)."""
|
||||
|
||||
@@ -46,7 +46,10 @@ from vllm.distributed.weight_transfer.m2n_source import (
|
||||
mesh_from_tensor,
|
||||
placements_from_tensor,
|
||||
)
|
||||
from vllm.distributed.weight_transfer.m2n_trainer import M2NTrainerInitInfo
|
||||
from vllm.distributed.weight_transfer.m2n_trainer import (
|
||||
M2NTrainerInitInfo,
|
||||
M2NTrainerWeightTransferEngine,
|
||||
)
|
||||
from vllm.model_executor.layers.linear import (
|
||||
ColumnParallelLinear,
|
||||
RowParallelLinear,
|
||||
@@ -57,6 +60,27 @@ from vllm.platforms import current_platform
|
||||
VALID_UID_B64 = base64.b64encode(b"\x00" * 128).decode()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"engine_type,group_attribute",
|
||||
[
|
||||
(M2NWeightTransferEngine, "model_update_group"),
|
||||
(M2NTrainerWeightTransferEngine, "group"),
|
||||
],
|
||||
)
|
||||
def test_shutdown_destroys_communicator_once(engine_type, group_attribute):
|
||||
engine = object.__new__(engine_type)
|
||||
engine._handle = None
|
||||
engine._executor = None
|
||||
group = Mock()
|
||||
setattr(engine, group_attribute, group)
|
||||
|
||||
engine.shutdown()
|
||||
engine.shutdown()
|
||||
|
||||
group.destroy.assert_called_once_with()
|
||||
assert getattr(engine, group_attribute) is None
|
||||
|
||||
|
||||
class TestLayout:
|
||||
def test_replicated_splits_nothing(self):
|
||||
"""A replicated tensor imposes no divisibility constraint. The shape
|
||||
|
||||
Reference in New Issue
Block a user