Commit 0a069810e for llama.cpp

commit 0a069810e605f3d5486bfea489164dba46647614
Author: Aman Gupta <amangupta052@gmail.com>
Date:   Sat Dec 5 15:45:20 2026 +0800

    qwen4exp : normalize the MTP hidden input over the full hc*n_embd width (#33778)

    The MTP pre-FC hidden norm (nextn.hnorm) was applied per hc stream, with
    the gammas reshaped to [n_embd, hc]. The vLLM and SGLang Qwen4 MTP apply one
    RMSNorm over the whole hc*n_embd residual and only split it into streams
    afterwards. The GGUF already stores the weight as [hc*n_embd], so no
    re-conversion is needed.

    Target output is unchanged. Draft acceptance improves on self-fed draft
    steps (Qwen4-35B-A3B Q4_K_M, draft-mtp depth 3, GB10).

    Fixes #33723

    Assisted-by: Claude Opus 5.5

diff --git a/src/models/qwen4exp.cpp b/src/models/qwen4exp.cpp
index 97b1f3f49..6dd9c2af7 100644
--- a/src/models/qwen4exp.cpp
+++ b/src/models/qwen4exp.cpp
@@ -326,8 +326,8 @@ void llama_model_qwen4exp::load_arch_tensors(llama_model_loader & ml) {
         auto & nextn = layers[il].nextn;
         nextn.eh_proj      = create_tensor(tn(LLM_TENSOR_NEXTN_EH_PROJ,      "weight", il), { 2*n_embd, n_embd }, mtp_flags);
         nextn.enorm        = create_tensor(tn(LLM_TENSOR_NEXTN_ENORM,        "weight", il), { n_embd }, mtp_flags);
-        // RMS per hc stream of the trunk residual, so the gammas load as [n_embd, hc] like the mixer norms
-        nextn.hnorm        = create_tensor(tn(LLM_TENSOR_NEXTN_HNORM,        "weight", il), { n_embd, hc }, mtp_flags | TENSOR_ALLOW_RESHAPE);
+        // one RMS over the whole hc*n_embd trunk residual, not per hc stream (as in the reference MTP)
+        nextn.hnorm        = create_tensor(tn(LLM_TENSOR_NEXTN_HNORM,        "weight", il), { hc_dim }, mtp_flags);
         nextn.hc_head_norm = create_tensor(tn(LLM_TENSOR_NEXTN_HC_HEAD_NORM, "weight", il), { n_embd, hc }, mtp_flags | TENSOR_ALLOW_RESHAPE);
         nextn.hc_head_down = create_tensor(tn(LLM_TENSOR_NEXTN_HC_HEAD_DOWN, "weight", il), { hc_dim, hc_lr }, mtp_flags);
         nextn.hc_head_up   = create_tensor(tn(LLM_TENSOR_NEXTN_HC_HEAD_UP,   "weight", il), { hc_lr, hc_dim }, mtp_flags);
@@ -639,7 +639,8 @@ llama_model_qwen4exp::graph_mtp::graph_mtp(const llm_graph_params & params) :
     ggml_tensor * inp_pos     = build_inp_pos();
     ggml_tensor * inp_out_ids = build_inp_out_ids();

-    ggml_tensor * h_norm = build_norm(ggml_reshape_3d(ctx0, h, n_embd, hc, n_tokens), layer.nextn.hnorm, nullptr, LLM_NORM_RMS, il);
+    ggml_tensor * h_norm = build_norm(h, layer.nextn.hnorm, nullptr, LLM_NORM_RMS, il);
+    h_norm = ggml_reshape_3d(ctx0, h_norm, n_embd, hc, n_tokens);
     cb(h_norm, "mtp_hnorm", il);

     ggml_tensor * e_norm = build_norm(tok_embd, layer.nextn.enorm, nullptr, LLM_NORM_RMS, il);