From 38328bb5998f555285fd32bace3de99937785e60 Mon Sep 17 00:00:00 2001 From: Michael Podvitskiy Date: Wed, 13 Mar 2024 21:48:37 +0100 Subject: [PATCH] fragmentation calculation fix --- llama.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama.cpp b/llama.cpp index c431f769e..a7d53d890 100644 --- a/llama.cpp +++ b/llama.cpp @@ -9037,7 +9037,7 @@ static int llama_decode_internal( // decide if we need to defrag the kv cache if (cparams.defrag_thold >= 0.0f) { - const float fragmentation = kv_self.n >= 128 ? 1.0f - float(kv_self.used + n_tokens_all)/float(kv_self.n) : 0.0f; + const float fragmentation = kv_self.n >= 128 ? 1.0f - float(kv_self.used)/float(kv_self.n) : 0.0f; // queue defragmentation for next llama_kv_cache_update if (fragmentation > cparams.defrag_thold) {