Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tools/server/server-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5527,7 +5527,7 @@ struct server_context_impl {
SLT_WRN(slot, "%s\n", st1.str().c_str());
}

if (pos_min >= pos_min_thold) {
if (n_swa > 0 && pos_min >= pos_min_thold) {
// search for a context checkpoint
const auto it = std::find_if(
slot.prompt.checkpoints.rbegin(),
Expand Down Expand Up @@ -5660,9 +5660,17 @@ struct server_context_impl {

SLT_TRC(slot, "cached n_tokens = %d, memory_seq_rm [%d, end)\n", slot.prompt.n_tokens(), p0);

common_context_seq_rm(ctx_tgt, slot.id, p0, -1);
if (!llama_memory_seq_rm(llama_get_memory(ctx_tgt), slot.id, p0, -1)) {
SLT_WRN(slot, "partial seq_rm at p0=%d failed (recurrent backend cannot roll into cache); clearing slot and re-evaluating from scratch\n", p0);
slot.n_prompt_tokens_cache = 0;
slot.prompt.tokens.keep_first(0);
common_context_seq_rm(ctx_tgt, slot.id, 0, -1);
}

if (ctx_dft) {
common_context_seq_rm(ctx_dft.get(), slot.id, p0, -1);
if (!llama_memory_seq_rm(llama_get_memory(ctx_dft.get()), slot.id, p0, -1)) {
common_context_seq_rm(ctx_dft.get(), slot.id, 0, -1);
}
}

// If using an alora, there may be uncached tokens that come
Expand Down