Skip to content

Commit c770cf4

Browse files
committed
mtmd: pad mask for qwen2.5vl
1 parent dd52868 commit c770cf4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/mtmd/clip.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,14 @@ struct clip_graph {
761761
ggml_set_name(window_mask, "window_mask");
762762
ggml_set_input(window_mask);
763763

764+
// if flash attn is used, we need to pad the mask
765+
if (ctx->flash_attn_type == CLIP_FLASH_ATTN_TYPE_ENABLED) {
766+
int padded_nrow = GGML_PAD(window_mask->ne[1], GGML_KQ_MASK_PAD);
767+
window_mask = ggml_pad(ctx0, window_mask,
768+
0, padded_nrow - window_mask->ne[0], 0, 0);
769+
window_mask = ggml_cast(ctx0, window_mask, GGML_TYPE_F16);
770+
}
771+
764772
// inpL shape: [n_embd, n_patches_x * n_patches_y, batch_size]
765773
GGML_ASSERT(batch_size == 1);
766774
inpL = ggml_reshape_2d(ctx0, inpL, n_embd * 4, n_patches_x * n_patches_y * batch_size / 4);

0 commit comments

Comments
 (0)