]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server-context: guarantee there is at least 1 token to decode (#23280)
authorPascal <redacted>
Tue, 19 May 2026 06:49:01 +0000 (08:49 +0200)
committerGitHub <redacted>
Tue, 19 May 2026 06:49:01 +0000 (09:49 +0300)
tools/server/server-context.cpp

index 88b207ad556bf076b6156b51bed9006d32370ae6..dc3189e17052fb806512e4ef792f9ddcceef3f1f 100644 (file)
@@ -2589,9 +2589,9 @@ private:
                             llama_pos pos_next = slot.prompt.tokens.pos_next(n_past);
 
                             // the largest pos_min required for a checkpoint to be useful
-                            const auto pos_min_thold = std::max(0, pos_next - n_swa);
+                            const auto pos_min_thold = std::max(0, pos_next - n_swa - 1);
 
-                            if (n_past > 0 && n_past < slot.prompt.n_tokens()) {
+                            if (n_past > 0 && n_past <= slot.prompt.n_tokens()) {
                                 const auto pos_min = llama_memory_seq_pos_min(llama_get_memory(ctx_tgt), slot.id);
                                 if (pos_min == -1) {
                                     SLT_ERR(slot, "n_past = %d, slot.prompt.tokens.size() = %d, seq_id = %d, pos_min = %d\n", n_past, (int) slot.prompt.tokens.size(), slot.id, pos_min);