Commit a105b1924 for llama.cpp
commit a105b192467c08611c1a00aec4f322bb947275ee
Author: Aman Gupta <amangupta052@gmail.com>
Date: Sat Dec 5 11:13:38 2026 +0800
qwen4exp : MTP eh_proj as one matmul over all streams and tokens (#33702)
diff --git a/src/models/qwen4exp.cpp b/src/models/qwen4exp.cpp
index e88a12ee9..97b1f3f49 100644
--- a/src/models/qwen4exp.cpp
+++ b/src/models/qwen4exp.cpp
@@ -646,7 +646,10 @@ llama_model_qwen4exp::graph_mtp::graph_mtp(const llm_graph_params & params) :
e_norm = ggml_repeat_4d(ctx0, ggml_reshape_3d(ctx0, e_norm, n_embd, 1, n_tokens), n_embd, hc, n_tokens, 1);
cb(e_norm, "mtp_enorm", il);
- ggml_tensor * res_hc = build_lora_mm(layer.nextn.eh_proj, ggml_concat(ctx0, e_norm, h_norm, 0)); // [n_embd, hc, n_tokens]
+ // one matmul over all hc*n_tokens rows: a 3D input runs as n_tokens matmuls of hc columns each
+ ggml_tensor * eh_in = ggml_concat(ctx0, e_norm, h_norm, 0); // [2*n_embd, hc, n_tokens]
+ ggml_tensor * res_hc = build_lora_mm(layer.nextn.eh_proj, ggml_reshape_2d(ctx0, eh_in, 2*n_embd, hc*n_tokens));
+ res_hc = ggml_reshape_3d(ctx0, res_hc, n_embd, hc, n_tokens);
cb(res_hc, "mtp_eh_proj", il);
hc_mix attn_mix = build_hc_mix(res_hc, layer.hc_attn_norm, layer.hc_attn_down, layer.hc_attn_up, layer.hc_attn_inject, layer.hc_attn_down_inject, il);