Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/models/deepseek41.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,11 @@ ggml_tensor * llama_model_deepseek41::graph::build_attention41(
// add the per-block mask with broadcast, in place: no [n_comp, tokens] mask tensor
// fill a computed node, not a new leaf: a leaf stays allocated for the whole graph
ggml_tensor * bm = ggml_cont(ctx0, ggml_view_3d(ctx0, score, 1, n_blk, nc*n_stream, bs*ggml_element_size(score), score->nb[1], 0));
bm = ggml_fill_inplace(ctx0, bm, -INFINITY);
bm = ggml_fill(ctx0, bm, -INFINITY);
bm = ggml_set_rows(ctx0, bm, zeros, ggml_reshape_3d(ctx0, bsel, k_b, nc*n_stream, 1));
bm = ggml_reshape_4d(ctx0, bm, 1, n_blk, nc, n_stream);
cb(bm, "cand_mask", il);
score = ggml_add_inplace(ctx0, ggml_reshape_4d(ctx0, score, bs, n_blk, nc, n_stream), bm);
score = ggml_add(ctx0, ggml_reshape_4d(ctx0, score, bs, n_blk, nc, n_stream), bm);
score = ggml_reshape_4d(ctx0, score, n_comp, nc, 1, n_stream);
} else {
ggml_tensor * bm = ggml_fill(ctx0, ggml_new_tensor_4d(ctx0, GGML_TYPE_F32, 1, n_blk, nc*n_stream, 1), -INFINITY);
Expand Down
6 changes: 3 additions & 3 deletions src/models/minimax-m3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ llama_model_minimax_m3::graph::graph(const llm_graph_params & params) : llm_grap
// the reference computes the indexer scores in F32: https://github.com/huggingface/transformers/blob/0f53828e83f2212060233d2ea552cc76617b8712/src/transformers/models/minimax_m3_vl/modeling_minimax_m3_vl.py#L562
ggml_prec_set_acc(sc, GGML_PREC_F32);
// unmapped positions come out -inf, so they can never rank into the top-k
sc = ggml_add_inplace(ctx0, sc,
sc = ggml_add(ctx0, sc,
ggml_reshape_4d(ctx0, msa->pos_mask, n_ps, 1, 1, ns));
ggml_tensor * bs = ggml_pool_2d(ctx0, sc, GGML_OP_POOL_MAX, blk, 1, blk, 1, 0, 0);
cb(bs, "msa_bs", il);
Expand Down Expand Up @@ -483,7 +483,7 @@ llama_model_minimax_m3::graph::graph(const llm_graph_params & params) : llm_grap
ggml_prec_set_acc(sc, GGML_PREC_F32);
sc = ggml_reshape_3d(ctx0, sc, n_ps, Hd, n_tps);
// unmapped positions (holes, padding, empty cells) come out -inf
sc = ggml_add_inplace(ctx0, sc, pm_s);
sc = ggml_add(ctx0, sc, pm_s);
ggml_tensor * bs = ggml_pool_2d(ctx0, sc, GGML_OP_POOL_MAX, blk, 1, blk, 1, 0, 0);
cb(bs, "msa_bs", il);

Expand Down Expand Up @@ -514,7 +514,7 @@ llama_model_minimax_m3::graph::graph(const llm_graph_params & params) : llm_grap
ggml_tensor * bmc = ggml_get_rows(ctx0, bm2, cb_s); // [n_tps*Hd, n_kv] F32
ggml_tensor * bmx = ggml_cont(ctx0, ggml_transpose(ctx0, bmc));
bmx = ggml_reshape_3d(ctx0, bmx, n_kv, n_tps, Hd);
ggml_tensor * mask4 = ggml_add_inplace(ctx0, bmx, mf_s);
ggml_tensor * mask4 = ggml_add(ctx0, bmx, mf_s);
mask4 = ggml_cast(ctx0,
ggml_reshape_4d(ctx0, mask4, n_kv, n_tps, 1, Hd), GGML_TYPE_F16);
cb(mask4, "msa_mask4", il);
Expand Down
2 changes: 1 addition & 1 deletion tools/mtmd/models/cogvlm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ggml_cgraph * mtmd_graph_cogvlm::build() {
cur = build_norm(cur, model.mm_post_fc_norm_w, model.mm_post_fc_norm_b, NORM_TYPE_NORMAL, 1e-5, -1);

// Apply GELU
cur = ggml_gelu_inplace(ctx0, cur);
cur = ggml_gelu(ctx0, cur);

// Branch 1: multiply with mm_h_to_4h_w
ggml_tensor * h_to_4h = build_mm(model.mm_h_to_4h_w, cur);
Expand Down
6 changes: 3 additions & 3 deletions tools/mtmd/models/conformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ggml_cgraph * mtmd_graph_conformer::build() {
cb(cur, "conformer.pre_encode.conv.{}", 0);

// layer.1 - relu
cur = ggml_relu_inplace(ctx0, cur);
cur = ggml_relu(ctx0, cur);

// layer.2 conv2d dw
cur = ggml_conv_2d_dw_direct(ctx0, model.pre_encode_conv_X_w[2], cur, 2, 2, 1, 1, 1, 1);
Expand All @@ -36,7 +36,7 @@ ggml_cgraph * mtmd_graph_conformer::build() {
cb(cur, "conformer.pre_encode.conv.{}", 3);

// layer.4 - relu
cur = ggml_relu_inplace(ctx0, cur);
cur = ggml_relu(ctx0, cur);

// layer.5 conv2d dw
cur = ggml_conv_2d_dw_direct(ctx0, model.pre_encode_conv_X_w[5], cur, 2, 2, 1, 1, 1, 1);
Expand All @@ -49,7 +49,7 @@ ggml_cgraph * mtmd_graph_conformer::build() {
cb(cur, "conformer.pre_encode.conv.{}", 6);

// layer.7 - relu
cur = ggml_relu_inplace(ctx0, cur);
cur = ggml_relu(ctx0, cur);

// flatten channel and frequency axis
cur = ggml_cont(ctx0, ggml_permute(ctx0, cur, 0, 2, 1, 3));
Expand Down
6 changes: 3 additions & 3 deletions tools/mtmd/models/lfm3a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ ggml_cgraph * mtmd_graph_lfm3a::build() {

// downsampler, same layout as the lfm2a pre-encoder but with SiLU
cur = conv_down(cur, "ds0", model.pre_encode_conv_X_w[0], model.pre_encode_conv_X_b[0], false);
cur = ggml_silu_inplace(ctx0, cur);
cur = ggml_silu(ctx0, cur);

cur = conv_down(cur, "ds1", model.pre_encode_conv_X_w[2], model.pre_encode_conv_X_b[2], true);
cur = ggml_conv_2d_direct(ctx0, model.pre_encode_conv_X_w[3], cur, 1, 1, 0, 0, 1, 1);
cur = ggml_add(ctx0, cur, model.pre_encode_conv_X_b[3]);
cur = ggml_silu_inplace(ctx0, cur);
cur = ggml_silu(ctx0, cur);

cur = conv_down(cur, "ds2", model.pre_encode_conv_X_w[5], model.pre_encode_conv_X_b[5], true);
cur = ggml_conv_2d_direct(ctx0, model.pre_encode_conv_X_w[6], cur, 1, 1, 0, 0, 1, 1);
cur = ggml_add(ctx0, cur, model.pre_encode_conv_X_b[6]);
cur = ggml_silu_inplace(ctx0, cur);
cur = ggml_silu(ctx0, cur);
cb(cur, "downsample.conv", -1);

// [n_pos, n_mel/8, n_ch] -> [n_ch * n_mel/8, n_pos]
Expand Down
2 changes: 1 addition & 1 deletion tools/mtmd/models/llava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ ggml_cgraph * mtmd_graph_llava::build() {
embeddings = build_mm(model.mm_model_mlp_0_w, embeddings);
embeddings = ggml_norm(ctx0, embeddings, eps);
embeddings = ggml_add(ctx0, ggml_mul(ctx0, embeddings, model.mm_model_ln_q_w), model.mm_model_ln_q_b);
embeddings = ggml_gelu_inplace(ctx0, embeddings);
embeddings = ggml_gelu(ctx0, embeddings);
ggml_tensor * x = embeddings;
embeddings = build_mm(model.mm_model_mlp_2_w, embeddings);
x = build_mm(model.mm_model_mlp_1_w,x);
Expand Down
Loading