From b4aa7dd477acf065a3b9c6a8cf324c904da1a834 Mon Sep 17 00:00:00 2001 From: Gerben van V Date: Tue, 21 Jul 2026 23:58:34 +0200 Subject: [PATCH] mtmd : use align_corners for qwen3vl vision position embedding interpolation (#25781) The Qwen3-VL learned position embedding is interpolated to the runtime patch grid with the default bilinear+antialias (align_corners=False) sampling, while the transformers reference uses align_corners=True (torch.linspace(0, side-1, T)). The mismatch scales grounding coordinates about the image center, growing with image size and per-axis for non-square images (see #16880). --- tools/mtmd/models/qwen3vl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mtmd/models/qwen3vl.cpp b/tools/mtmd/models/qwen3vl.cpp index 261e77a19..48626b221 100644 --- a/tools/mtmd/models/qwen3vl.cpp +++ b/tools/mtmd/models/qwen3vl.cpp @@ -37,7 +37,7 @@ ggml_cgraph * clip_graph_qwen3vl::build() { } // calculate absolute position embedding and apply - ggml_tensor * learned_pos_embd = resize_position_embeddings(); + ggml_tensor * learned_pos_embd = resize_position_embeddings(GGML_SCALE_MODE_BILINEAR | GGML_SCALE_FLAG_ALIGN_CORNERS); learned_pos_embd = ggml_cont_4d( ctx0, learned_pos_embd, n_embd * 2, n_patches_x / 2, n_patches_y, batch_size);