[HiCache] Reject load-back specs that claim nodes pinned by an in-flight load-back (#35931)
This commit is contained in:
@@ -1927,6 +1927,20 @@ class UnifiedTreeCore(UnifiedTreeCoreInterface):
|
||||
)
|
||||
if t:
|
||||
comp_xfers[comp.component_type] = t
|
||||
# Reject transfers that would claim a node pinned by another load-back
|
||||
# anchor; the empty spec makes the caller back off and recompute.
|
||||
if any(
|
||||
self.node_by_id(nid).load_back_pending_id not in (None, node_id)
|
||||
for xfers in ([kv_xfer], *comp_xfers.values())
|
||||
for xfer in xfers
|
||||
for nid in xfer.nodes_to_load or ()
|
||||
):
|
||||
empty_kv = PoolTransfer(
|
||||
name=PoolName.KV,
|
||||
host_indices=torch.empty((0,), dtype=torch.int64, device="cpu"),
|
||||
nodes_to_load=[],
|
||||
)
|
||||
return empty_kv, {}
|
||||
return kv_xfer, comp_xfers
|
||||
|
||||
def prefetch_anchor_info(
|
||||
|
||||
@@ -1465,8 +1465,10 @@ class UnifiedRadixCache(BasePrefixCache):
|
||||
|
||||
# Skip if there is nothing to load, or if the Full-KV transfer is too
|
||||
# small / exceeds memory quota. Aux transfers should still run even
|
||||
# when the Full-KV load is skipped by thresholding.
|
||||
if (kv_tokens < self.load_back_threshold and not comp_xfers) or (
|
||||
# when the Full-KV load is skipped by thresholding. max(1, ...): an
|
||||
# entirely empty spec (e.g. foreign-pin rejection) must never report
|
||||
# success, even at load_back_threshold <= 0.
|
||||
if (kv_tokens < max(1, self.load_back_threshold) and not comp_xfers) or (
|
||||
mem_quota is not None and kv_tokens > mem_quota + result.delta
|
||||
):
|
||||
self.dec_lock_ref(node_id, ancestor_lock_params)
|
||||
|
||||
Reference in New Issue
Block a user