Skip to content

Commit f2764f3

Browse files
authored
fix: offload all KV blocks when doing prefill in P/D (#1649)
Signed-off-by: AlpinDale <alpindale@gmail.com>
1 parent 1d9d9b5 commit f2764f3

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • aphrodite/distributed/kv_transfer/kv_connector/v1/offloading

aphrodite/distributed/kv_transfer/kv_connector/v1/offloading/scheduler.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ def update_state_after_alloc(self, request: Request, blocks: KVCacheBlocks, num_
288288
num_locally_computed_tokens = req_status.num_locally_computed_tokens
289289
num_cached_tokens = num_locally_computed_tokens + num_external_tokens
290290

291+
params = req_status.req_context.kv_transfer_params
292+
do_remote_decode = params is not None and params.get("do_remote_decode")
293+
291294
keys_to_load: list[OffloadKey] = []
292295
dst_block_ids: list[int] = []
293296
# per group
@@ -326,7 +329,11 @@ def update_state_after_alloc(self, request: Request, blocks: KVCacheBlocks, num_
326329
group_sizes.append(num_pending_gpu_blocks)
327330
block_indices.append(num_locally_computed_gpu_blocks)
328331

329-
group_state.next_stored_block_idx = num_blocks
332+
if not do_remote_decode:
333+
# For P/D prefill requests (do_remote_decode=True), we do
334+
# NOT skip saving the hit prefix, as we need to stream the
335+
# entire KV cache so a remote decode node can consume it.
336+
group_state.next_stored_block_idx = num_blocks
330337

331338
src_spec = self.manager.prepare_load(keys_to_load, req_status.req_context)
332339
dst_spec = GPULoadStoreSpec(dst_block_ids, group_sizes=group_sizes, block_indices=block_indices)

0 commit comments

Comments
 (0)