[KV Offload] Support out-of-tree secondary tier managers via module_path (#51007)
Signed-off-by: Ronen Schaffer <ronen.schaffer@ibm.com> Co-authored-by: Or Ozeri <oro@il.ibm.com>
This commit is contained in:
co-authored by
Or Ozeri
parent
d4da0c55af
commit
8543522ca7
@@ -133,13 +133,13 @@ def test_missing_tier_type_raises():
|
||||
|
||||
|
||||
def test_unknown_tier_type_raises():
|
||||
"""Unrecognized tier_type → ValueError with supported types list."""
|
||||
"""Unrecognized tier_type without module_path → ValueError."""
|
||||
primary_kv_view, offloading_spec = _make_mock_args()
|
||||
tier_config = {"type": "nonexistent_tier"}
|
||||
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match=r"Unknown secondary tier type.*Supported types:",
|
||||
match=r"Unknown secondary tier type.*also set 'module_path'",
|
||||
):
|
||||
SecondaryTierFactory.create_secondary_tier(
|
||||
tier_config, primary_kv_view, offloading_spec
|
||||
@@ -150,3 +150,52 @@ def test_duplicate_registration_raises():
|
||||
"""register_tier with existing type → ValueError."""
|
||||
with pytest.raises(ValueError, match="is already registered"):
|
||||
SecondaryTierFactory.register_tier("example", "some.module", "SomeClass")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Out-of-tree dynamic loading via module_path
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_create_tier_from_module_path():
|
||||
"""Full end-to-end: create_secondary_tier with module_path."""
|
||||
assert "ExampleSecondaryTierManager" not in SecondaryTierFactory._registry
|
||||
|
||||
primary_kv_view, offloading_spec = _make_mock_args()
|
||||
tier_config = {
|
||||
"type": "ExampleSecondaryTierManager",
|
||||
"module_path": "vllm.v1.kv_offload.tiering.example.manager",
|
||||
"custom_param": 42,
|
||||
}
|
||||
|
||||
tier = SecondaryTierFactory.create_secondary_tier(
|
||||
tier_config, primary_kv_view, offloading_spec
|
||||
)
|
||||
|
||||
assert isinstance(tier, ExampleSecondaryTierManager)
|
||||
assert tier.tier_type == "ExampleSecondaryTierManager"
|
||||
|
||||
|
||||
def test_module_path_invalid_module_raises():
|
||||
"""Non-existent module_path → ModuleNotFoundError."""
|
||||
primary_kv_view, offloading_spec = _make_mock_args()
|
||||
tier_config = {
|
||||
"type": "SomeTier",
|
||||
"module_path": "nonexistent.module.path",
|
||||
}
|
||||
|
||||
with pytest.raises(ModuleNotFoundError):
|
||||
SecondaryTierFactory.create_secondary_tier(
|
||||
tier_config, primary_kv_view, offloading_spec
|
||||
)
|
||||
|
||||
|
||||
def test_module_path_not_subclass_raises():
|
||||
"""module_path resolving to a non-SecondaryTierManager → AssertionError."""
|
||||
tier_config = {
|
||||
"type": "MagicMock",
|
||||
"module_path": "unittest.mock",
|
||||
}
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
SecondaryTierFactory.get_tier_class(tier_config)
|
||||
|
||||
Reference in New Issue
Block a user