Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions python/sglang/srt/disaggregation/decode_hicache_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,8 @@ def _process_hicache_local_restores(self, decode_reqs: List[DecodeRequest]) -> N
):
dr.hicache_restore_status = HiCacheRestoreResult.READY

# Phase B: queue new load_back ops if the next slot is free.
# The (producer_index + 1) check ensures we never overwrite a still-in-flight slot:
# if a previous req holds that slot and isn't done, its event won't be signaled.
counter = self.tree_cache.cache_controller.layer_done_counter
if not self.tree_cache.is_load_back_event_done(
(counter.producer_index + 1) % counter.num_counters
):
# Phase B: queue new load_back ops if the next slot is free on every rank.
if not self.tree_cache.has_free_load_back_slot():
return
queued = [
dr
Expand Down
18 changes: 6 additions & 12 deletions python/sglang/srt/mem_cache/unified_radix_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3523,25 +3523,19 @@ def ready_to_load_host_cache(self) -> int:
return 0

def is_load_back_event_done(self, consumer_index: int) -> bool:
"""Return True after the local load-back event is complete.

Lets the disagg decode restore state machine
(``DecodeHiCacheTransferMixin``) gate on load-back completion; the
controller-level ``layer_done_counter`` event is shared across cache
implementations, while the tree-side bookkeeping runs in
``loading_check``.
"""
"""Return True after this rank's load-back event is complete."""
if consumer_index < 0 or self.cache_controller is None:
return True

finish_event = self.cache_controller.layer_done_counter.events[
consumer_index
].finish_event
if not finish_event.query():
return False
return finish_event.query()

self.loading_check()
return True
def has_free_load_back_slot(self) -> bool:
"""Acks are reaped in lockstep, so every rank agrees on this."""
cc = self.cache_controller
return len(cc.ack_load_queue) < cc.layer_done_counter.num_counters

# ---- Query / Inspection APIs ----
# These APIs exist for compatibility with other RadixTree implementations.
Expand Down
Loading