Commit 01592dc58 for llama.cpp

commit 01592dc58b105ea6c7e38e4b348cb5d5e2e2bbc2
Author: Georgi Gerganov <ggerganov@gmail.com>
Date:   Thu Nov 19 13:31:50 2026 +0200

    llama : remove redundant fields from llm_graph_params (#32596)

    llm_graph_params no longer carries hparams, prec_policy and hdmd, since the model reference already provides them. llm_graph_context sources them from the model and keeps prec_policy as a reference.

    Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

diff --git a/src/llama-context.cpp b/src/llama-context.cpp
index 6cd39ac7d..6252147a7 100644
--- a/src/llama-context.cpp
+++ b/src/llama-context.cpp
@@ -3095,7 +3095,6 @@ llm_graph_params llama_context::graph_params(
                           llm_graph_type   gtype) const {
     return {
         /*.model       =*/ &model,
-        /*.hparams     =*/ model.hparams,
         /*.cparams     =*/ cparams,
         /*.ubatch      =*/ ubatch,
         /*.gtype       =*/ gtype,
@@ -3106,8 +3105,6 @@ llm_graph_params llama_context::graph_params(
         /*.mctx        =*/ mctx,
         /*.cross       =*/ &cross,
         /*.moe_cache   =*/ moe_cache.get(),
-        /*.prec_policy =*/ &model.prec_policy,
-        /*.hdmd        =*/ model.hdmd.rot.empty() ? nullptr : &model.hdmd,
         /*.layer_inp_dev =*/ layer_inp_dev,
         /*.layer_inp_src =*/ supports_embd_row() ? cparams.ctx_other->get_layer_inp_dev() : nullptr,
         /*.h_nextn_dev   =*/ cparams.embeddings_nextn_dev ? h_nextn_dev : nullptr,
diff --git a/src/llama-graph.cpp b/src/llama-graph.cpp
index 58c5b6c9c..6706e238e 100644
--- a/src/llama-graph.cpp
+++ b/src/llama-graph.cpp
@@ -1594,9 +1594,10 @@ void llm_graph_result::set_params(const llm_graph_params & params) {

 llm_graph_context::llm_graph_context(const llm_graph_params & params) :
     model            (*params.model),
-    hparams          (params.hparams),
+    hparams          (model.hparams),
     cparams          (params.cparams),
     ubatch           (params.ubatch),
+    prec_policy      (model.prec_policy),
     n_embd           (hparams.n_embd),
     n_layer          (hparams.n_layer()),
     n_layer_nextn    (hparams.n_layer_nextn),
@@ -1630,8 +1631,7 @@ llm_graph_context::llm_graph_context(const llm_graph_params & params) :
     mctx             (params.mctx),
     cross            (params.cross),
     moe_cache        (params.moe_cache),
-    prec_policy      (params.prec_policy),
-    hdmd             (params.hdmd),
+    hdmd             (model.hdmd.rot.empty() ? nullptr : &model.hdmd),
     layer_inp_dev    (params.layer_inp_dev),
     layer_inp_src    (params.layer_inp_src),
     h_nextn_dev      (params.h_nextn_dev),
@@ -1728,9 +1728,7 @@ ggml_tensor * llm_graph_context::build_lora_mm(
     ggml_tensor * cur_mm = build_hadamard_input(w, cur);
     ggml_tensor * res = ggml_mul_mat(ctx0, w, cur_mm);

-    if (prec_policy) {
-        prec_policy->apply(res);
-    }
+    prec_policy.apply(res);

     if (w->type == GGML_TYPE_NVFP4) {
         ggml_prec_set_acc(res, GGML_PREC_BF16);
@@ -1812,9 +1810,7 @@ ggml_tensor * llm_graph_context::build_lora_mm_id(
         ggml_mul_mat_id(ctx0, w, cur_mm, ids) :
         ggml_mul_mat_id(ctx0, cached ? moe_cache->get_experts(w) : w, cur_mm, slots);

-    if (prec_policy) {
-        prec_policy->apply(res);
-    }
+    prec_policy.apply(res);

     if (w->type == GGML_TYPE_NVFP4) {
         ggml_prec_set_acc(res, GGML_PREC_BF16);
diff --git a/src/llama-graph.h b/src/llama-graph.h
index 862e64e05..06ccc4075 100644
--- a/src/llama-graph.h
+++ b/src/llama-graph.h
@@ -804,7 +804,6 @@ class llm_graph_result;
 struct llm_graph_params {
     const llama_model * model = nullptr;

-    llama_hparams hparams;
     llama_cparams cparams;

     llama_ubatch ubatch; // note: intentionally make a copy
@@ -820,10 +819,6 @@ struct llm_graph_params {
     const llama_cross            * cross;
     const llama_moe_cache        * moe_cache;

-    const llama_prec_policy * prec_policy = nullptr;
-
-    const llama_hadamard * hdmd = nullptr;
-
     ggml_tensor * layer_inp_dev = nullptr; // own layer input device buffer (write)
     ggml_tensor * layer_inp_src = nullptr; // ctx_other's layer input device buffer (read)
     ggml_tensor * h_nextn_dev   = nullptr; // own h_nextn device buffer (write)
@@ -1056,6 +1051,8 @@ struct llm_graph_context {
     const llama_cparams & cparams;
     const llama_ubatch  & ubatch;

+    const llama_prec_policy & prec_policy;
+
     const int64_t n_embd;
     const int64_t n_layer;
     const int64_t n_layer_nextn;
@@ -1096,8 +1093,6 @@ struct llm_graph_context {
     const llama_cross            * cross;
     const llama_moe_cache        * moe_cache;

-    const llama_prec_policy * prec_policy;
-
     const llama_hadamard * hdmd;

     ggml_tensor * layer_inp_dev;