Sliding window 30+20 + GEN 0 cache pre-warm (pre-warm-on-change)

Window: MAIN_AREA 30 + BUFFER 20 (same 50 cap) halves rotation frequency. context: shared compose_prefix (byte-exact prefix of compose) + notepad_fingerprint (rendered header body, excludes updated_at). inkling: build_prefix_ids renders without finish_prompt. service: prewarm() sends GEN 0 directly (no PerfMeter/DB). sessions: schedule_prewarm at turn end on pending rotation OR notepad-dirty (ws=0 normalized); session_chat loads only the window subset.

examples/prewarm_bench.rs: joint GEN 0 -> RESUME bench, PASS on HIP (cached==L==385). Verified live all-agent: notepad write -> pre-warm 1468 -> next turn cached_tokens==1468. Tests: prefix property, opener-skip, GEN 0 primitive, notepad fingerprint. Suite 162 passed + 3 ignored.
This commit is contained in:
adm committed 2026-11-26 19:12:59 +01:00
1 parent 0ce84581a4
commit a52bec97d4
12 files changed
+650 -59

No files matched your search

+10
View File
@@ -79,6 +79,16 @@ pub trait Formatter: Send + Sync {
/// Errors map straight to an HTTP 400.
fn build_prompt(&self, req: &ChatRequest) -> Result<Prompt, ApiErrorEnvelope>;
/// Render only the conversation prefix to prompt ids, for cache pre-warming
/// (`GEN 0`): the same messages/tools/effort as the real turn but WITHOUT the
/// generation opener, so the ids are a byte-exact token prefix of the real
/// prompt and the engine's `RESUME` hits. Default: a dialect with no
/// generation suffix already yields the prefix from `build_prompt`; dialects
/// that append an opener (Inkling's `finish_prompt`) override this to skip it.
fn build_prefix_ids(&self, req: &ChatRequest) -> Result<Vec<u32>, ApiErrorEnvelope> {
Ok(self.build_prompt(req)?.ids)
}
/// A fresh output decoder for one request.
fn decoder(&self) -> Box<dyn Decoder>;
}