mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-19 17:24:57 +02:00
kv-cache: check the mirrored slot layout on a whole-context restore too
state_read_meta only looked at the layout it was given on the single-sequence path. A whole-context restore lays the cells out from 0 in both caches, so they agree as long as they restore the same number of cells, but nothing checked that they did: an indexer section belonging to some other context was read over cells the attention cache had filled from a different one, which is the state the indexer must never be left in.
This commit is contained in:
@@ -2352,6 +2352,14 @@ bool llama_kv_cache::state_read_meta(llama_io_read_i & io, uint32_t strm, uint32
|
||||
return false;
|
||||
}
|
||||
|
||||
// the cells go in from 0, so a mirrored cache lands on the same ones as long as it
|
||||
// restores the same count. the layout itself carries no more information here
|
||||
if (sinfo_in && (sinfo_in->empty() || sinfo_in->n_stream() != 1 || sinfo_in->idxs[0].size() != cell_count)) {
|
||||
LLAMA_LOG_ERROR("%s: mirrored slot layout holds %d cells, this cache restores %d\n", __func__,
|
||||
sinfo_in->empty() ? 0 : (int) sinfo_in->idxs[0].size(), cell_count);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < cell_count; ++i) {
|
||||
llama_pos pos;
|
||||
uint32_t n_seq_id;
|
||||
|
||||
Reference in New Issue
Block a user