Skip to content

Commit 76091ee

Browse files
committed
Change CogVLM CLIP encoder to use SWIGLU
1 parent 66cb20f commit 76091ee

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tools/mtmd/clip.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,6 @@ struct clip_graph {
15961596
cur = build_norm(cur, model.mm_post_fc_norm_w, model.mm_post_fc_norm_b, NORM_TYPE_NORMAL, 1e-5, -1);
15971597

15981598
// Apply GELU
1599-
// TODO: Not 100% sure about gelu and silu configuration
16001599
cur = ggml_gelu_inplace(ctx0, cur);
16011600

16021601
// Branch 1: multiply with mm_h_to_4h_w
@@ -1606,16 +1605,12 @@ struct clip_graph {
16061605
ggml_tensor * gate = ggml_mul_mat(ctx0, model.mm_gate_w, cur);
16071606

16081607
// Apply silu
1609-
gate = ggml_silu_inplace(ctx0, gate);
1610-
1611-
// Multiply together
1612-
cur = ggml_mul(ctx0, gate, h_to_4h);
1608+
gate = ggml_swiglu_split(ctx0, gate, h_to_4h);
16131609

16141610
// Apply mm_4h_to_h_w
1615-
cur = ggml_mul_mat(ctx0, model.mm_4h_to_h_w, cur);
1611+
cur = ggml_mul_mat(ctx0, model.mm_4h_to_h_w, gate);
16161612

16171613
// Concatenate with boi and eoi
1618-
// TODO: The shape may be incorrect
16191614
cur = ggml_concat(ctx0, model.mm_boi, cur, 1);
16201615
cur = ggml_concat(ctx0, cur, model.mm_eoi, 1);
16211616

0 commit comments

Comments
 (0)