From eee8d481d910afeddc20709dd703fff5d012ca7c Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 9 Jun 2025 10:53:26 +0300 Subject: [PATCH] kv-cache : fix shift ggml-ci --- src/llama-kv-cache-unified.cpp | 4 +--- src/llama-kv-cells.h | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/llama-kv-cache-unified.cpp b/src/llama-kv-cache-unified.cpp index 3a40463fd..d8f4e7ffc 100644 --- a/src/llama-kv-cache-unified.cpp +++ b/src/llama-kv-cache-unified.cpp @@ -944,11 +944,9 @@ llm_graph_result_ptr llama_kv_cache_unified::build_graph_shift( const auto & n_embd_head_k = hparams.n_embd_head_k; //const auto & n_embd_head_v = hparams.n_embd_head_v; - //GGML_ASSERT(kv_self->size == n_ctx); - auto inp = std::make_unique(this); - inp->k_shift = ggml_new_tensor_1d(ctx, GGML_TYPE_I32, cparams.n_ctx); + inp->k_shift = ggml_new_tensor_1d(ctx, GGML_TYPE_I32, cells.size()); ggml_set_input(inp->k_shift); for (const auto & layer : layers) { diff --git a/src/llama-kv-cells.h b/src/llama-kv-cells.h index 9e2c4d927..94c842ce0 100644 --- a/src/llama-kv-cells.h +++ b/src/llama-kv-cells.h @@ -317,8 +317,6 @@ public: pos[i] += d; shift[i] += d; - seq_pos_add(i); - has_shift = true; if (pos[i] < 0) { @@ -326,12 +324,15 @@ public: seq[i].reset(); pos[i] = -1; + shift[i] = 0; used.erase(i); return true; } + seq_pos_add(i); + return false; }