mirror of
https://github.com/ollama/ollama.git
synced 2026-09-01 08:51:37 +00:00
A lazy KV snapshot indexes into the cache's live buffer instead of owning a copy, so it must be copied out before an append overwrites the slots it names. appendKV checked for that only on the first append after a rewind, and only against that append's own range: a still-lazy snapshot further ahead in the buffer was overwritten without a copy when a later append reached it. This happens when a request reuses a short prefix of a longer cached conversation and prefills past one of the old conversation's snapshots; restoring that snapshot later silently serves the new request's KV in place of the old conversation's. Scan every append instead. The overlap test already limits copies to snapshots the current write clobbers, and appends outside a rewind refill sit above every snapshot, so the steady-state scan walks a short list and finds nothing. This restores the invariant Restore's lazy fast path relies on: a snapshot still in its lazy state has never been overwritten. |
||
|---|---|---|
| .. | ||
| cache.go | ||
| cache_test.go | ||
| kvcache.go | ||
| lazy_test.go | ||
| recurrent.go | ||
| recurrent_test.go | ||
| rotating.go | ||
| rotating_attention_test.go | ||
| rotating_multiturn_test.go | ||
| snapshot_capture_test.go | ||