Archived
sched: a prefix hit on a sliding-window model resumes from a snapshot of the window behind it
The prefix cache cannot index a windowed group, so every hit on a windowed
trunk re-prefilled the whole prompt (73620ef). Gemma 4 31B (50 of 60 layers
windowed at 1024) paid that on every chat and agent turn: 17-48 s to the
first token at 25-49k tokens.
A model with a window and no linear state now takes one checkpoint per
prompt, a block short of its end -- the next turn re-renders the last few
tokens -- if the prompt is --checkpoint-interval tokens or longer, and does
not split chunks at the interval. The prefix cache treats the window like
linear state: a hit is reusable at a checkpoint only. admit_one adopts the
full-attention blocks as before, seeds the windowed groups at the window's
floor, and the entry's restore fills them from the slot; anything else
re-prefills as before. A model with both linear state and a window keeps
refusing the hit.
Measured on Gemma 4 31B, TP 2, agent transcripts: a follow-up turn's first
token in 0.8-3.4 s instead of 17-48 s; greedy output byte-identical to a
cold prefill with the same chunk boundaries (32 turns, chains five hits
deep, thinking on and off).
This commit is contained in:
1 parent
93389679e8
commit
e35052abfe
7 files changed
+70
-8
No files matched your search
@@ -48,6 +48,12 @@ struct ChunkGeometry {
|
||||
/* Every contributor by name, for the startup line and for the refusal. Built once. */
|
||||
std::string why;
|
||||
|
||||
/* NO LINEAR STATE, A SLIDING WINDOW: the checkpoint snapshots the window behind a prompt's
|
||||
* tail (KVManager::has_window_snapshot) and nothing else. Chunks are not split at the
|
||||
* interval -- a window snapshot in the middle of a prompt buys a later hit nothing its tail
|
||||
* does not -- and the interval is only the shortest prompt worth a snapshot. */
|
||||
bool window_ckpt = false;
|
||||
|
||||
bool checkpoints() const { return checkpoint_interval > 0; }
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user