Skip to content

Commit 2135bef

Browse files
sdavidbdDavid Ben-David
authored andcommitted
[P/D][V1] Support dynamic loading of external KV connector implementations (vllm-project#18142)
Signed-off-by: David Ben-David <[email protected]> Co-authored-by: David Ben-David <[email protected]> Signed-off-by: Yuqi Zhang <[email protected]>
1 parent fec76ce commit 2135bef

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

vllm/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3524,6 +3524,10 @@ class KVTransferConfig:
35243524
kv_connector_extra_config: dict[str, Any] = field(default_factory=dict)
35253525
"""any extra config that the connector may need."""
35263526

3527+
kv_connector_module_path: Optional[str] = None
3528+
"""The Python module path to dynamically load the KV connector from.
3529+
Only supported in V1."""
3530+
35273531
def compute_hash(self) -> str:
35283532
"""
35293533
WARNING: Whenever a new field is added to this config,

vllm/distributed/kv_transfer/kv_connector/factory.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,17 @@ def create_connector_v1(
5858
raise ValueError("Attempting to initialize a V1 Connector, "
5959
f"but found {envs.VLLM_USE_V1=}")
6060

61-
connector_name = config.kv_transfer_config.kv_connector
62-
connector_cls = cls._registry[connector_name]()
61+
kv_transfer_config = config.kv_transfer_config
62+
connector_name = kv_transfer_config.kv_connector
63+
if connector_name in cls._registry:
64+
connector_cls = cls._registry[connector_name]()
65+
else:
66+
connector_module_path = kv_transfer_config.kv_connector_module_path
67+
if connector_module_path is None:
68+
raise ValueError(
69+
f"Unsupported connector type: {connector_name}")
70+
connector_module = importlib.import_module(connector_module_path)
71+
connector_cls = getattr(connector_module, connector_name)
6372
assert issubclass(connector_cls, KVConnectorBase_V1)
6473
logger.info("Creating v1 connector with name: %s", connector_name)
6574
# NOTE(Kuntai): v1 connector is explicitly separated into two roles.

0 commit comments

Comments
 (0)