]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
clip: (minicpmv) fix resampler kq_scale (#17516)
authorHan Qingzhe <redacted>
Wed, 26 Nov 2025 20:44:07 +0000 (04:44 +0800)
committerGitHub <redacted>
Wed, 26 Nov 2025 20:44:07 +0000 (21:44 +0100)
* debug:"solve minicpmv precision problem"

* “debug minicpmv”

* Apply suggestion from @ngxson

---------

Co-authored-by: Xuan-Son Nguyen <redacted>
tools/mtmd/clip.cpp

index abdb778f7afb87d4fdeec2adae2b525ad61437f9..52ea542decc2c9c5731369fbc975e0a2c55848ec 100644 (file)
@@ -1175,10 +1175,11 @@ struct clip_graph {
             cb(K, "resampler_K", -1);
             cb(V, "resampler_V", -1);
 
+            float resampler_kq_scale = 1.0f/ sqrtf(float(d_head));
             embeddings = build_attn(
                 model.mm_model_attn_o_w,
                 model.mm_model_attn_o_b,
-                Q, K, V, nullptr, kq_scale, -1);
+                Q, K, V, nullptr, resampler_kq_scale, -1);
             cb(embeddings, "resampler_attn_out", -1);
         }
         // layernorm