Attempt to fix #1438 (#1439)

This commit is contained in:
Kawrakow 2026-03-16 08:34:17 +01:00 committed by GitHub
parent 56f4e9e673
commit d83b0172b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -1183,12 +1183,18 @@ static uint32_t llama_kv_cache_cell_max(const struct llama_kv_cache & cache) {
}
static uint32_t llama_kv_cache_cell_max(const struct llama_kv_cache & cache, uint32_t pad) {
uint32_t last = cache.size;
for (uint32_t i = cache.size; i > 0; i -= pad) {
const llama_kv_cell & cell = cache.cells[i - 1];
if (cell.pos >= 0 && !cell.is_empty()) {
for (uint32_t j = last; j > i; --j) {
auto & cell_j = cache.cells[j - 1];
if (cell_j.pos >= 0 && !cell_j.is_empty()) return j;
}
return i;
}
last = i;
}
return 0;