Commit cb55ffe6e for llama.cpp
commit cb55ffe6e2147eb15f4bede1f60d11246715754f
Author: Pascal <admin@serveurperso.com>
Date: Tue Oct 13 16:16:14 2026 +0200
graph: skip the LM head for pooled embeddings (#30445)
* graph: skip the LM head for pooled embeddings
A context that extracts pooled embeddings outputs one vector per
sequence, but every model still expanded its LM head, so the graph
computed n_vocab logits per token and the context kept a host buffer
for them.
The models now only declare t_logits, and set_outputs() expands it
unless the context extracts embeddings with a pooling type other than
NONE. Since the toggle changes the graph shape for a pooled context,
set_embeddings() schedules a re-reserve in that case.
* graph: drop the redundant t_embd expand
Address review from @CISC: with embeddings on, build_pooling() already
expands its output for every pooling type, and a decoder graph without
embeddings does not read t_embd, so set_outputs() only expands
t_logits.
* graph: add build_logits() for the LM head output
Address review from @ggerganov: the LM head is expanded by a dedicated
build_logits(), called from llama_model::build_graph() like
build_pooling(), and set_outputs() only marks the outputs again.
* graph: call build_logits() before build_sampling()
Address review from @ggerganov: build_sampling() reads t_logits, so the
LM head is built first. A pooled context then skips the sampling layers
too, since it has no logits to sample from.
* nit
diff --git a/include/llama.h b/include/llama.h
index 6f76c819f..f15ca9f75 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 9d54c326a..9ee64b566 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 91af27473..9039e47fd 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 fbbe67f25..e853a0269 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 e57ede5fd..7072d029c 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 08c22b6ed..266597a35 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 6dfb8905f..130980e32 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 9536e7c5d..81e3b828f 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 09ee0f752..1a170f085 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 b38b20647..5f1ca4384 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 585f36141..b7f5b05f8 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 9d1073ae1..2da47f09f 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 24fc4e022..d7003ef7e 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 abbc30fdf..49c0f7fea 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 c83302745..a08881b9f 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 609d2ddf9..54ef3a037 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 4f45acecf..bb597afef 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 7ae5b938f..54e3913c4 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 de53bb981..be1e57619 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 bc394b3c1..2e1416be8 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 7ad5244e4..969b4ef05 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 19362e5c1..649682610 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 94a46188b..edf74c57b 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 4f5ac4d06..8d4f783fb 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 cdfcf29e0..ce5de887c 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 a47a9c3da..a066d4fb6 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 2d56dfb22..5fd24d105 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 98f34a200..083b32ecf 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 50864b2cb..af04dddd3 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 3f426f566..aeeadbbd1 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 a3a85748e..f29f669c2 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 0991c488e..237a92371 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 abe737c33..7d5ffa56a 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 bfde35e43..d47340759 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 8d9ff1386..6bf539d21 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 7bf7be648..b7a6e9629 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 840da5f67..1a09d544d 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 676fb37b5..070bfd568 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 c1c55957a..80447908e 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 d6ef2d519..a7f9e5576 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 b2ad90b32..555468a47 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 651cd7e64..1da4ad815 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 9e5243465..c405e6400 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 83cb57f99..4c8183cce 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 50d30c63f..f2e5ae6c8 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 b6c29183e..6ebc3c3e8 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 d88338437..f4f80d396 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 596d86a61..a9d62c076 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 341d18a94..d19eb553f 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 463be809d..a6cb0889b 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 14224e64f..32199a260 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 45afbccc1..d6ca64744 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 ed5e8c50d..bc8a9fd4a 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 c177ae787..fb3bf7024 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 08d9e8a54..f683ef6e8 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 044c8e699..a73fcdaff 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 60d463aed..4cac49595 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 cb6afc3a7..1a125d94e 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 f32f3e9ed..b2648a13a 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 8b3337c0b..912a430f4 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 cedc3b53e..779575eee 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 18b6eaf8c..fa7183190 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 037191da8..080b30c1a 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 ee41787ba..25e40abf7 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 f6cfdfb94..8fc99856a 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 415103ce2..446b56617 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 64813b7b6..4b24e697f 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 dba160b01..ed4c9f13e 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 222952738..845940913 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 112b09849..27ceffe92 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 b9cf28d85..7ce088ef6 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 2bc4fa8a0..b59d8afc7 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 2488c0746..942d8de90 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 0ee9ce1be..0930cfb3c 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 ae3d6925c..1277e9dd7 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 4bfebc884..f9c125113 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 4f79b4d1e..9a365394c 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 ae56a26a1..1eeab45a1 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 0d94e9828..d47e8e5e1 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 7604b7dfe..9568c6475 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 3ab79747a..145597fc3 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 238dcfd91..fdf5d00af 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 7820d5224..7136921dc 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 9fa2e8fc0..27fe5291b 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 7a22af036..8b80eab2d 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 53caca1a5..35e7b1a81 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 9a8e3f9a5..484e1b698 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 d094fd9f8..69d8b8c66 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 0e5f75ebe..2f84d6f98 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 7d5a6bbdb..e2d0a7b13 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 d3b8bb837..c6ce58a7a 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 cf78ebfbe..b14913f2a 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 6e2bd9a33..129cf622e 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 9f7a2ba60..261aa98f7 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 fe5dc88d4..db2de3afd 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 11c53f3f4..f44783821 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 a6b63947b..8e4227803 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 13120bd32..1d7d4e5ec 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 863a28222..06ed3bd31 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 d39220bd7..68030b9af 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 90f05c088..cf34cd16a 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 81b1ad12c..de14cfe37 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 716ff814c..fc8084840 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 246144519..401ffe48a 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 ba1cea146..9ce229b19 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 f8235f8a8..4dcbcad81 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 5abefd53b..64528c372 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 1b3bb6c64..ad1835893 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 1f5dff384..3c42cad3c 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 e9c2ea80a..d2cd8e22d 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 8bcb1017b..5f9222f1c 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 d79db682c..778d1c80a 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 a565e3e68..bf7e622fb 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 ecc02a112..802f2e2f1 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 118deeb2a..fdbb2c63d 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 a6a3381e5..2198fcfb5 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 68be550a5..13aa68ee8 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 30c08ed35..8c06dccca 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 e7a81e32c..94974d8e8 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 1d151dc21..f68a8622c 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 a46c358fa..5336608a7 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 553a75730..2b0b3e97e 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 0b5013dc7..84a18180b 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 6c7db5144..0e5561c19 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 67c51f5b5..6577a25f9 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 57de881a0..871f06cc5 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 555f8b718..60803cb4f 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 c67d967b2..474093b68 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 107448777..970b32ba6 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 bf6087b87..5189a4606 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 f73a88fd4..e68e24ffb 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 b81b46937..dcf6ed371 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 bd43d9ae8..3e225a11e 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 e2bf12b6b..a5ddbebf9 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 393e8f65b..c6a6b5abe 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 313500129..bfc539e8d 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);
}