Skip to content

Commit 7766ca5

Browse files
updated
Signed-off-by: [email protected] <[email protected]>
1 parent b0629bd commit 7766ca5

File tree

1 file changed

+20
-24
lines changed
  • vllm/distributed/kv_transfer/kv_connector

1 file changed

+20
-24
lines changed

vllm/distributed/kv_transfer/kv_connector/factory.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
import importlib
4-
from typing import TYPE_CHECKING, Callable, Dict, Optional, Type, Union
4+
from typing import TYPE_CHECKING, Callable, Dict, Type, Union
55

66
import vllm.envs as envs
77
from vllm.distributed.kv_transfer.kv_connector.v1 import (KVConnectorBase_V1,
@@ -47,36 +47,32 @@ def create_connector_v1(
4747
connector_cls = cls._registry[connector_name]()
4848
assert issubclass(connector_cls, KVConnectorBase_V1)
4949
logger.info("Creating v1 connector with name: %s", connector_name)
50+
# NOTE(Kuntai): v1 connector is explicitly separated into two roles.
51+
# Scheduler connector:
52+
# - Co-colate with scheduler process
53+
# - Should only be used inside the Scheduler class
54+
# Worker connector:
55+
# - Co-locate with worker process
56+
# - Should only be used inside the forward context & attention layer
57+
# We build separately to enforce strict separation
5058
return connector_cls(config, role)
5159

5260
@classmethod
53-
def create_connector_v0(cls, rank: Optional[int],
54-
local_rank: Optional[int], config: "VllmConfig",
55-
role: KVConnectorRole) -> KVConnectorBase:
61+
def create_connector_v0(cls, rank: int, local_rank: int,
62+
config: "VllmConfig") -> KVConnectorBase:
63+
if envs.VLLM_USE_V1:
64+
raise ValueError("Attempting to initialize a V0 Connector, "
65+
f"but found {envs.VLLM_USE_V1=}")
66+
5667
connector_name = config.kv_transfer_config.kv_connector
5768
if connector_name not in cls._registry:
5869
raise ValueError(f"Unsupported connector type: {connector_name}")
5970

60-
if envs.VLLM_USE_V1:
61-
# NOTE(Kuntai): v1 connector is explicitly separated into two roles.
62-
# Scheduler connector:
63-
# - Co-colate with scheduler process
64-
# - Should only be used inside the Scheduler class
65-
# Worker connector:
66-
# - Co-locate with worker process
67-
# - Should only be used inside the forward context & attention layer
68-
# We build these two connectors separately to enforce strict
69-
# separation
70-
connector_cls_v1 = cls._registry[connector_name]()
71-
assert issubclass(connector_cls_v1, KVConnectorBase_V1)
72-
logger.info("Creating v1 connector with name: %s", connector_name)
73-
return connector_cls_v1(rank, local_rank, config, role)
74-
else:
75-
assert rank is not None
76-
assert local_rank is not None
77-
connector_cls = cls._registry[connector_name]()
78-
assert issubclass(connector_cls, KVConnectorBase)
79-
return connector_cls(rank, local_rank, config)
71+
assert rank is not None
72+
assert local_rank is not None
73+
connector_cls = cls._registry[connector_name]()
74+
assert issubclass(connector_cls, KVConnectorBase)
75+
return connector_cls(rank, local_rank, config)
8076

8177

8278
# Register various connectors here.

0 commit comments

Comments
 (0)