[GW][LD][HIP][Proofs] Wire prefix checkpoint cache into serve: restore longest prefix, prefill only new suffix
Concept ported from strata --auto-ckpt, adapted to vetta's contiguous per-pass
KV + ShortConv history (proofs/prefix_cache.lean, restore_equiv). serve_gen now
restores the longest cached STRICT prefix of a prompt and prefills only the new
suffix tokens; the final logits still come from a real forward of the last prompt
token. Checkpoints save at pos (prompt + generated non-EOS tokens) so the next
turn reuses the full prior context. Pinned anchors {512,1024} never evicted (I3),
LRU at cap 6; KV snapshots unpooled (freed on eviction). VETTA_NO_PREFIX_CACHE
forces cold prefill for A/B.
Device-to-device copy FFI (vetta_buf_copy / vetta_buf_copy2d) + DeviceBuf
copy_from/copy2d_from; LayerState snapshot/restore (pitched KV prefix + hist).
Verified: CPU 91 + gw GPU 5 + hip GPU 18 + ld GPU 18 green; Lean 0 sorryAx.
Multi-turn parity EXACT (restore == cold re-prefill), both prewarm- and
decode-state checkpoints. Measured (gfx1150, Inkling-2-Mini, FP16 KV, greedy):
605-token prompt, 600-token cached prefix -> prefill 132.5s cold vs 2.29s warm
(57.8x), end-to-end 133.2s vs 3.2s (41.8x).
This commit is contained in:
1 parent
f12281ec61
commit
736c541887
6 files changed
+220
-10
No files matched your search
@@ -70,7 +70,7 @@ theorem restore_equiv (init : S) (step : S → Tok → S) (ck : Ckpt S) (suffix
|
||||
|
||||
/-- Restoring with an empty suffix reproduces the checkpoint state exactly. -/
|
||||
theorem restore_nil (init : S) (step : S → Tok → S) (ck : Ckpt S)
|
||||
(h : Valid init step ck) : prefill step ck.state [] = ck.state := by
|
||||
(_h : Valid init step ck) : prefill step ck.state [] = ck.state := by
|
||||
simp [prefill]
|
||||
|
||||
/-! ## Part B: validity is intrinsic and preserved by pool operations -/
|
||||
@@ -145,12 +145,12 @@ theorem length_filter_ne_lt {l : List Nat} {a : Nat} (hmem : a ∈ l) :
|
||||
| cons x xs ih =>
|
||||
by_cases hxa : x = a
|
||||
· have hf : (x :: xs).filter (· != a) = xs.filter (· != a) := by
|
||||
simp only [List.filter]; split <;> simp_all [Nat.beq_eq]
|
||||
simp only [List.filter]; split <;> simp_all
|
||||
rw [hf]
|
||||
have := List.length_filter_le (· != a) xs
|
||||
simp; omega
|
||||
· have hf : (x :: xs).filter (· != a) = x :: xs.filter (· != a) := by
|
||||
simp only [List.filter]; split <;> simp_all [Nat.beq_eq]
|
||||
simp only [List.filter]; split <;> simp_all
|
||||
rw [hf]
|
||||
have hmem' : a ∈ xs := by
|
||||
rcases List.mem_cons.mp hmem with h | h
|
||||
|
||||
Reference in new issue
Block a user