sched: a preempted request publishes its prefix; the recompute adopts it

Scheduler::preempt_back dropped everything a request had computed: unlike
close_request it published nothing, so a preempted 96.6k-token prompt was
computed again from its first token. The publish block of close_request is
now Scheduler::publish_prefix, called by both. Its blocks stay in the cache,
so a preemption that published gives eviction its rounds back (the decode
ensure loop and the overdue path) and the cache gives them back, the newest
last, before another request is preempted. preempted_can_prefill counts the
blocks the recompute adopts from the cache (pc_->lookup), so a preempted
request is not held back for room its own cached prompt already covers.

Shared KV with RADIANCE_KV_GUARANTEE=1 (nine Qwen requests preempted for
TranslateGemma's start pool): Qwen 587 -> 458 s, TranslateGemma 139 -> 80 s;
without the guarantee unchanged (340 / 58 vs 339 / 56). Test:
a_preempted_request_publishes_its_prefix; sched 187, engine_e2e and the
related suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-11-05 14:59:28 +01:00
1 parent e3d65f3a7c
commit 01c7a3334a
4 files changed
+57 -15

No files matched your search

+2 -1
View File
@@ -821,7 +821,8 @@ private:
const Request* serial_req(const SerialSeq& m) const;
/* Both snapshots resolve the same way; the two wrappers exist because the row types differ. */
const Request* live_req(int32_t slot, uint64_t id) const;
void preempt_back();
bool preempt_back(); /* true: the victim published its prefix */
bool publish_prefix(SchedReq& s);
/* A preempted request waits until the pool can hold its WHOLE remaining recompute, the rest
* of every running prefill, and one block of headroom per runner. Admitting it against only
* the next token steals the blocks a running prefill still needs and preempt_back() resets