5
5
from typing import TYPE_CHECKING , Callable
6
6
7
7
import vllm .envs as envs
8
- from vllm .config import KVTransferConfig
9
- from vllm .distributed .kv_transfer .kv_connector .base import KVConnectorBaseType
10
- from vllm .distributed .kv_transfer .kv_connector .v1 import (KVConnectorBase_V1 ,
11
- KVConnectorRole )
8
+ from vllm .distributed .kv_transfer .kv_connector .base import KVConnectorBase
9
+ from vllm .distributed .kv_transfer .kv_connector .v1 import KVConnectorRole
12
10
from vllm .logger import init_logger
13
11
14
- from .base import KVConnectorBase
15
-
16
12
if TYPE_CHECKING :
17
13
from vllm .config import VllmConfig
18
14
19
15
logger = init_logger (__name__ )
20
16
21
17
22
18
class KVConnectorFactory :
23
- _registry : dict [str , Callable [[], type [KVConnectorBaseType ]]] = {}
19
+ _registry : dict [str , Callable [[], type [KVConnectorBase ]]] = {}
24
20
25
21
@classmethod
26
22
def register_connector (cls , name : str , module_path : str ,
@@ -29,28 +25,23 @@ def register_connector(cls, name: str, module_path: str,
29
25
if name in cls ._registry :
30
26
raise ValueError (f"Connector '{ name } ' is already registered." )
31
27
32
- def loader () -> type [KVConnectorBaseType ]:
28
+ def loader () -> type [KVConnectorBase ]:
33
29
module = importlib .import_module (module_path )
34
30
return getattr (module , class_name )
35
31
36
32
cls ._registry [name ] = loader
37
33
38
34
@classmethod
39
- def create_connector_v0 (cls , rank : int , local_rank : int ,
40
- config : "VllmConfig" ) -> KVConnectorBase :
41
- if envs .VLLM_USE_V1 :
42
- raise ValueError ("Attempting to initialize a V0 Connector, "
35
+ def create_connector (
36
+ cls ,
37
+ config : "VllmConfig" ,
38
+ role : KVConnectorRole ,
39
+ ) -> KVConnectorBase :
40
+ if not envs .VLLM_USE_V1 :
41
+ raise ValueError ("Attempting to initialize a V1 Connector, "
43
42
f"but found { envs .VLLM_USE_V1 = } " )
44
43
45
- connector_cls = cls .get_connector_class (config .kv_transfer_config )
46
- assert issubclass (connector_cls , KVConnectorBase )
47
- return connector_cls (rank , local_rank , config )
48
-
49
- @classmethod
50
- def get_connector_class (
51
- cls , kv_transfer_config : "KVTransferConfig"
52
- ) -> type [KVConnectorBaseType ]:
53
- """Get the connector class by name."""
44
+ kv_transfer_config = config .kv_transfer_config
54
45
connector_name = kv_transfer_config .kv_connector
55
46
if connector_name in cls ._registry :
56
47
connector_cls = cls ._registry [connector_name ]()
@@ -61,21 +52,7 @@ def get_connector_class(
61
52
f"Unsupported connector type: { connector_name } " )
62
53
connector_module = importlib .import_module (connector_module_path )
63
54
connector_cls = getattr (connector_module , connector_name )
64
- return connector_cls
65
-
66
- @classmethod
67
- def create_connector_v1 (
68
- cls ,
69
- config : "VllmConfig" ,
70
- role : KVConnectorRole ,
71
- ) -> KVConnectorBase_V1 :
72
- if not envs .VLLM_USE_V1 :
73
- raise ValueError ("Attempting to initialize a V1 Connector, "
74
- f"but found { envs .VLLM_USE_V1 = } " )
75
-
76
- kv_transfer_config = config .kv_transfer_config
77
- connector_cls = cls .get_connector_class (kv_transfer_config )
78
- assert issubclass (connector_cls , KVConnectorBase_V1 )
55
+ assert issubclass (connector_cls , KVConnectorBase )
79
56
logger .info ("Creating v1 connector with name: %s and engine_id: %s" ,
80
57
connector_cls .__name__ , kv_transfer_config .engine_id )
81
58
# NOTE(Kuntai): v1 connector is explicitly separated into two roles.
@@ -92,25 +69,6 @@ def create_connector_v1(
92
69
# Register various connectors here.
93
70
# The registration should not be done in each individual file, as we want to
94
71
# only load the files corresponding to the current connector.
95
- KVConnectorFactory .register_connector (
96
- "PyNcclConnector" ,
97
- "vllm.distributed.kv_transfer.kv_connector.simple_connector" ,
98
- "SimpleConnector" )
99
-
100
- KVConnectorFactory .register_connector (
101
- "MooncakeConnector" ,
102
- "vllm.distributed.kv_transfer.kv_connector.simple_connector" ,
103
- "SimpleConnector" )
104
-
105
- KVConnectorFactory .register_connector (
106
- "LMCacheConnector" ,
107
- "vllm.distributed.kv_transfer.kv_connector.lmcache_connector" ,
108
- "LMCacheConnector" )
109
-
110
- KVConnectorFactory .register_connector (
111
- "MooncakeStoreConnector" ,
112
- "vllm.distributed.kv_transfer.kv_connector.mooncake_store_connector" ,
113
- "MooncakeStoreConnector" )
114
72
115
73
KVConnectorFactory .register_connector (
116
74
"SharedStorageConnector" ,
0 commit comments