fragmentation calculation fix

This commit is contained in:
Michael Podvitskiy 2024-03-13 21:48:37 +01:00
parent 97ad402539
commit 38328bb599

View file

@ -9037,7 +9037,7 @@ static int llama_decode_internal(
// decide if we need to defrag the kv cache // decide if we need to defrag the kv cache
if (cparams.defrag_thold >= 0.0f) { 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 // queue defragmentation for next llama_kv_cache_update
if (fragmentation > cparams.defrag_thold) { if (fragmentation > cparams.defrag_thold) {