From: Andrei Date: Wed, 3 Jun 2026 19:51:18 +0000 (-0700) Subject: mtmd: fix Gemma 4 unified FPE (#24088) X-Git-Tag: upstream/0.0.10438~942 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=94a220cd6745e6e3f8de62870b66fd5b9bc92700;p=pkg%2Fggml%2Fsources%2Fllama.cpp mtmd: fix Gemma 4 unified FPE (#24088) --- diff --git a/tools/mtmd/clip.cpp b/tools/mtmd/clip.cpp index 1abde5fb5..200819815 100644 --- a/tools/mtmd/clip.cpp +++ b/tools/mtmd/clip.cpp @@ -247,11 +247,11 @@ clip_graph::clip_graph(clip_ctx * ctx, const clip_image_f32 & img) : n_embd(hparams.n_embd), n_head(hparams.n_head), n_head_kv(hparams.n_head_kv), - d_head(n_embd / n_head), + d_head(n_head > 0 ? n_embd / n_head : 0), n_layer(hparams.n_layer), n_mmproj_embd(clip_n_mmproj_embd(ctx)), eps(hparams.eps), - kq_scale(1.0f / sqrtf((float)d_head)), + kq_scale(d_head > 0 ? 1.0f / sqrtf((float)d_head) : 0.0f), flash_attn_type(ctx->flash_attn_type) { struct ggml_init_params params = { /*.mem_size =*/ ctx->buf_compute_meta.size(),