Skip to content

LLM inference in C/C++

C++ ggml

graph: skip the LM head for pooled embeddings (#30445)

Pascalcb55ffe6e214
diff --git a/include/llama.h b/include/llama.h
index 6f76c819f8..f15ca9f75d 100644
--- a/include/llama.h
+++ b/include/llama.h
@@ -405,7 +405,7 @@ extern "C" {
void * abort_callback_data;
// Keep the booleans together and at the end of the struct to avoid misalignment during copy-by-value.
- bool embeddings; // if true, extract embeddings (together with logits)
+ bool embeddings; // if true, extract embeddings (together with logits, except for a pooling type other than NONE)
bool offload_kqv; // offload the KQV ops (including the KV cache) to GPU
bool no_perf; // measure performance timings
bool op_offload; // offload host tensor operations to device
diff --git a/src/llama-context.cpp b/src/llama-context.cpp
index 9d54c326ad..9ee64b5667 100644
--- a/src/llama-context.cpp
+++ b/src/llama-context.cpp
@@ -1323,10 +1323,12 @@ void llama_context::set_abort_callback(bool (*abort_callback)(void * data), void
void llama_context::set_embeddings(bool value) {
LLAMA_LOG_DEBUG("%s: value = %d\n", __func__, value);
- cparams.embeddings = value;
+ // a pooled context computes the logits only without embeddings, so the toggle changes the graph shape
+ if (cparams.embeddings != value && cparams.pooling_type != LLAMA_POOLING_TYPE_NONE) {
+ sched_need_reserve = true;
+ }
- // TODO: not sure yet if we want to reserve here
- //sched_need_reserve = true;
+ cparams.embeddings = value;
}
void llama_context::set_embeddings_nextn(bool value, bool masked) {
@@ -2233,7 +2235,6 @@ uint32_t llama_context::output_reserve(int32_t n_outputs) {
const auto n_embd = hparams.n_embd;
const auto n_embd_out = hparams.n_embd_out();
- // LFM2 builds logits only when embeddings are off, and set_embeddings() does not re-reserve
bool has_logits = !cparams.embeddings || graph_has_logits;
bool has_embd = cparams.embeddings;
bool has_embd_nextn = cparams.embeddings_nextn;
diff --git a/src/llama-graph.cpp b/src/llama-graph.cpp
index 91af274731..9039e47fd8 100644
--- a/src/llama-graph.cpp
+++ b/src/llama-graph.cpp
@@ -4063,6 +4063,18 @@ void llm_graph_context::build_pooling(
ggml_build_forward_expand(gf, cur);
}
+void llm_graph_context::build_logits() const {
+ // a pooled embeddings context outputs one vector per sequence, so its graph skips the LM head
+ if (cparams.embeddings && pooling_type != LLAMA_POOLING_TYPE_NONE) {
+ res->t_logits = nullptr;
+ }
+
+ // the models declare t_logits without expanding it, so the LM head is computed only when it is expanded here
+ if (res->t_logits != nullptr) {
+ ggml_build_forward_expand(gf, res->t_logits);
+ }
+}
+
void llm_graph_context::build_sampling() const {
if (samplers.empty() || !res->t_logits) {
return;
diff --git a/src/llama-graph.h b/src/llama-graph.h
index fbbe67f25b..e853a02695 100644
--- a/src/llama-graph.h
+++ b/src/llama-graph.h
@@ -1429,6 +1429,12 @@ struct llm_graph_context {
ggml_tensor * cls_out_b,
ggml_tensor * cls_norm) const;
+ //
+ // logits
+ //
+
+ void build_logits() const;
+
//
// sampling (backend sampling)
//
diff --git a/src/llama-model.cpp b/src/llama-model.cpp
index e57ede5fdb..7072d029c9 100644
--- a/src/llama-model.cpp
+++ b/src/llama-model.cpp
@@ -3305,6 +3305,9 @@ ggml_cgraph * llama_model::build_graph(const llm_graph_params & params) const {
// add on pooling layer
llm->build_pooling(cls, cls_b, cls_out, cls_out_b, cls_norm);
+ // add the LM head (if the context outputs logits)
+ llm->build_logits();
+
// add backend sampling layers (if any)
llm->build_sampling();
diff --git a/src/models/afmoe.cpp b/src/models/afmoe.cpp
index 08c22b6ed8..266597a355 100644
--- a/src/models/afmoe.cpp
+++ b/src/models/afmoe.cpp
@@ -278,6 +278,4 @@ llama_model_afmoe::graph::graph(const llama_model & model, const llm_graph_param
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/apertus.cpp b/src/models/apertus.cpp
index 6dfb8905fb..130980e32a 100644
--- a/src/models/apertus.cpp
+++ b/src/models/apertus.cpp
@@ -165,6 +165,4 @@ llama_model_apertus::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/arcee.cpp b/src/models/arcee.cpp
index 9536e7c5d4..81e3b828f7 100644
--- a/src/models/arcee.cpp
+++ b/src/models/arcee.cpp
@@ -152,6 +152,4 @@ llama_model_arcee::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/arctic.cpp b/src/models/arctic.cpp
index 09ee0f752f..1a170f0856 100644
--- a/src/models/arctic.cpp
+++ b/src/models/arctic.cpp
@@ -175,6 +175,4 @@ llama_model_arctic::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/arwkv7.cpp b/src/models/arwkv7.cpp
index b38b206478..5f1ca4384d 100644
--- a/src/models/arwkv7.cpp
+++ b/src/models/arwkv7.cpp
@@ -197,6 +197,4 @@ llama_model_arwkv7::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/baichuan.cpp b/src/models/baichuan.cpp
index 585f361417..b7f5b05f8b 100644
--- a/src/models/baichuan.cpp
+++ b/src/models/baichuan.cpp
@@ -150,6 +150,4 @@ llama_model_baichuan::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/bailingmoe.cpp b/src/models/bailingmoe.cpp
index 9d1073ae14..2da47f09fd 100644
--- a/src/models/bailingmoe.cpp
+++ b/src/models/bailingmoe.cpp
@@ -175,6 +175,4 @@ llama_model_bailingmoe::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/bailingmoe2.cpp b/src/models/bailingmoe2.cpp
index 24fc4e0226..d7003ef7e5 100644
--- a/src/models/bailingmoe2.cpp
+++ b/src/models/bailingmoe2.cpp
@@ -206,6 +206,4 @@ llama_model_bailingmoe2::graph::graph(const llama_model & model, const llm_graph
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/bailingmoe3.cpp b/src/models/bailingmoe3.cpp
index abbc30fdf9..49c0f7feac 100644
--- a/src/models/bailingmoe3.cpp
+++ b/src/models/bailingmoe3.cpp
@@ -412,7 +412,6 @@ llama_model_bailingmoe3::graph::graph(const llama_model & model, const llm_graph
cur = ggml_mul_mat(ctx0, model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
llama_model_bailingmoe3::graph_mtp::graph_mtp(const llama_model & model, const llm_graph_params & params) :
@@ -555,5 +554,4 @@ llama_model_bailingmoe3::graph_mtp::graph_mtp(const llama_model & model, const l
cur = ggml_mul_mat(ctx0, model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/bitnet.cpp b/src/models/bitnet.cpp
index c833027458..a08881b9f6 100644
--- a/src/models/bitnet.cpp
+++ b/src/models/bitnet.cpp
@@ -165,6 +165,4 @@ llama_model_bitnet::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/bloom.cpp b/src/models/bloom.cpp
index 609d2ddf99..54ef3a0375 100644
--- a/src/models/bloom.cpp
+++ b/src/models/bloom.cpp
@@ -146,6 +146,4 @@ llama_model_bloom::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/chameleon.cpp b/src/models/chameleon.cpp
index 4f45acecf8..bb597afef2 100644
--- a/src/models/chameleon.cpp
+++ b/src/models/chameleon.cpp
@@ -199,6 +199,4 @@ llama_model_chameleon::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/chatglm.cpp b/src/models/chatglm.cpp
index 7ae5b938fd..54e3913c4a 100644
--- a/src/models/chatglm.cpp
+++ b/src/models/chatglm.cpp
@@ -156,6 +156,4 @@ llama_model_chatglm::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/codeshell.cpp b/src/models/codeshell.cpp
index de53bb9818..be1e576197 100644
--- a/src/models/codeshell.cpp
+++ b/src/models/codeshell.cpp
@@ -148,6 +148,4 @@ llama_model_codeshell::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/cogvlm.cpp b/src/models/cogvlm.cpp
index bc394b3c1a..2e1416be89 100644
--- a/src/models/cogvlm.cpp
+++ b/src/models/cogvlm.cpp
@@ -155,5 +155,4 @@ llama_model_cogvlm::graph::graph(const llama_model & model, const llm_graph_para
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/cohere2.cpp b/src/models/cohere2.cpp
index 7ad5244e42..969b4ef05a 100644
--- a/src/models/cohere2.cpp
+++ b/src/models/cohere2.cpp
@@ -154,6 +154,4 @@ llama_model_cohere2::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/cohere2moe.cpp b/src/models/cohere2moe.cpp
index 19362e5c11..649682610e 100644
--- a/src/models/cohere2moe.cpp
+++ b/src/models/cohere2moe.cpp
@@ -275,8 +275,6 @@ llama_model_cohere2moe::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
llama_model_cohere2moe::graph_mtp::graph_mtp(const llama_model & model, const llm_graph_params & params) : llm_graph_context(params) {
@@ -426,6 +424,4 @@ llama_model_cohere2moe::graph_mtp::graph_mtp(const llama_model & model, const ll
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/command-r.cpp b/src/models/command-r.cpp
index 94a46188bb..edf74c57b3 100644
--- a/src/models/command-r.cpp
+++ b/src/models/command-r.cpp
@@ -139,6 +139,4 @@ llama_model_command_r::graph::graph(const llama_model & model, const llm_graph_p
}
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/dbrx.cpp b/src/models/dbrx.cpp
index 4f5ac4d06a..8d4f783fbd 100644
--- a/src/models/dbrx.cpp
+++ b/src/models/dbrx.cpp
@@ -149,6 +149,4 @@ llama_model_dbrx::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/deci.cpp b/src/models/deci.cpp
index cdfcf29e02..ce5de887c7 100644
--- a/src/models/deci.cpp
+++ b/src/models/deci.cpp
@@ -186,6 +186,4 @@ llama_model_deci::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/deepseek.cpp b/src/models/deepseek.cpp
index a47a9c3daf..a066d4fb60 100644
--- a/src/models/deepseek.cpp
+++ b/src/models/deepseek.cpp
@@ -189,6 +189,4 @@ llama_model_deepseek::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/deepseek2.cpp b/src/models/deepseek2.cpp
index 2d56dfb22b..5fd24d105f 100644
--- a/src/models/deepseek2.cpp
+++ b/src/models/deepseek2.cpp
@@ -406,7 +406,6 @@ llama_model_deepseek2::graph_mtp::graph_mtp(const llama_model & model, const llm
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
llama_model_deepseek2::graph::graph(const llama_model & model, const llm_graph_params & params) :
@@ -703,6 +702,4 @@ llama_model_deepseek2::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/deepseek32.cpp b/src/models/deepseek32.cpp
index 98f34a2000..083b32ecf4 100644
--- a/src/models/deepseek32.cpp
+++ b/src/models/deepseek32.cpp
@@ -475,8 +475,6 @@ llama_model_deepseek32::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// LLM_GRAPH_TYPE_DECODER_MTP draft head for DeepSeek V3.2 (DEEPSEEK32).
@@ -716,6 +714,5 @@ llama_model_deepseek32::graph_mtp::graph_mtp(const llama_model & model, const ll
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/deepseek4.cpp b/src/models/deepseek4.cpp
index 50864b2cbe..af04dddd39 100644
--- a/src/models/deepseek4.cpp
+++ b/src/models/deepseek4.cpp
@@ -1353,8 +1353,6 @@ llama_model_deepseek4::graph::graph(const llama_model & model, const llm_graph_p
cur = ggml_mul_mat(ctx0, model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
@@ -1502,5 +1500,4 @@ llama_model_deepseek4::graph_mtp::graph_mtp(const llama_model & model, const llm
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/dflash.cpp b/src/models/dflash.cpp
index 3f426f5664..aeeadbbd15 100644
--- a/src/models/dflash.cpp
+++ b/src/models/dflash.cpp
@@ -841,8 +841,6 @@ llama_model_dflash::graph<false>::graph(const llama_model & model, const llm_gra
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
-
// DSpark: bias the draft logits with the Markov head
if (model.dspark_markov_w1) {
build_dspark_markov_head(*this, model, inp_tokens);
@@ -1022,8 +1020,6 @@ llama_model_dflash::graph_dsv4::graph_dsv4(const llama_model & model, const llm_
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
-
if (model.dspark_markov_w1) {
build_dspark_markov_head(*this, model, inp_tokens);
}
diff --git a/src/models/dots1.cpp b/src/models/dots1.cpp
index a3a85748ef..f29f669c21 100644
--- a/src/models/dots1.cpp
+++ b/src/models/dots1.cpp
@@ -188,6 +188,4 @@ llama_model_dots1::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/dots3note.cpp b/src/models/dots3note.cpp
index 0991c488e4..237a923714 100644
--- a/src/models/dots3note.cpp
+++ b/src/models/dots3note.cpp
@@ -471,6 +471,4 @@ llama_model_dots3note::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/dream.cpp b/src/models/dream.cpp
index abe737c335..7d5ffa56a5 100644
--- a/src/models/dream.cpp
+++ b/src/models/dream.cpp
@@ -133,6 +133,4 @@ llama_model_dream::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/eagle3.cpp b/src/models/eagle3.cpp
index bfde35e43b..d473407590 100644
--- a/src/models/eagle3.cpp
+++ b/src/models/eagle3.cpp
@@ -321,8 +321,6 @@ llama_model_eagle3::graph<false>::graph(const llama_model & model, const llm_gra
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
std::unique_ptr<llm_graph_context> llama_model_eagle3::build_arch_graph(const llm_graph_params & params) const {
diff --git a/src/models/ernie4-5-moe.cpp b/src/models/ernie4-5-moe.cpp
index 8d9ff13867..6bf539d213 100644
--- a/src/models/ernie4-5-moe.cpp
+++ b/src/models/ernie4-5-moe.cpp
@@ -128,6 +128,4 @@ llama_model_ernie4_5_moe::graph::graph(const llama_model & model, const llm_grap
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/ernie4-5.cpp b/src/models/ernie4-5.cpp
index 7bf7be648a..b7a6e9629c 100644
--- a/src/models/ernie4-5.cpp
+++ b/src/models/ernie4-5.cpp
@@ -159,6 +159,4 @@ llama_model_ernie4_5::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/exaone-moe.cpp b/src/models/exaone-moe.cpp
index 840da5f678..1a09d544d5 100644
--- a/src/models/exaone-moe.cpp
+++ b/src/models/exaone-moe.cpp
@@ -234,6 +234,4 @@ llama_model_exaone_moe::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/exaone.cpp b/src/models/exaone.cpp
index 676fb37b5a..070bfd568e 100644
--- a/src/models/exaone.cpp
+++ b/src/models/exaone.cpp
@@ -131,6 +131,4 @@ llama_model_exaone::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/exaone4.cpp b/src/models/exaone4.cpp
index c1c55957a4..80447908e1 100644
--- a/src/models/exaone4.cpp
+++ b/src/models/exaone4.cpp
@@ -181,8 +181,6 @@ llama_model_exaone4::graph<iswa>::graph(const llama_model & model, const llm_gra
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// Explicit template instantiations
diff --git a/src/models/falcon-h1.cpp b/src/models/falcon-h1.cpp
index d6ef2d5198..a7f9e55765 100644
--- a/src/models/falcon-h1.cpp
+++ b/src/models/falcon-h1.cpp
@@ -204,6 +204,4 @@ llama_model_falcon_h1::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/falcon.cpp b/src/models/falcon.cpp
index b2ad90b327..555468a475 100644
--- a/src/models/falcon.cpp
+++ b/src/models/falcon.cpp
@@ -156,6 +156,4 @@ llama_model_falcon::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/gemma.cpp b/src/models/gemma.cpp
index 651cd7e64d..1da4ad8150 100644
--- a/src/models/gemma.cpp
+++ b/src/models/gemma.cpp
@@ -134,6 +134,4 @@ llama_model_gemma::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/gemma2.cpp b/src/models/gemma2.cpp
index 9e52434655..c405e6400f 100644
--- a/src/models/gemma2.cpp
+++ b/src/models/gemma2.cpp
@@ -170,6 +170,4 @@ llama_model_gemma2::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/gemma3.cpp b/src/models/gemma3.cpp
index 83cb57f997..4c8183cce9 100644
--- a/src/models/gemma3.cpp
+++ b/src/models/gemma3.cpp
@@ -213,8 +213,6 @@ llama_model_gemma3::graph<iswa>::graph(const llama_model & model, const llm_grap
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
template struct llama_model_gemma3::graph<false>;
diff --git a/src/models/gemma3n.cpp b/src/models/gemma3n.cpp
index 50d30c63f6..f2e5ae6c85 100644
--- a/src/models/gemma3n.cpp
+++ b/src/models/gemma3n.cpp
@@ -309,8 +309,6 @@ llama_model_gemma3n::graph::graph(const llama_model & model, const llm_graph_par
}
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_gemma3n::graph::calc_magnitude(ggml_tensor * x) {
diff --git a/src/models/gemma4-assistant.cpp b/src/models/gemma4-assistant.cpp
index b6c29183e8..6ebc3c3e8e 100644
--- a/src/models/gemma4-assistant.cpp
+++ b/src/models/gemma4-assistant.cpp
@@ -201,6 +201,5 @@ llama_model_gemma4_assistant::graph::graph(const llama_model & model, const llm_
cb(h_next, "h_nextn", -1);
res->t_h_nextn = h_next;
- ggml_build_forward_expand(gf, logits);
ggml_build_forward_expand(gf, h_next);
}
diff --git a/src/models/gemma4.cpp b/src/models/gemma4.cpp
index d883384375..f4f80d3960 100644
--- a/src/models/gemma4.cpp
+++ b/src/models/gemma4.cpp
@@ -439,8 +439,6 @@ llama_model_gemma4::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
class llm_graph_input_gemma4_ple : public llm_graph_input_i {
diff --git a/src/models/glm-dsa.cpp b/src/models/glm-dsa.cpp
index 596d86a61f..a9d62c0768 100644
--- a/src/models/glm-dsa.cpp
+++ b/src/models/glm-dsa.cpp
@@ -515,8 +515,6 @@ llama_model_glm_dsa::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// LLM_GRAPH_TYPE_DECODER_MTP draft head for GLM-5.2 (GLM_DSA).
@@ -756,5 +754,4 @@ llama_model_glm_dsa::graph_mtp::graph_mtp(const llama_model & model, const llm_g
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/glm4-moe.cpp b/src/models/glm4-moe.cpp
index 341d18a94e..d19eb553f8 100644
--- a/src/models/glm4-moe.cpp
+++ b/src/models/glm4-moe.cpp
@@ -280,7 +280,6 @@ llama_model_glm4_moe::graph_mtp::graph_mtp(const llama_model & model, const llm_
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
llama_model_glm4_moe::graph::graph(const llama_model & model, const llm_graph_params & params) : llm_graph_context(params) {
@@ -434,6 +433,4 @@ llama_model_glm4_moe::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/glm4.cpp b/src/models/glm4.cpp
index 463be809d8..a6cb0889b6 100644
--- a/src/models/glm4.cpp
+++ b/src/models/glm4.cpp
@@ -181,6 +181,4 @@ llama_model_glm4::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/glm5-next.cpp b/src/models/glm5-next.cpp
index 14224e64fb..32199a2603 100644
--- a/src/models/glm5-next.cpp
+++ b/src/models/glm5-next.cpp
@@ -667,7 +667,6 @@ llama_model_glm5_next::graph_mtp::graph_mtp(const llama_model & model, const llm
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
llama_model_glm5_next::graph::graph(const llama_model & model, const llm_graph_params & params) :
@@ -800,8 +799,6 @@ llama_model_glm5_next::graph::graph(const llama_model & model, const llm_graph_p
cur = ggml_mul_mat(ctx0, model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// KDA layer, g_a/g_b output gate
diff --git a/src/models/gpt2.cpp b/src/models/gpt2.cpp
index 45afbccc12..d6ca64744f 100644
--- a/src/models/gpt2.cpp
+++ b/src/models/gpt2.cpp
@@ -143,6 +143,4 @@ llama_model_gpt2::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/gptneox.cpp b/src/models/gptneox.cpp
index ed5e8c50da..bc8a9fd4a9 100644
--- a/src/models/gptneox.cpp
+++ b/src/models/gptneox.cpp
@@ -214,6 +214,4 @@ llama_model_gptneox::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/granite-hybrid.cpp b/src/models/granite-hybrid.cpp
index c177ae7875..fb3bf7024b 100644
--- a/src/models/granite-hybrid.cpp
+++ b/src/models/granite-hybrid.cpp
@@ -195,8 +195,6 @@ llama_model_granite_hybrid::graph::graph(const llama_model & model, const llm_gr
}
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_granite_hybrid::graph::build_attention_layer(ggml_tensor * cur,
diff --git a/src/models/granite-swa.cpp b/src/models/granite-swa.cpp
index 08d9e8a542..f683ef6e8e 100644
--- a/src/models/granite-swa.cpp
+++ b/src/models/granite-swa.cpp
@@ -193,8 +193,6 @@ llama_model_granite_swa::graph::graph(
cur = ggml_scale(ctx0, cur, 1.0f / hparams.f_logit_scale);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_granite_swa::graph::build_attention_layer(
diff --git a/src/models/granite-switch.cpp b/src/models/granite-switch.cpp
index 044c8e6996..a73fcdaff5 100644
--- a/src/models/granite-switch.cpp
+++ b/src/models/granite-switch.cpp
@@ -326,8 +326,6 @@ llama_model_granite_switch::graph::graph(
cur = ggml_scale(ctx0, cur, 1.0f / hparams.f_logit_scale);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_granite_switch::graph::build_attention_layer(
diff --git a/src/models/granite.cpp b/src/models/granite.cpp
index 60d463aeda..4cac495953 100644
--- a/src/models/granite.cpp
+++ b/src/models/granite.cpp
@@ -198,8 +198,6 @@ llama_model_granite::graph::graph(
cur = ggml_scale(ctx0, cur, 1.0f / hparams.f_logit_scale);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_granite::graph::build_attention_layer(
diff --git a/src/models/grok.cpp b/src/models/grok.cpp
index cb6afc3a70..1a125d94e3 100644
--- a/src/models/grok.cpp
+++ b/src/models/grok.cpp
@@ -218,6 +218,4 @@ llama_model_grok::graph::graph(const llama_model & model, const llm_graph_params
}
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/grovemoe.cpp b/src/models/grovemoe.cpp
index f32f3e9ed9..b2648a13a8 100644
--- a/src/models/grovemoe.cpp
+++ b/src/models/grovemoe.cpp
@@ -188,6 +188,4 @@ llama_model_grovemoe::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/hrm-text.cpp b/src/models/hrm-text.cpp
index 8b3337c0bd..912a430f40 100644
--- a/src/models/hrm-text.cpp
+++ b/src/models/hrm-text.cpp
@@ -208,6 +208,4 @@ llama_model_hrm_text::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/hunyuan-moe.cpp b/src/models/hunyuan-moe.cpp
index cedc3b53eb..779575eee0 100644
--- a/src/models/hunyuan-moe.cpp
+++ b/src/models/hunyuan-moe.cpp
@@ -182,6 +182,4 @@ llama_model_hunyuan_moe::graph::graph(const llama_model & model, const llm_graph
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/hunyuan-vl.cpp b/src/models/hunyuan-vl.cpp
index 18b6eaf8cd..fa7183190e 100644
--- a/src/models/hunyuan-vl.cpp
+++ b/src/models/hunyuan-vl.cpp
@@ -186,6 +186,4 @@ llama_model_hunyuan_vl::graph::graph(const llama_model & model, const llm_graph_
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/hy-v3.cpp b/src/models/hy-v3.cpp
index 037191da8d..080b30c1a5 100644
--- a/src/models/hy-v3.cpp
+++ b/src/models/hy-v3.cpp
@@ -217,8 +217,6 @@ llama_model_hy_v3::graph::graph(const llama_model & model, const llm_graph_param
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// LLM_GRAPH_TYPE_DECODER_MTP draft head for HY V3 (MoE).
@@ -380,5 +378,4 @@ llama_model_hy_v3::graph_mtp::graph_mtp(const llama_model & model, const llm_gra
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/hy-v4.cpp b/src/models/hy-v4.cpp
index ee41787ba3..25e40abf7b 100644
--- a/src/models/hy-v4.cpp
+++ b/src/models/hy-v4.cpp
@@ -596,6 +596,4 @@ llama_model_hy_v4::graph::graph(const llama_model & model, const llm_graph_param
cur = ggml_mul_mat(ctx0, model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/internlm2.cpp b/src/models/internlm2.cpp
index f6cfdfb945..8fc99856a2 100644
--- a/src/models/internlm2.cpp
+++ b/src/models/internlm2.cpp
@@ -134,6 +134,4 @@ llama_model_internlm2::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/jais.cpp b/src/models/jais.cpp
index 415103ce23..446b566175 100644
--- a/src/models/jais.cpp
+++ b/src/models/jais.cpp
@@ -127,6 +127,4 @@ llama_model_jais::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/jais2.cpp b/src/models/jais2.cpp
index 64813b7b6b..4b24e697f5 100644
--- a/src/models/jais2.cpp
+++ b/src/models/jais2.cpp
@@ -150,6 +150,4 @@ llama_model_jais2::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/jamba.cpp b/src/models/jamba.cpp
index dba160b014..ed4c9f13e5 100644
--- a/src/models/jamba.cpp
+++ b/src/models/jamba.cpp
@@ -193,6 +193,4 @@ llama_model_jamba::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/k2-horizon.cpp b/src/models/k2-horizon.cpp
index 2229527388..845940913f 100644
--- a/src/models/k2-horizon.cpp
+++ b/src/models/k2-horizon.cpp
@@ -357,6 +357,4 @@ llama_model_k2_horizon::graph::graph(const llama_model & model, const llm_graph_
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/kimi-k3.cpp b/src/models/kimi-k3.cpp
index 112b098490..27ceffe923 100644
--- a/src/models/kimi-k3.cpp
+++ b/src/models/kimi-k3.cpp
@@ -346,8 +346,6 @@ llama_model_kimi_k3::graph::graph(const llama_model & model, const llm_graph_par
cur = ggml_mul_mat(ctx0, model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
//
diff --git a/src/models/kimi-linear.cpp b/src/models/kimi-linear.cpp
index b9cf28d85c..7ce088ef69 100644
--- a/src/models/kimi-linear.cpp
+++ b/src/models/kimi-linear.cpp
@@ -557,6 +557,4 @@ llama_model_kimi_linear::graph::graph(const llama_model & model, const llm_graph
cur = ggml_mul_mat(ctx0, model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/laguna.cpp b/src/models/laguna.cpp
index 2bc4fa8a0f..b59d8afc7a 100644
--- a/src/models/laguna.cpp
+++ b/src/models/laguna.cpp
@@ -326,6 +326,4 @@ llama_model_laguna::graph::graph(const llama_model & model, const llm_graph_para
cur = build_lora_mm(model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/lfm2.cpp b/src/models/lfm2.cpp
index 2488c07465..942d8de907 100644
--- a/src/models/lfm2.cpp
+++ b/src/models/lfm2.cpp
@@ -341,8 +341,6 @@ llama_model_lfm2::graph<iswa>::graph(const llama_model & model, const llm_graph_
res->t_logits = cur;
}
-
- ggml_build_forward_expand(gf, cur);
}
// media entries (an image or audio prefix) are embeddings, text entries are tokens
diff --git a/src/models/llada-moe.cpp b/src/models/llada-moe.cpp
index 0ee9ce1bec..0930cfb3cf 100644
--- a/src/models/llada-moe.cpp
+++ b/src/models/llada-moe.cpp
@@ -158,6 +158,4 @@ llama_model_llada_moe::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/llada.cpp b/src/models/llada.cpp
index ae3d6925c1..1277e9dd7c 100644
--- a/src/models/llada.cpp
+++ b/src/models/llada.cpp
@@ -148,6 +148,4 @@ llama_model_llada::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/llama.cpp b/src/models/llama.cpp
index 4bfebc8843..f9c1251131 100644
--- a/src/models/llama.cpp
+++ b/src/models/llama.cpp
@@ -242,8 +242,6 @@ llama_model_llama::graph<embed>::graph(const llama_model & model, const llm_grap
cb(cur, "result_output", -1);
res->t_logits = cur;
}
-
- ggml_build_forward_expand(gf, cur);
}
template struct llama_model_llama::graph<false>;
diff --git a/src/models/llama4.cpp b/src/models/llama4.cpp
index 4f79b4d1ee..9a365394ce 100644
--- a/src/models/llama4.cpp
+++ b/src/models/llama4.cpp
@@ -263,8 +263,6 @@ llama_model_llama4::graph<iswa>::graph(const llama_model & model, const llm_grap
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// Explicit template instantiations
diff --git a/src/models/maincoder.cpp b/src/models/maincoder.cpp
index ae56a26a1f..1eeab45a15 100644
--- a/src/models/maincoder.cpp
+++ b/src/models/maincoder.cpp
@@ -146,6 +146,4 @@ llama_model_maincoder::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/mamba.cpp b/src/models/mamba.cpp
index 0d94e98281..d47e8e5e12 100644
--- a/src/models/mamba.cpp
+++ b/src/models/mamba.cpp
@@ -132,6 +132,4 @@ llama_model_mamba::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/maple.cpp b/src/models/maple.cpp
index 7604b7dfee..9568c64758 100644
--- a/src/models/maple.cpp
+++ b/src/models/maple.cpp
@@ -145,6 +145,4 @@ llama_model_maple::graph::graph(const llama_model & model, const llm_graph_param
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/mellum.cpp b/src/models/mellum.cpp
index 3ab79747af..145597fc33 100644
--- a/src/models/mellum.cpp
+++ b/src/models/mellum.cpp
@@ -211,8 +211,6 @@ llama_model_mellum::graph<iswa>::graph(const llama_model & model, const llm_grap
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
template struct llama_model_mellum::graph<false>;
diff --git a/src/models/mimo2.cpp b/src/models/mimo2.cpp
index 238dcfd91a..fdf5d00af1 100644
--- a/src/models/mimo2.cpp
+++ b/src/models/mimo2.cpp
@@ -253,8 +253,6 @@ llama_model_mimo2::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// Mirrors MiMo's appended NextN block: normalize and fuse token and hidden inputs, run the decoder block,
@@ -397,5 +395,4 @@ llama_model_mimo2::graph_mtp::graph_mtp(const llama_model & model, const llm_gra
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/minicpm3.cpp b/src/models/minicpm3.cpp
index 7820d52241..7136921dc3 100644
--- a/src/models/minicpm3.cpp
+++ b/src/models/minicpm3.cpp
@@ -247,6 +247,4 @@ llama_model_minicpm3::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/minimax-01.cpp b/src/models/minimax-01.cpp
index 9fa2e8fc01..27fe5291b0 100644
--- a/src/models/minimax-01.cpp
+++ b/src/models/minimax-01.cpp
@@ -479,6 +479,4 @@ llama_model_minimax_01::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/minimax-m2.cpp b/src/models/minimax-m2.cpp
index 7a22af036b..8b80eab2da 100644
--- a/src/models/minimax-m2.cpp
+++ b/src/models/minimax-m2.cpp
@@ -163,6 +163,4 @@ llama_model_minimax_m2::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/minimax-m3.cpp b/src/models/minimax-m3.cpp
index 53caca1a5c..35e7b1a815 100644
--- a/src/models/minimax-m3.cpp
+++ b/src/models/minimax-m3.cpp
@@ -603,6 +603,4 @@ llama_model_minimax_m3::graph::graph(const llama_model & model, const llm_graph_
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/mistral3.cpp b/src/models/mistral3.cpp
index 9a8e3f9a50..484e1b698a 100644
--- a/src/models/mistral3.cpp
+++ b/src/models/mistral3.cpp
@@ -230,6 +230,4 @@ llama_model_mistral3::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/mpt.cpp b/src/models/mpt.cpp
index d094fd9f80..69d8b8c66b 100644
--- a/src/models/mpt.cpp
+++ b/src/models/mpt.cpp
@@ -165,6 +165,4 @@ llama_model_mpt::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/muse-glimmer.cpp b/src/models/muse-glimmer.cpp
index 0e5f75ebed..2f84d6f980 100644
--- a/src/models/muse-glimmer.cpp
+++ b/src/models/muse-glimmer.cpp
@@ -194,8 +194,6 @@ llama_model_muse_glimmer::graph::graph(const llama_model & model, const llm_grap
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
std::unique_ptr<llm_graph_context> llama_model_muse_glimmer::build_arch_graph(const llm_graph_params & params) const {
diff --git a/src/models/nanbeige.cpp b/src/models/nanbeige.cpp
index 7d5a6bbdb6..e2d0a7b133 100644
--- a/src/models/nanbeige.cpp
+++ b/src/models/nanbeige.cpp
@@ -180,6 +180,4 @@ llama_model_nanbeige::graph::graph(const llama_model & model, const llm_graph_pa
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/nemotron-h-moe.cpp b/src/models/nemotron-h-moe.cpp
index d3b8bb837b..c6ce58a7a6 100644
--- a/src/models/nemotron-h-moe.cpp
+++ b/src/models/nemotron-h-moe.cpp
@@ -156,5 +156,4 @@ llama_model_nemotron_h_moe::graph_mtp::graph_mtp(const llama_model & model, cons
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/nemotron-h.cpp b/src/models/nemotron-h.cpp
index cf78ebfbe3..b14913f2a8 100644
--- a/src/models/nemotron-h.cpp
+++ b/src/models/nemotron-h.cpp
@@ -259,8 +259,6 @@ llama_model_nemotron_h::graph::graph(const llama_model & model, const llm_graph_
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_nemotron_h::graph::build_attention_layer(ggml_tensor * cur,
diff --git a/src/models/nemotron.cpp b/src/models/nemotron.cpp
index 6e2bd9a33c..129cf622e2 100644
--- a/src/models/nemotron.cpp
+++ b/src/models/nemotron.cpp
@@ -145,6 +145,4 @@ llama_model_nemotron::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/olmo.cpp b/src/models/olmo.cpp
index 9f7a2ba60e..261aa98f7c 100644
--- a/src/models/olmo.cpp
+++ b/src/models/olmo.cpp
@@ -137,6 +137,4 @@ llama_model_olmo::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/olmo2.cpp b/src/models/olmo2.cpp
index fe5dc88d44..db2de3afd7 100644
--- a/src/models/olmo2.cpp
+++ b/src/models/olmo2.cpp
@@ -199,8 +199,6 @@ llama_model_olmo2::graph<iswa>::graph(const llama_model & model, const llm_graph
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// Explicit template instantiations
diff --git a/src/models/olmoe.cpp b/src/models/olmoe.cpp
index 11c53f3f4c..f447838216 100644
--- a/src/models/olmoe.cpp
+++ b/src/models/olmoe.cpp
@@ -168,6 +168,4 @@ llama_model_olmoe::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/openai-moe.cpp b/src/models/openai-moe.cpp
index a6b63947b9..8e42278039 100644
--- a/src/models/openai-moe.cpp
+++ b/src/models/openai-moe.cpp
@@ -170,6 +170,4 @@ llama_model_openai_moe::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/openelm.cpp b/src/models/openelm.cpp
index 13120bd323..1d7d4e5ec6 100644
--- a/src/models/openelm.cpp
+++ b/src/models/openelm.cpp
@@ -166,6 +166,4 @@ llama_model_openelm::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/orion.cpp b/src/models/orion.cpp
index 863a282226..06ed3bd31c 100644
--- a/src/models/orion.cpp
+++ b/src/models/orion.cpp
@@ -136,6 +136,4 @@ llama_model_orion::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/paddleocr.cpp b/src/models/paddleocr.cpp
index d39220bd77..68030b9af0 100644
--- a/src/models/paddleocr.cpp
+++ b/src/models/paddleocr.cpp
@@ -102,6 +102,4 @@ llama_model_paddleocr::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/pangu-embed.cpp b/src/models/pangu-embed.cpp
index 90f05c088c..cf34cd16a7 100644
--- a/src/models/pangu-embed.cpp
+++ b/src/models/pangu-embed.cpp
@@ -157,6 +157,4 @@ llama_model_pangu_embed::graph::graph(const llama_model & model, const llm_graph
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/phi2.cpp b/src/models/phi2.cpp
index 81b1ad12cc..de14cfe37b 100644
--- a/src/models/phi2.cpp
+++ b/src/models/phi2.cpp
@@ -137,6 +137,4 @@ llama_model_phi2::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/phi3.cpp b/src/models/phi3.cpp
index 716ff814cc..fc80848409 100644
--- a/src/models/phi3.cpp
+++ b/src/models/phi3.cpp
@@ -187,8 +187,6 @@ llama_model_phi3::graph<iswa>::graph(const llama_model & model, const llm_graph_
}
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// Explicit template instantiations
diff --git a/src/models/plamo.cpp b/src/models/plamo.cpp
index 246144519e..401ffe48af 100644
--- a/src/models/plamo.cpp
+++ b/src/models/plamo.cpp
@@ -131,6 +131,4 @@ llama_model_plamo::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/plamo2.cpp b/src/models/plamo2.cpp
index ba1cea1465..9ce229b194 100644
--- a/src/models/plamo2.cpp
+++ b/src/models/plamo2.cpp
@@ -196,8 +196,6 @@ llama_model_plamo2::graph::graph(const llama_model & model, const llm_graph_para
ggml_set_output(cur);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_plamo2::graph::build_plamo2_attn_layer(llm_graph_input_attn_kv * inp,
diff --git a/src/models/plamo3.cpp b/src/models/plamo3.cpp
index f8235f8a83..4dcbcad81a 100644
--- a/src/models/plamo3.cpp
+++ b/src/models/plamo3.cpp
@@ -186,8 +186,6 @@ llama_model_plamo3::graph<iswa>::graph(const llama_model & model, const llm_grap
cur = build_lora_mm(model.output, cur, model.output_s);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// Explicit template instantiations
diff --git a/src/models/plm.cpp b/src/models/plm.cpp
index 5abefd53ba..64528c3727 100644
--- a/src/models/plm.cpp
+++ b/src/models/plm.cpp
@@ -201,6 +201,4 @@ llama_model_plm::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/pockettts.cpp b/src/models/pockettts.cpp
index 1b3bb6c648..ad1835893a 100644
--- a/src/models/pockettts.cpp
+++ b/src/models/pockettts.cpp
@@ -141,6 +141,4 @@ llama_model_pockettts::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen.cpp b/src/models/qwen.cpp
index 1f5dff3843..3c42cad3cb 100644
--- a/src/models/qwen.cpp
+++ b/src/models/qwen.cpp
@@ -135,6 +135,4 @@ llama_model_qwen::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen2.cpp b/src/models/qwen2.cpp
index e9c2ea80a6..d2cd8e22dd 100644
--- a/src/models/qwen2.cpp
+++ b/src/models/qwen2.cpp
@@ -149,6 +149,4 @@ llama_model_qwen2::graph::graph(const llama_model & model, const llm_graph_param
}
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen2moe.cpp b/src/models/qwen2moe.cpp
index 8bcb1017bf..5f9222f1ce 100644
--- a/src/models/qwen2moe.cpp
+++ b/src/models/qwen2moe.cpp
@@ -189,6 +189,4 @@ llama_model_qwen2moe::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen2vl.cpp b/src/models/qwen2vl.cpp
index d79db682cd..778d1c80a3 100644
--- a/src/models/qwen2vl.cpp
+++ b/src/models/qwen2vl.cpp
@@ -138,6 +138,4 @@ llama_model_qwen2vl::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen3.cpp b/src/models/qwen3.cpp
index a565e3e688..bf7e622fb9 100644
--- a/src/models/qwen3.cpp
+++ b/src/models/qwen3.cpp
@@ -58,8 +58,6 @@ llama_model_qwen3::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_qwen3::graph::build_backbone(const llama_model & model) {
diff --git a/src/models/qwen35.cpp b/src/models/qwen35.cpp
index ecc02a1120..802f2e2f13 100644
--- a/src/models/qwen35.cpp
+++ b/src/models/qwen35.cpp
@@ -234,8 +234,6 @@ llama_model_qwen35::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
std::pair<ggml_tensor *, ggml_tensor *> llama_model_qwen35::graph::build_qkvz(
@@ -665,5 +663,4 @@ llama_model_qwen35::graph_mtp::graph_mtp(const llama_model & model, const llm_gr
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen35moe.cpp b/src/models/qwen35moe.cpp
index 118deeb2aa..fdbb2c63d4 100644
--- a/src/models/qwen35moe.cpp
+++ b/src/models/qwen35moe.cpp
@@ -244,8 +244,6 @@ llama_model_qwen35moe::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
std::pair<ggml_tensor *, ggml_tensor *> llama_model_qwen35moe::graph::build_qkvz(
@@ -738,5 +736,4 @@ llama_model_qwen35moe::graph_mtp::graph_mtp(const llama_model & model, const llm
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen3moe.cpp b/src/models/qwen3moe.cpp
index a6a3381e5e..2198fcfb5a 100644
--- a/src/models/qwen3moe.cpp
+++ b/src/models/qwen3moe.cpp
@@ -174,6 +174,4 @@ llama_model_qwen3moe::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen3next.cpp b/src/models/qwen3next.cpp
index 68be550a57..13aa68ee80 100644
--- a/src/models/qwen3next.cpp
+++ b/src/models/qwen3next.cpp
@@ -218,8 +218,6 @@ llama_model_qwen3next::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
ggml_tensor * llama_model_qwen3next::graph::build_norm_gated(
@@ -814,5 +812,4 @@ llama_model_qwen3next::graph_mtp::graph_mtp(const llama_model & model, const llm
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen3vl.cpp b/src/models/qwen3vl.cpp
index 30c08ed35e..8c06dcccae 100644
--- a/src/models/qwen3vl.cpp
+++ b/src/models/qwen3vl.cpp
@@ -192,6 +192,4 @@ llama_model_qwen3vl::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen3vlmoe.cpp b/src/models/qwen3vlmoe.cpp
index e7a81e32cf..94974d8e84 100644
--- a/src/models/qwen3vlmoe.cpp
+++ b/src/models/qwen3vlmoe.cpp
@@ -185,6 +185,4 @@ llama_model_qwen3vlmoe::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/qwen4exp.cpp b/src/models/qwen4exp.cpp
index 1d151dc21e..f68a8622c7 100644
--- a/src/models/qwen4exp.cpp
+++ b/src/models/qwen4exp.cpp
@@ -519,8 +519,6 @@ llama_model_qwen4exp::graph::graph(const llama_model & model, const llm_graph_pa
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
llama_model_qwen4exp::graph_mtp::graph_mtp(const llama_model & model, const llm_graph_params & params) :
@@ -615,8 +613,6 @@ llama_model_qwen4exp::graph_mtp::graph_mtp(const llama_model & model, const llm_
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
std::pair<ggml_tensor *, ggml_tensor *> llama_model_qwen4exp::graph::build_qkvz(
diff --git a/src/models/refact.cpp b/src/models/refact.cpp
index a46c358fa6..5336608a74 100644
--- a/src/models/refact.cpp
+++ b/src/models/refact.cpp
@@ -155,6 +155,4 @@ llama_model_refact::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/rnd1.cpp b/src/models/rnd1.cpp
index 553a757302..2b0b3e97ef 100644
--- a/src/models/rnd1.cpp
+++ b/src/models/rnd1.cpp
@@ -172,6 +172,4 @@ llama_model_rnd1::graph::graph(const llama_model & model, const llm_graph_params
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/rwkv6.cpp b/src/models/rwkv6.cpp
index 0b5013dc75..84a18180b7 100644
--- a/src/models/rwkv6.cpp
+++ b/src/models/rwkv6.cpp
@@ -180,6 +180,4 @@ llama_model_rwkv6::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/rwkv6qwen2.cpp b/src/models/rwkv6qwen2.cpp
index 6c7db51443..0e5561c195 100644
--- a/src/models/rwkv6qwen2.cpp
+++ b/src/models/rwkv6qwen2.cpp
@@ -162,6 +162,4 @@ llama_model_rwkv6qwen2::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/rwkv7.cpp b/src/models/rwkv7.cpp
index 67c51f5b59..6577a25f92 100644
--- a/src/models/rwkv7.cpp
+++ b/src/models/rwkv7.cpp
@@ -206,6 +206,4 @@ llama_model_rwkv7::graph::graph(const llama_model & model, const llm_graph_param
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/seed-oss.cpp b/src/models/seed-oss.cpp
index 57de881a09..871f06cc5e 100644
--- a/src/models/seed-oss.cpp
+++ b/src/models/seed-oss.cpp
@@ -146,6 +146,4 @@ llama_model_seed_oss::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/smallthinker.cpp b/src/models/smallthinker.cpp
index 555f8b7184..60803cb4fd 100644
--- a/src/models/smallthinker.cpp
+++ b/src/models/smallthinker.cpp
@@ -179,8 +179,6 @@ llama_model_smallthinker::graph<iswa>::graph(const llama_model & model, const ll
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// Explicit template instantiations
diff --git a/src/models/smollm3.cpp b/src/models/smollm3.cpp
index c67d967b20..474093b68b 100644
--- a/src/models/smollm3.cpp
+++ b/src/models/smollm3.cpp
@@ -147,6 +147,4 @@ llama_model_smollm3::graph::graph(const llama_model & model, const llm_graph_par
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/spark2-5.cpp b/src/models/spark2-5.cpp
index 107448777c..970b32ba60 100644
--- a/src/models/spark2-5.cpp
+++ b/src/models/spark2-5.cpp
@@ -141,6 +141,4 @@ llama_model_spark2_5::graph::graph(const llama_model & model, const llm_graph_pa
cur = build_lora_mm(model.output, cur);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/stablelm.cpp b/src/models/stablelm.cpp
index bf6087b879..5189a46068 100644
--- a/src/models/stablelm.cpp
+++ b/src/models/stablelm.cpp
@@ -167,6 +167,4 @@ llama_model_stablelm::graph::graph(const llama_model & model, const llm_graph_pa
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/starcoder.cpp b/src/models/starcoder.cpp
index f73a88fd4e..e68e24ffb8 100644
--- a/src/models/starcoder.cpp
+++ b/src/models/starcoder.cpp
@@ -140,6 +140,4 @@ llama_model_starcoder::graph::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/starcoder2.cpp b/src/models/starcoder2.cpp
index b81b469374..dcf6ed3714 100644
--- a/src/models/starcoder2.cpp
+++ b/src/models/starcoder2.cpp
@@ -153,6 +153,4 @@ llama_model_starcoder2::graph::graph(const llama_model & model, const llm_graph_
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/step35.cpp b/src/models/step35.cpp
index bd43d9ae87..3e225a11ef 100644
--- a/src/models/step35.cpp
+++ b/src/models/step35.cpp
@@ -351,8 +351,6 @@ llama_model_step35::graph::graph(const llama_model & model, const llm_graph_para
cur = build_lora_mm(model.output, cur, model.output_s);
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
// LLM_GRAPH_TYPE_DECODER_MTP draft head for Step3p5 (MoE)
@@ -550,5 +548,4 @@ llama_model_step35::graph_mtp::graph_mtp(const llama_model & model, const llm_gr
cb(cur, "result_output", -1);
res->t_logits = cur;
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/t5.cpp b/src/models/t5.cpp
index e2bf12b6b1..a5ddbebf90 100644
--- a/src/models/t5.cpp
+++ b/src/models/t5.cpp
@@ -257,8 +257,6 @@ llama_model_t5::graph<false>::graph(const llama_model & model, const llm_graph_p
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
template <>
diff --git a/src/models/talkie.cpp b/src/models/talkie.cpp
index 393e8f65bf..c6a6b5abe8 100644
--- a/src/models/talkie.cpp
+++ b/src/models/talkie.cpp
@@ -144,6 +144,4 @@ llama_model_talkie::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}
diff --git a/src/models/xverse.cpp b/src/models/xverse.cpp
index 3135001293..bfc539e8da 100644
--- a/src/models/xverse.cpp
+++ b/src/models/xverse.cpp
@@ -131,6 +131,4 @@ llama_model_xverse::graph::graph(const llama_model & model, const llm_graph_para
cb(cur, "result_output", -1);
res->t_logits = cur;
-
- ggml_build_forward_expand(gf, cur);
}