[Bugfix][NIXL] Report a full prefix cache hit as finished (#56640)
Signed-off-by: Yizheng Jiao <jyizheng@gmail.com> Signed-off-by: Nick Hill <nickhill123@gmail.com> Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
co-authored by
Nick Hill
parent
e6eb0d120c
commit
381c61e008
@@ -113,7 +113,7 @@ class NixlBaseConnectorScheduler:
|
||||
# New requests are added by update_state_after_alloc in
|
||||
# the scheduler. Used to make metadata passed to Worker.
|
||||
self._reqs_need_recv: dict[
|
||||
ReqId, tuple[Request, BlockIds, tuple[int, ...]]
|
||||
ReqId, tuple[Request, BlockIds, tuple[int, ...], bool]
|
||||
] = {}
|
||||
self._reqs_need_save: dict[ReqId, Request] = {}
|
||||
# Reqs to send and their expiration time
|
||||
@@ -459,13 +459,19 @@ class NixlBaseConnectorScheduler:
|
||||
meta = NixlConnectorMetadata()
|
||||
|
||||
# Loop through scheduled reqs and convert to ReqMeta.
|
||||
for req_id, (req, block_ids, cached) in self._reqs_need_recv.items():
|
||||
for req_id, (
|
||||
req,
|
||||
block_ids,
|
||||
cached,
|
||||
awaiting_kvs,
|
||||
) in self._reqs_need_recv.items():
|
||||
assert req.kv_transfer_params is not None
|
||||
meta.add_new_req_to_recv(
|
||||
request_id=req_id,
|
||||
local_block_ids=block_ids,
|
||||
kv_transfer_params=req.kv_transfer_params,
|
||||
local_num_computed_blocks=cached,
|
||||
awaiting_kvs=awaiting_kvs,
|
||||
)
|
||||
|
||||
if self.use_host_buffer:
|
||||
|
||||
@@ -246,6 +246,9 @@ class ReqMeta:
|
||||
remote_block_size: int | None = None
|
||||
# Remote producer pipeline-parallel size (push mode, D side).
|
||||
pp_size: int = 1
|
||||
# True only when the scheduler parked the request in WAITING_FOR_REMOTE_KVS
|
||||
# and expects it in finished_recving; notify-only recvs must not be reported.
|
||||
awaiting_kvs: bool = False
|
||||
|
||||
|
||||
class NixlConnectorMetadata(KVConnectorMetadata):
|
||||
@@ -275,6 +278,7 @@ class NixlConnectorMetadata(KVConnectorMetadata):
|
||||
local_block_ids: BlockIds,
|
||||
kv_transfer_params: dict[str, Any],
|
||||
local_num_computed_blocks: tuple[int, ...] = (),
|
||||
awaiting_kvs: bool = False,
|
||||
) -> ReqMeta:
|
||||
return ReqMeta(
|
||||
local_block_ids=local_block_ids,
|
||||
@@ -285,6 +289,7 @@ class NixlConnectorMetadata(KVConnectorMetadata):
|
||||
remote_block_size=kv_transfer_params.get("remote_block_size"),
|
||||
pp_size=kv_transfer_params.get("pp_size", 1),
|
||||
local_num_computed_blocks=local_num_computed_blocks,
|
||||
awaiting_kvs=awaiting_kvs,
|
||||
)
|
||||
|
||||
def add_new_req_to_save(
|
||||
@@ -303,11 +308,13 @@ class NixlConnectorMetadata(KVConnectorMetadata):
|
||||
local_block_ids: BlockIds,
|
||||
kv_transfer_params: dict[str, Any],
|
||||
local_num_computed_blocks: tuple[int, ...] = (),
|
||||
awaiting_kvs: bool = False,
|
||||
):
|
||||
req = self._add_new_req(
|
||||
local_block_ids,
|
||||
kv_transfer_params,
|
||||
local_num_computed_blocks,
|
||||
awaiting_kvs,
|
||||
)
|
||||
req.remote = RemoteMeta(
|
||||
block_ids=kv_transfer_params["remote_block_ids"],
|
||||
|
||||
@@ -172,6 +172,9 @@ class NixlPullConnectorScheduler(NixlBaseConnectorScheduler):
|
||||
request,
|
||||
local_block_ids,
|
||||
local_num_computed_blocks,
|
||||
# Parked in WAITING_FOR_REMOTE_KVS only when there is
|
||||
# something to pull; a full local hit stays RUNNING.
|
||||
num_external_tokens > 0,
|
||||
)
|
||||
|
||||
else:
|
||||
@@ -224,7 +227,7 @@ class NixlPullConnectorScheduler(NixlBaseConnectorScheduler):
|
||||
# To avoid stranding the prefill blocks in the prefill instance,
|
||||
# we must add empty block_ids to _reqs_need_recv so that our
|
||||
# worker side will notify and free blocks in the prefill instance.
|
||||
self._reqs_need_recv[request.request_id] = (request, [], ())
|
||||
self._reqs_need_recv[request.request_id] = (request, [], (), False)
|
||||
params["do_remote_prefill"] = False
|
||||
return False, None
|
||||
|
||||
|
||||
@@ -303,6 +303,7 @@ class NixlPullConnectorWorker(NixlBaseConnectorWorker):
|
||||
local_dram_handle=local_dram_handle,
|
||||
remote_xfer_side_handle=remote_xfer_side_handle,
|
||||
expected_consumers=plan.local_consumers,
|
||||
awaiting_kvs=meta.awaiting_kvs,
|
||||
):
|
||||
return
|
||||
|
||||
@@ -327,6 +328,7 @@ class NixlPullConnectorWorker(NixlBaseConnectorWorker):
|
||||
local_dram_handle: int | None,
|
||||
remote_xfer_side_handle: int,
|
||||
expected_consumers: int,
|
||||
awaiting_kvs: bool,
|
||||
) -> bool:
|
||||
"""
|
||||
Post a READ point-to-point xfer request from a single local worker to
|
||||
@@ -387,6 +389,11 @@ class NixlPullConnectorWorker(NixlBaseConnectorWorker):
|
||||
remote_agent_name=agent_name,
|
||||
)
|
||||
self.xfer_stats.record_failed_notification()
|
||||
# Report even on notification failure: the KV is already local, and
|
||||
# an unreported parked request would hold its blocks forever.
|
||||
# Notify-only recvs must stay unreported (scheduler asserts).
|
||||
if awaiting_kvs:
|
||||
self._recving_transfers.setdefault(request_id, [])
|
||||
return True
|
||||
|
||||
if read_spec.block_ids_by_region:
|
||||
|
||||
@@ -198,7 +198,7 @@ class NixlPushConnectorScheduler(NixlBaseConnectorScheduler):
|
||||
# ReqMeta without a KeyError — the actual remote block IDs are
|
||||
# learned by P over the NIXL handshake at WRITE time.
|
||||
params["remote_block_ids"] = ()
|
||||
self._reqs_need_recv[request.request_id] = (request, local_block_ids, ())
|
||||
self._reqs_need_recv[request.request_id] = (request, local_block_ids, (), False)
|
||||
|
||||
# Mark as processed so a re-entry (e.g. preemption + reschedule)
|
||||
# doesn't re-stage the registration.
|
||||
@@ -240,7 +240,7 @@ class NixlPushConnectorScheduler(NixlBaseConnectorScheduler):
|
||||
# recv so the worker emits a notif that lets P free them.
|
||||
# Seed remote_block_ids so add_new_req_to_recv won't KeyError.
|
||||
params["remote_block_ids"] = ()
|
||||
self._reqs_need_recv[request.request_id] = (request, [], ())
|
||||
self._reqs_need_recv[request.request_id] = (request, [], (), False)
|
||||
params["do_remote_prefill"] = False
|
||||
return False, None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user