Archived
mem: preserve snapshot-backed prefix KV across recomputes
When a stateful model's cached prefix is host-resident and another request recomputes shared tokens without restoring that entry, PrefixCache::insert can replace KV still referenced by an older recurrent checkpoint. Preserve the first cached copy for snapshot-backed prefixes regardless of tier, while retaining rebinding behavior for non-stateful caches. Add a regression covering a recomputed shared prefix, the original host copy, and its recurrent snapshot. Tests: `ctest --test-dir build-gfx1201 -L '^fast$' --output-on-failure --parallel 24` (96/96 passed).
This commit is contained in:
1 parent
7fa2ec0e4a
commit
f2c892761a
2 files changed
+46
-1
No files matched your search
+4
-1
@@ -368,7 +368,10 @@ int PrefixCache::insert(uint64_t session,
|
||||
for (int64_t b = 0; b < n_full; ++b) {
|
||||
const BlockHash& h = hs[(size_t)b];
|
||||
auto it = map_.find(h);
|
||||
if (it != map_.end() && it->second.in_lru) continue; /* touched below */
|
||||
/* A snapshot-backed prefix keeps its first bytes even in the host tier: a short
|
||||
* recompute can round the KV differently, while older conversations' recurrent snapshots
|
||||
* still depend on the original attention KV. Non-stateful caches may rebind below. */
|
||||
if (it != map_.end() && (it->second.in_lru || has_linear_)) continue; /* touched below */
|
||||
if (it != map_.end()) {
|
||||
/* An off-device entry this request recomputed (a restore that did not fit, or a chain
|
||||
* cut short). Its blocks become the entry's device copy and the tier copy goes
|
||||
|
||||
Reference in new issue
Block a user