]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
graph : handle non-contiguous Q/K/V in mul_mat_aux (#22630)
authorSigbjørn Skjæret <redacted>
Tue, 5 May 2026 03:34:44 +0000 (05:34 +0200)
committerGitHub <redacted>
Tue, 5 May 2026 03:34:44 +0000 (06:34 +0300)
* qkv may not always be contiguous

* cont : make the cont conditional

---------

Co-authored-by: Georgi Gerganov <redacted>
src/llama-graph.cpp

index c4cf0ccb26251ee0c24f1883141ab89486de6b3c..fe155c92dea0633e85bb5ba81732864bffff3a93 100644 (file)
@@ -65,7 +65,11 @@ static ggml_tensor * ggml_mul_mat_aux(
 
     ggml_tensor * res;
 
-    res = ggml_reshape_2d(ctx, cur, n, ggml_nelements(cur)/n);
+    if (!ggml_is_contiguous(cur)) {
+        res = ggml_cont_2d   (ctx, cur, n, ggml_nelements(cur)/n);
+    } else {
+        res = ggml_reshape_2d(ctx, cur, n, ggml_nelements(cur)/n);
+    }
     res = ggml_mul_mat   (ctx, rot, res);
     ggml_mul_mat_set_hint(res, GGML_HINT_SRC0_IS_HADAMARD);
     res = ggml_reshape_4d(ctx, res, cur->ne[0], cur->ne[1], cur->ne[2], cur->ne[3]);