]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
cuda : fix "V is K view" check for non-unified KV cache (#19145)
authorGeorgi Gerganov <redacted>
Wed, 28 Jan 2026 07:15:27 +0000 (09:15 +0200)
committerGitHub <redacted>
Wed, 28 Jan 2026 07:15:27 +0000 (09:15 +0200)
common/arg.cpp
ggml/src/ggml-cuda/fattn-common.cuh
ggml/src/ggml-cuda/fattn.cu

index 2f68bdc1c08aa0722e98721ba91dd2f04a427c56..cd3a1b639704092eede2afba8d75bf05aa236299 100644 (file)
@@ -1295,9 +1295,10 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
     ).set_env("LLAMA_ARG_CACHE_RAM").set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}));
     add_opt(common_arg(
         {"-kvu", "--kv-unified"},
+        {"-no-kvu", "--no-kv-unified"},
         "use single unified KV buffer shared across all sequences (default: enabled if number of slots is auto)",
-        [](common_params & params) {
-            params.kv_unified = true;
+        [](common_params & params, bool value) {
+            params.kv_unified = value;
         }
     ).set_env("LLAMA_ARG_KV_UNIFIED").set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_PERPLEXITY, LLAMA_EXAMPLE_BATCHED}));
     add_opt(common_arg(
index 3d7daccfdf873b2ef3b4aac14bb742d0460f379a..b6a7460da831dc8e28e9ff5a0c175ef12501de5f 100644 (file)
@@ -789,7 +789,7 @@ void launch_fattn(
     const ggml_tensor * K = dst->src[1];
     const ggml_tensor * V = dst->src[2];
 
-    const bool V_is_K_view = V->view_src && V->view_offs == 0 && (V->view_src == K || V->view_src == K->view_src);
+    const bool V_is_K_view = V->view_src && (V->view_src == K || (V->view_src == K->view_src && V->view_offs == K->view_offs));
 
     const ggml_tensor * mask  = dst->src[3];
     const ggml_tensor * sinks = dst->src[4];
index fe18ff6c7dcf2d61340449df29cf35a1445417db..195904ee2061eb12566f7f2aa64ea7c5b03fc18d 100644 (file)
@@ -310,7 +310,7 @@ static best_fattn_kernel ggml_cuda_get_best_fattn_kernel(const int device, const
         }
     }
 
-    const bool V_is_K_view = V->view_src && V->view_offs == 0 && (V->view_src == K || V->view_src == K->view_src);
+    const bool V_is_K_view = V->view_src && (V->view_src == K || (V->view_src == K->view_src && V->view_offs == K->view_offs));
 
     const int cc = ggml_cuda_info().devices[device].cc;