From 67268c8fdeeeb3c8fb2d2380cf371d3a7a73496e Mon Sep 17 00:00:00 2001 From: Nexes the Elder <124105151+Nexesenex@users.noreply.github.com> Date: Mon, 13 Apr 2026 07:23:13 +0200 Subject: [PATCH] Fix mixed KV cache: type_v_first used instead of type_v_last for last layers (#1626) In llama_kv_cache_init() call, params.type_v_first was incorrectly passed twice instead of params.type_v_last. This caused V cache in the last N layers to use type_v_first instead of type_v_last. Fix: Replace second params.type_v_first with params.type_v_last. --- src/llama.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llama.cpp b/src/llama.cpp index 069ede9d..c4d8e79f 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -5727,7 +5727,7 @@ struct llama_context * llama_init_from_model( ctx->backends.push_back(ctx->backend_cpu); if (!llama_kv_cache_init(ctx->kv_self, ctx, type_k, type_v, kv_size, cparams.offload_kqv, - params.type_k_first, params.type_k_last, params.type_v_first, params.type_v_first, + params.type_k_first, params.type_k_last, params.type_v_first, params.type_v_last, params.n_k_first, params.n_k_last, params.n_v_first, params.n_v_last)) { LLAMA_LOG_ERROR("%s: llama_kv_cache_init() failed for self-attention cache\n", __func__); llama_free(ctx);