]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server : fix ctx checkpoint restore logic (#19924)
authorGeorgi Gerganov <redacted>
Thu, 26 Feb 2026 16:20:16 +0000 (18:20 +0200)
committerGitHub <redacted>
Thu, 26 Feb 2026 16:20:16 +0000 (18:20 +0200)
tools/server/server-context.cpp

index 73af812437ea4f3222b230c30936ce90ca4a7f1e..eba463e4dac8a54cdb1ac2a2292cc7776e6cdf12 100644 (file)
@@ -2363,7 +2363,7 @@ private:
                                             //printf("[DEBUG] `do_reset` was set to `true` after failing to restore a checkpoint");
                                         } else {
                                             pos_next = std::min(pos_next, std::max(it->pos_min + 1, it->pos_max));
-                                            n_past = slot.prompt.tokens.size_up_to_pos(pos_next);
+                                            n_past = std::min(slot.prompt.tokens.size_up_to_pos(pos_next), (size_t) it->n_tokens);
                                             SLT_WRN(slot, "restored context checkpoint (pos_min = %d, pos_max = %d, n_tokens = %" PRId64 ", size = %.3f MiB)\n", it->pos_min, it->pos_max, it->n_tokens, (float) checkpoint_size / 1024 / 1024);
                                         }
                                     }