From 2f4fe20a9a220e8967e73c4d1f8736c469cff13f Mon Sep 17 00:00:00 2001 From: havok2-htwo Date: Mon, 12 Oct 2026 05:24:28 +0200 Subject: [PATCH] serve: STRATA_SLOT_CKPT_MOVE honours the #879 flush (no resume from a tainted slot's checkpoint) Upstream's non-finite flush only marks running slots `tainted`; their checkpoints stayed. With STRATA_SLOT_CKPT_MOVE a running slot's checkpoints are a resume source (active_source) and a slot's moved turn checkpoint can be restored into the main session (lent_slot), so a request right after the flush, logged as "reading this prompt from token 0", still continued from a pre-flush checkpoint. - the flush drops a running slot's checkpoints too (only with STRATA_SLOT_CKPT_MOVE, the one reader of them; they go back to the checkpoint pool) - active_source and the lent_slot search skip tainted slots Checked with STRATA_NAN_INJECT=600 on the T16-142gsc setup (next turns of chats still running in slots): before, the two requests after the flush resumed 1628 tokens from slots 0 and 8 ("gave back ... its turn checkpoint"); now both read 1661 tokens from token 0. A next turn before the flush still resumes from its running slot. Default path (switch off) unchanged. --- src/program/generate.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 839fc861..05cb4577 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -11328,6 +11328,13 @@ int main(int argc, char** argv) { if (sl.active) { // a running slot finishes its reply, but is not kept as a cache after it sl.tainted = true; ++n_running; + // STRATA_SLOT_CKPT_MOVE reads a running slot's checkpoints (and a finished one's: lent_slot): + // they predate the flush, so they go now + if (slot_ckpt_move_env()) { + if (ckpt_pool.on()) + for (ConvCheckpoint& c : sl.checks) ckpt_pool.give(std::move(c)); + sl.checks.clear(); + } } else if (sl.cached) { sl.cached = false; sl.partial = false; @@ -11358,7 +11365,7 @@ int main(int argc, char** argv) { int64_t moved_in = -1; if (slot_ckpt_move_env() && o.prompt_cache > 0 && want_cvec == cvec_cached && live_ok) for (int b = 0; b < (int) bs.size(); ++b) { - if (bs[(size_t) b].cvec != cvec_cached) continue; + if (bs[(size_t) b].cvec != cvec_cached || bs[(size_t) b].tainted) continue; // (#879) for (const ConvCheckpoint& c : bs[(size_t) b].checks) { const int64_t L = (int64_t) c.ids.size(); if (L > resume && L <= (int64_t) live.size() && starts_with(c.ids, c.imgs) && @@ -11383,7 +11390,8 @@ int main(int argc, char** argv) { const bool idle_source = !sl.active && sl.cached; // (an active slot only where the drafter's rows come along or are not drafted from: the copy // takes the main layers' cells, so the main drafter would keep another conversation's below it) - const bool active_source = sl.active && slot_ckpt_move_env() && (!use_mtp || batch_mtp || admit_slot >= 0); + const bool active_source = sl.active && !sl.tainted && slot_ckpt_move_env() && + (!use_mtp || batch_mtp || admit_slot >= 0); if (sl.cvec != want_cvec || !(idle_source || active_source)) continue; if (idle_source && (int64_t) sl.ids.size() > std::max(resume, slot_tokens) && starts_with(sl.ids, {})) { slot_source = b;