Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vllm_ascend/distributed/kvpool/ascend_store_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self,
)

assert self.connector_worker is not None
if vllm_config.parallel_config.rank == 0:
if vllm_config.parallel_config.rank == 0 and self.kv_role != "kv_consumer":
self.lookup_server = LookupKeyServer(self.connector_worker,
vllm_config,
self.use_layerwise)
Expand Down
7 changes: 4 additions & 3 deletions vllm_ascend/distributed/kvpool/pool_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
class KVPoolScheduler:

def __init__(self, vllm_config: "VllmConfig", use_layerwise):
self.client = LookupKeyClient(vllm_config)
self.use_layerwise = use_layerwise
self.kv_role = vllm_config.kv_transfer_config.kv_role
self.consumer_is_to_load = vllm_config.kv_transfer_config.kv_connector_extra_config.get(
"consumer_is_to_load", False)
self.load_async = vllm_config.kv_transfer_config.kv_connector_extra_config.get(
"load_async", False)
self.client = LookupKeyClient(
vllm_config) if self.kv_role != "kv_consumer" else None
Comment on lines +29 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The condition for initializing LookupKeyClient is incorrect. If self.kv_role == "kv_consumer" and self.consumer_is_to_load is True, self.client will be None. However, get_num_new_matched_tokens will then attempt to call self.client.lookup, leading to a runtime AttributeError. The client should only be None when it's a consumer that is not configured to load.

Suggested change
self.client = LookupKeyClient(
vllm_config) if self.kv_role != "kv_consumer" else None
if self.kv_role == "kv_consumer" and not self.consumer_is_to_load:
self.client = None
else:
self.client = LookupKeyClient(vllm_config)

# request_id -> (vllm cached tokes, kvpool cached tokens)
self.load_specs: dict[str, LoadSpec] = {}
self.pcp_size = getattr(vllm_config.parallel_config,
Expand Down Expand Up @@ -74,8 +75,8 @@ def get_num_new_matched_tokens(
else:
token_len = len(request.prompt_token_ids)

num_external_hit_tokens = self.client.lookup(token_len,
request.block_hashes)
num_external_hit_tokens = self.client.lookup( # type: ignore[union-attr]
token_len, request.block_hashes)
Comment on lines +78 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

With the suggested fix for the self.client initialization, this type: ignore comment is no longer necessary and should be removed to improve code clarity. The code path that reaches this line will always have self.client initialized.

        num_external_hit_tokens = self.client.lookup(token_len, request.block_hashes)


if num_external_hit_tokens == request.num_tokens:
num_external_hit_tokens -= 1
Expand Down
Loading