From c4f3e3be3336c2c20f68d7486f7117871d6d32f3 Mon Sep 17 00:00:00 2001 From: "minke.yu" Date: Fri, 9 Oct 2026 11:22:42 +0800 Subject: [PATCH] refactor: route disagg prefill checkpoints through checkpoint_disagg_prefill shim Upstream #42035's tests and call structure expect Scheduler.checkpoint_disagg_prefill (introduced upstream with #41520's checkpoint_kv_cache / insert_req cache API). This branch still uses maybe_cache_unfinished_req (old cache_unfinished_req API), so add a thin shim with the upstream name and route the three call sites through it. No behavior change. --- python/sglang/srt/disaggregation/prefill.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/disaggregation/prefill.py b/python/sglang/srt/disaggregation/prefill.py index 9e3286a336..e4c8b08258 100644 --- a/python/sglang/srt/disaggregation/prefill.py +++ b/python/sglang/srt/disaggregation/prefill.py @@ -969,7 +969,7 @@ class SchedulerDisaggregationPrefillMixin: advance_logprob_pt(i, req) continue - maybe_cache_unfinished_req(req, self.tree_cache) + self.checkpoint_disagg_prefill(req) self.disagg_prefill_inflight_queue.append(req) if self.spec_algorithm.is_eagle() and draft_input is not None: req.output_topk_p = draft_input.topk_p[i] @@ -1326,7 +1326,7 @@ class SchedulerDisaggregationPrefillMixin: chunked_req_to_exclude = set() if (req := self.chunked_req) is not None: chunked_req_to_exclude.add(req) - maybe_cache_unfinished_req(req, self.tree_cache, chunked=True) + self.checkpoint_disagg_prefill(req, chunked=True) if not self.check_bootstrap(req): if is_aborted(req): @@ -1622,10 +1622,21 @@ class SchedulerDisaggregationPrefillMixin: else: self.disagg_prefill_pending_chunk_rids.add(req.rid) + def checkpoint_disagg_prefill( + self: Scheduler, req: Req, chunked: bool = False + ) -> None: + """Publish the request's computed prefix to the tree cache. + + Name shim for the #42035-era call structure: this branch predates + #41520's ``checkpoint_kv_cache`` / ``insert_req`` cache API, so the + equivalent here is ``maybe_cache_unfinished_req``. + """ + maybe_cache_unfinished_req(req, self.tree_cache, chunked=chunked) + def optimistic_release_and_requeue(self: Scheduler, req: Req) -> None: """Release KV cache and requeue an optimistic prefill request.""" max_attempts = get_disagg().optimistic_prefill_attempts - maybe_cache_unfinished_req(req, self.tree_cache) + self.checkpoint_disagg_prefill(req) # The cached prefix is evictable once the KV is released. Its length # (capped at what a retry can match) seeds the retry's storage baseline, # so an evicted prefix is looked up in L3 once before it is recomputed.