]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
graph : fix graph reuse logic when `n_pos_per_embd > 1` (#18566)
authorGeorgi Gerganov <redacted>
Sat, 3 Jan 2026 21:59:06 +0000 (23:59 +0200)
committerGitHub <redacted>
Sat, 3 Jan 2026 21:59:06 +0000 (23:59 +0200)
src/llama-graph.cpp

index 1d0d7197e1f7fde65fd7fd24a3974545deae1cf0..8edf7d749be3b7ee6256cff428714a0d572bf942 100644 (file)
@@ -32,7 +32,7 @@ bool llm_graph_input_embd::can_reuse(const llm_graph_params & params) {
     bool res = true;
 
     res &= (!tokens && !params.ubatch.token) || (tokens && tokens->ne[0] == params.ubatch.n_tokens);
-    res &= (!embd   && !params.ubatch.embd)  || (embd   &&   embd->ne[0] == params.ubatch.n_tokens);
+    res &= (!embd   && !params.ubatch.embd)  || (embd   &&   embd->ne[1] == params.ubatch.n_tokens);
 
     return res;
 }
@@ -62,7 +62,7 @@ void llm_graph_input_pos::set_input(const llama_ubatch * ubatch) {
 bool llm_graph_input_pos::can_reuse(const llm_graph_params & params) {
     bool res = true;
 
-    res &= pos->ne[0] == params.ubatch.n_tokens;
+    res &= pos->ne[0] == params.ubatch.n_tokens*n_pos_per_embd;
 
     return res;
 }