Skip to content

Commit 5145566

Browse files
updated
Signed-off-by: [email protected] <[email protected]>
1 parent 62e1421 commit 5145566

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

vllm/distributed/kv_transfer/kv_connector/v1/base.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def get_external_prefix_cache_blocks(
159159
Get the external prefix cache blocks from the connector.
160160
161161
This function may change the state of the connector, which will
162-
be used by `attach_connector_meta` later.
162+
be used by `build_connector_meta` later.
163163
164164
This function will also allocate/free the blocks dynamically when
165165
there is remote cache hit.
@@ -178,13 +178,12 @@ def get_external_prefix_cache_blocks(
178178
pass
179179

180180
@abstractmethod
181-
def attach_connector_meta(
182-
self, scheduler_output: SchedulerOutput) -> SchedulerOutput:
181+
def build_connector_meta(
182+
self, scheduler_output: SchedulerOutput) -> KVConnectorMetadata:
183183
"""
184-
Attach the connector metadata to the request object.
184+
Build the connector metadata for this step.
185185
186-
This function should NOT modify other fields in the scheduler_output
187-
except the `connector_metadata` field.
186+
This function should NOT modify fields in the scheduler_output.
188187
Also, calling this function will reset the state of the connector.
189188
190189
Args:

vllm/distributed/kv_transfer/kv_connector/v1/shared_storage_connector.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_external_prefix_cache_blocks(
221221
"""Get the external prefix cache blocks from the connector.
222222
223223
This function may change the state of the connector, which will be
224-
used by `attach_connector_meta` later.
224+
used by `build_connector_meta` later.
225225
226226
Args:
227227
request (Request): the request object.
@@ -283,12 +283,11 @@ def get_external_prefix_cache_blocks(
283283
else:
284284
return computed_blocks
285285

286-
def attach_connector_meta(
287-
self, scheduler_output: SchedulerOutput) -> SchedulerOutput:
288-
"""Attach the connector metadata to the request object.
286+
def build_connector_meta(
287+
self, scheduler_output: SchedulerOutput) -> KVConnectorMetadata:
288+
"""Build the connector metadata for this step.
289289
290-
This function should NOT modify other fields in the scheduler_output
291-
except the `kv_connector_metadata` field.
290+
This function should NOT modify any fields in the scheduler_output.
292291
Also, calling this function will reset the state of the connector.
293292
294293
Args:
@@ -304,10 +303,9 @@ def attach_connector_meta(
304303
# store and load status
305304
if not self.found_match_for_request(request):
306305
meta.add_request(request, self._block_size, is_store=True)
307-
scheduler_output.kv_connector_metadata = meta
308306

309307
self._requests_need_load.clear()
310-
return scheduler_output
308+
return meta
311309

312310
# ==============================
313311
# Helper functions

vllm/v1/core/sched/scheduler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ def schedule(self) -> SchedulerOutput:
453453
# 2. Wrap up all the KV cache load / save ops into an opaque object
454454
# 3. Clear the internal states of the connector
455455
if self.connector is not None:
456-
scheduler_output = self.connector.attach_connector_meta(
457-
scheduler_output)
456+
meta = self.connector.build_connector_meta(scheduler_output)
457+
scheduler_output.kv_connector_metadata = meta
458458

459459
# Advance the number of computed tokens for the request AFTER
460460
# the request is scheduled.

0 commit comments

Comments
 (0)