sched: checkpoint sliding windows at prefill intervals

Keep intermediate window snapshots as well as the prompt-tail snapshot so a tail edit can resume below its divergence instead of re-prefilling the entire matched prefix. Reuse the existing checkpoint retention policy and preserve the pre-template-divergence tail boundary.

Add scheduler and cache regression tests for interval snapshots, aligned prompt tails, constrained chunk budgets, and edited-prefix lookup. Update the geometry report and guide to describe periodic window snapshots.
This commit is contained in:
John authored and StillDeadcode committed 2026-10-24 11:08:38 +02:00
1 parent 9eaf10da6e
commit 192fe10278
6 files changed
+89 -16

No files matched your search

+5 -5
View File
@@ -126,14 +126,14 @@ int chunk_geometry_resolve(const Program& prog, const Config& cfg, ChunkGeometry
* retention.
*
* Without linear state there are no checkpoints, except for a trunk window under a prefix
* cache, which snapshots the window behind a prompt's tail (window_ckpt) without splitting
* chunks. */
* cache, which snapshots the window at interval boundaries and the prompt's tail
* (window_ckpt). */
if ((has_linear || (has_window && cfg.prefix_cache)) && cfg.checkpoint_interval > 0)
g.checkpoint_interval = align_up(cfg.checkpoint_interval, g.quantum);
else
g.checkpoint_interval = 0;
g.window_ckpt = !has_linear && g.checkpoint_interval > 0;
/* A window snapshot splits no chunk (plan_chunk), so there is no interval grid to span. */
/* Window checkpoints do not support skipping snapshots inside a prefill span. */
g.span = (g.checkpoint_interval > 0 && !g.window_ckpt && cfg.prefill_span > 1)
? cfg.prefill_span : 1;
g.shared_tok = prefill_shared_tok(cfg);
@@ -153,9 +153,9 @@ int chunk_geometry_resolve(const Program& prog, const Config& cfg, ChunkGeometry
/* Log the effective chunk length. `plan_chunk` splits at the checkpoint interval first, so
* when the interval is below --max-num-batched-tokens, raising the budget does not change the
* chunk; the log line makes that visible. A window snapshot splits nothing. */
* chunk; the log line makes that visible. */
const int64_t span_tok = g.checkpoint_interval * g.span;
const int64_t eff = (g.checkpoint_interval > 0 && !g.window_ckpt && span_tok < cfg.max_tok)
const int64_t eff = (g.checkpoint_interval > 0 && span_tok < cfg.max_tok)
? span_tok : cfg.max_tok;
RAD_INFO("chunk geometry: quantum %lld (attn block %lld, state chunk %lld), checkpoint "
"interval %lld, max_tok %lld -> prefill chunks of at most %lld%s",