From 729eb59f60866d3f7c94b0f6fed05b73eef9f7bb Mon Sep 17 00:00:00 2001 From: maobaolong Date: Tue, 7 Apr 2026 23:03:11 +0800 Subject: [PATCH] [KVConnector]: prioritize external connector over internal registry (#38301) Signed-off-by: baoloongmao Co-authored-by: Chauncey --- .../kv_transfer/kv_connector/factory.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/vllm/distributed/kv_transfer/kv_connector/factory.py b/vllm/distributed/kv_transfer/kv_connector/factory.py index c88b32284..9a6be93a2 100644 --- a/vllm/distributed/kv_transfer/kv_connector/factory.py +++ b/vllm/distributed/kv_transfer/kv_connector/factory.py @@ -107,12 +107,11 @@ class KVConnectorFactory: if connector_name is None: raise ValueError("Connector name is not set in KVTransferConfig") compat_sig = False - if connector_name in cls._registry: - connector_cls = cls._registry[connector_name]() - else: - connector_module_path = kv_transfer_config.kv_connector_module_path - if connector_module_path is None: - raise ValueError(f"Unsupported connector type: {connector_name}") + connector_module_path = kv_transfer_config.kv_connector_module_path + if connector_module_path is not None and not connector_module_path: + raise ValueError("kv_connector_module_path cannot be an empty string.") + if connector_module_path: + # External module path takes priority over internal registry. connector_module = importlib.import_module(connector_module_path) try: connector_cls = getattr(connector_module, connector_name) @@ -128,6 +127,10 @@ class KVConnectorFactory: "Please update to include kv_cache_config as the second argument.", connector_cls.__name__, ) + elif connector_name in cls._registry: + connector_cls = cls._registry[connector_name]() + else: + raise ValueError(f"Unsupported connector type: {connector_name}") return connector_cls, compat_sig @classmethod