Skip to content

Commit fc498d8

Browse files
committed
Add improvements from code review comments
Review comments: - vllm-project#28309 (comment) - vllm-project#28309 (comment) Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
1 parent 32ec2d8 commit fc498d8

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

vllm/distributed/kv_events.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ def combine_unique_ordered_events(self, other: "KVEventBatch") -> "KVEventBatch"
7171
"""
7272
Combine non duplicated events with another `KVEventBatch` object.
7373
"""
74-
combined_events = self.events[:]
74+
checked_events = set(self.events)
7575
for item in other.events:
76-
if item not in combined_events:
77-
combined_events.append(item)
78-
self.events = combined_events
76+
if item not in checked_events:
77+
self.events.append(item)
78+
checked_events.add(item)
7979
return self
8080

8181

vllm/v1/worker/kv_connector_model_runner_mixin.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
)
1313

1414
from vllm.config import VllmConfig
15-
from vllm.distributed.kv_events import KVEventBatch
1615
from vllm.distributed.kv_transfer import (
1716
ensure_kv_transfer_shutdown,
1817
get_kv_transfer_group,
1918
has_kv_transfer_group,
2019
)
2120
from vllm.distributed.kv_transfer.kv_connector.base import KVConnectorBase
22-
from vllm.distributed.kv_transfer.kv_connector.v1.metrics import KVConnectorStats
2321
from vllm.forward_context import get_forward_context, set_forward_context
2422
from vllm.logger import init_logger
2523
from vllm.v1.outputs import (
@@ -132,23 +130,13 @@ def _get_kv_connector_output(
132130
kv_connector.get_finished(scheduler_output.finished_req_ids)
133131
)
134132
output.invalid_block_ids = kv_connector.get_block_ids_with_load_errors()
135-
136-
output.kv_connector_stats = (
137-
KVConnectorModelRunnerMixin.get_kv_connector_stats()
138-
)
139-
output.kv_cache_events = (
140-
KVConnectorModelRunnerMixin.get_kv_connector_kv_cache_events()
141-
)
133+
if has_kv_transfer_group():
134+
output.kv_connector_stats = (
135+
get_kv_transfer_group().get_kv_connector_stats()
136+
)
137+
output.kv_cache_events = (
138+
get_kv_transfer_group().get_kv_connector_kv_cache_events()
139+
)
140+
else:
141+
output.kv_connector_stats = output.kv_cache_events = None
142142
kv_connector.clear_connector_metadata()
143-
144-
@staticmethod
145-
def get_kv_connector_stats() -> KVConnectorStats | None:
146-
if has_kv_transfer_group():
147-
return get_kv_transfer_group().get_kv_connector_stats()
148-
return None
149-
150-
@staticmethod
151-
def get_kv_connector_kv_cache_events() -> KVEventBatch | None:
152-
if has_kv_transfer_group():
153-
return get_kv_transfer_group().get_kv_connector_kv_cache_events()
154-
return None

0 commit comments

Comments
 (0)