Skip to content

Commit c257a88

Browse files
committed
cont : fix defrag erasing cells that didn't move
ggml-ci
1 parent d564e04 commit c257a88

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/llama-kv-cache-unified.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ bool llama_kv_cache_unified::update(llama_context * lctx, bool do_shift, const d
462462
for (uint32_t i = 0; i < n_kv; ++i) {
463463
assert(dinfo.ids[i] <= n_kv);
464464

465-
if (dinfo.ids[i] == n_kv) {
465+
if (dinfo.ids[i] == n_kv || dinfo.ids[i] == i) {
466466
continue;
467467
}
468468

src/llama-kv-cells.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ class llama_kv_cells_unified {
8080
assert(isrc < pos.size());
8181
assert(idst < pos.size());
8282

83+
assert(pos[idst] == -1);
84+
assert(pos[isrc] != -1);
85+
8386
pos [idst] = pos [isrc];
8487
shift[idst] = shift[isrc];
8588
seq [idst] = seq [isrc];

0 commit comments

Comments
 (0)