]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama : fix shapes for bert/mpt q/k norm (#16409)
authorSigbjørn Skjæret <redacted>
Fri, 3 Oct 2025 12:40:25 +0000 (14:40 +0200)
committerGitHub <redacted>
Fri, 3 Oct 2025 12:40:25 +0000 (14:40 +0200)
src/llama-model.cpp

index 19643d60353fd926f115d31667d5a2bbad857ac9..cce77a854bb2f92c61e8abfad98877e9e9e0d1ce 100644 (file)
@@ -7843,6 +7843,8 @@ struct llm_build_bert : public llm_graph_context {
                 }
 
                 if (model.layers[il].attn_q_norm) {
+                    Qcur = ggml_reshape_2d(ctx0, Qcur, n_embd_head*n_head, n_tokens);
+
                     Qcur = build_norm(Qcur,
                             model.layers[il].attn_q_norm,
                             model.layers[il].attn_q_norm_b,
@@ -7852,6 +7854,8 @@ struct llm_build_bert : public llm_graph_context {
                 }
 
                 if (model.layers[il].attn_k_norm) {
+                    Kcur = ggml_reshape_2d(ctx0, Kcur, n_embd_head*n_head_kv, n_tokens);
+
                     Kcur = build_norm(Kcur,
                             model.layers[il].attn_k_norm,
                             model.layers[il].attn_k_norm_b,
@@ -8234,6 +8238,9 @@ struct llm_build_mpt : public llm_graph_context {
 
                 // Q/K Layernorm
                 if (model.layers[il].attn_q_norm) {
+                    Qcur = ggml_reshape_2d(ctx0, Qcur, n_embd_head*n_head,    n_tokens);
+                    Kcur = ggml_reshape_2d(ctx0, Kcur, n_embd_head*n_head_kv, n_tokens);
+
                     Qcur = build_norm(Qcur,
                             model.layers[il].attn_q_norm,
                             model.layers[il].attn_q_norm_b,