]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
context : fix n_outputs during reserve (#15858)
authorGeorgi Gerganov <redacted>
Mon, 8 Sep 2025 07:26:36 +0000 (10:26 +0300)
committerGitHub <redacted>
Mon, 8 Sep 2025 07:26:36 +0000 (10:26 +0300)
ggml-ci

src/llama-context.cpp
src/llama-graph.cpp

index 6b3188be4bc015dc11db3939388ae21ec33de8fe..874c6f82cb95807f392ddfbc3bc2dcfc725698d1 100644 (file)
@@ -285,8 +285,8 @@ llama_context::llama_context(
         const uint32_t n_seqs = cparams.kv_unified ? 1 : cparams.n_seq_max;
         const uint32_t n_tokens = std::min(cparams.n_ctx, cparams.n_ubatch);
 
-        // avoid reserving graphs with zero outputs
-        n_outputs = 1;
+        // avoid reserving graphs with zero outputs - assume one output per sequence
+        n_outputs = n_seqs;
 
         LLAMA_LOG_DEBUG("%s: worst-case: n_tokens = %d, n_seqs = %d, n_outputs = %d\n", __func__, n_tokens, n_seqs, n_outputs);
 
index 4abb6008dd18490af90751fbaa4a3145c1b6ace0..7f254b25cd451dfa5c1d7ba09595a0d9ed2ae19c 100644 (file)
@@ -1431,7 +1431,8 @@ ggml_tensor * llm_graph_context::build_attn(
 
     // [TAG_NO_CACHE_PAD]
     // TODO: if ubatch.equal_seqs() == true, we can split the three tensors below into ubatch.n_seqs_unq streams
-    assert(!ubatch.equal_seqs() || (k_cur->ne[3] == 1 && k_cur->ne[3] == ubatch.n_seqs_unq));
+    //       but it might not be worth it: https://github.com/ggml-org/llama.cpp/pull/15636
+    //assert(!ubatch.equal_seqs() || (k_cur->ne[3] == 1 && k_cur->ne[3] == ubatch.n_seqs_unq));
 
     ggml_tensor * q = q_cur;
     ggml_tensor * k = k_cur;