[PD] Enable optimistic prefill with buffer-only L3 write-through HiCache (#40043)

Co-authored-by: cctry <csycfl@gmail.com>
This commit is contained in:
Zhiqiang Xie
2026-09-18 16:04:15 -07:00
committed by GitHub
co-authored by cctry
parent 5e4b94b134
commit ceb1d2e580
4 changed files with 161 additions and 9 deletions
+12 -5
View File
@@ -466,13 +466,20 @@ def handle_other_validations(server_args: Any):
"_handle_other_validations",
optimistic_prefill_attempts=0,
)
elif cfg.enable_hierarchical_cache and (
cfg.hicache_storage_backend is not None
or cfg.hicache_write_policy != "write_back"
elif cfg.enable_hierarchical_cache and not (
(
cfg.hicache_storage_backend is None
and cfg.hicache_write_policy == "write_back"
)
or (
cfg.hicache_storage_backend is not None
and cfg.hicache_host_memory_mode == "buffer_only"
and cfg.hicache_write_policy == "write_through"
)
):
logger.warning(
"Optimistic prefill only supports L2 hierarchical cache "
"with write-back policy"
"Optimistic prefill supports L2 write-back or L3 buffer-only "
"write-through hierarchical cache"
)
declare_resolution(
server_args,
@@ -1496,6 +1496,17 @@ class SchedulerDisaggregationPrefillMixin:
"""Release KV cache and requeue an optimistic prefill request."""
max_attempts = get_disagg().optimistic_prefill_attempts
maybe_cache_unfinished_req(req, self.tree_cache)
# 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.
yielded_prefix_len = (
0
if req.skip_radix_cache_insert
else min(
req.kv.cache_protected_len,
req._compute_max_prefix_len(len(req.full_untruncated_fill_ids)),
)
)
self._release_aborted_request(req)
release_kv_cache(req, self.tree_cache)
req.reset_for_retract()
@@ -1510,6 +1521,9 @@ class SchedulerDisaggregationPrefillMixin:
req.pending_bootstrap = True
req.time_stats.reset_prefill_retry_time()
req.advance_cache_request_handle()
# A fresh lookup budget for the new attempt, as after a retraction.
req.storage_prefetch_retry_attempts = 0
req.storage_prefetch_last_match_len = yielded_prefix_len or None
if req.prefill_attempt_count >= max_attempts:
logger.info(
f"Req {req.rid} exhausted optimistic prefill attempts "