From 9cf967a04d0dd39f648764d73ac07facc7b75db1 Mon Sep 17 00:00:00 2001 From: Pascal Date: Wed, 14 Oct 2026 08:15:08 +0200 Subject: [PATCH] models: drop the t_embd expand of the embedding graphs (#30461) These graphs only produce embeddings, and build_pooling() already expands its output for every pooling type, so the expand at the end of the model graph is redundant. --- src/models/bert.cpp | 2 -- src/models/eurobert.cpp | 2 -- src/models/gemma-embedding.cpp | 2 -- src/models/gemma-embedding2.cpp | 2 -- src/models/neo-bert.cpp | 2 -- src/models/wavtokenizer-dec.cpp | 2 -- 6 files changed, 12 deletions(-) diff --git a/src/models/bert.cpp b/src/models/bert.cpp index 25640445a..8f3aa316c 100644 --- a/src/models/bert.cpp +++ b/src/models/bert.cpp @@ -222,6 +222,4 @@ llama_model_bert::graph::graph(const llama_model & model, const llm_graph_params cb(cur, "result_embd", -1); res->t_embd = cur; - - ggml_build_forward_expand(gf, cur); } diff --git a/src/models/eurobert.cpp b/src/models/eurobert.cpp index 0948d7de6..13bae8b71 100644 --- a/src/models/eurobert.cpp +++ b/src/models/eurobert.cpp @@ -119,6 +119,4 @@ llama_model_eurobert::graph::graph(const llama_model & model, const llm_graph_pa cb(cur, "result_embd", -1); res->t_embd = cur; - - ggml_build_forward_expand(gf, cur); } diff --git a/src/models/gemma-embedding.cpp b/src/models/gemma-embedding.cpp index 692e19ee9..bb4e964e8 100644 --- a/src/models/gemma-embedding.cpp +++ b/src/models/gemma-embedding.cpp @@ -169,6 +169,4 @@ llama_model_gemma_embedding::graph::graph(const llama_model & model, const llm_g cb(cur, "result_norm", -1); res->t_embd = cur; - - ggml_build_forward_expand(gf, cur); } diff --git a/src/models/gemma-embedding2.cpp b/src/models/gemma-embedding2.cpp index 4b77664ad..2c7fa6750 100644 --- a/src/models/gemma-embedding2.cpp +++ b/src/models/gemma-embedding2.cpp @@ -210,8 +210,6 @@ llama_model_gemma_embedding2::graph::graph(const llama_model & model, const llm_ cur = build_lora_mm(model.output, cur, model.output_s); cb(cur, "result_embd", -1); res->t_embd = cur; - - ggml_build_forward_expand(gf, cur); } // equivalent to EmbeddingGemma2TextPLE in python code diff --git a/src/models/neo-bert.cpp b/src/models/neo-bert.cpp index 4a08d7abd..9b141c3b7 100644 --- a/src/models/neo-bert.cpp +++ b/src/models/neo-bert.cpp @@ -129,6 +129,4 @@ llama_model_neo_bert::graph::graph(const llama_model & model, const llm_graph_pa cb(cur, "result_embd", -1); res->t_embd = cur; - - ggml_build_forward_expand(gf, cur); } diff --git a/src/models/wavtokenizer-dec.cpp b/src/models/wavtokenizer-dec.cpp index 214fed99b..881d2c383 100644 --- a/src/models/wavtokenizer-dec.cpp +++ b/src/models/wavtokenizer-dec.cpp @@ -259,6 +259,4 @@ llama_model_wavtokenizer_dec::graph::graph(const llama_model & model, const llm_ cb(cur, "result_embd", -1); res->t_embd = cur; - - ggml_build_forward_expand(gf, cur); }