From eb572f9ac64efa5087c823550127c3c3f3b4e1a8 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 5 Jul 2024 18:36:55 +0200 Subject: [PATCH] squash! llama : add early return for empty range Remove the setting of cache.head to 0 when the range is empty. Signed-off-by: Daniel Bevenius --- src/llama.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/llama.cpp b/src/llama.cpp index b2c302915..24356d2b4 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -3259,10 +3259,7 @@ static void llama_kv_cache_seq_add( if (p0 < 0) p0 = 0; if (p1 < 0) p1 = std::numeric_limits::max(); // If there is no range then return early to avoid looping over the cache. - if (p0 == p1) { - cache.head = 0; - return; - } + if (p0 == p1) return; if (cache.recurrent) { // for Mamba-like models, only the pos needs to be shifted