Skip to content
Closed
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
17 changes: 11 additions & 6 deletions tools/server/server-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2559,12 +2559,17 @@ struct server_context_impl {
SLT_INF(slot, "n_tokens = %d, memory_seq_rm [%d, end)\n", slot.prompt.n_tokens(), p0);

if (!llama_memory_seq_rm(llama_get_memory(ctx), slot.id, p0, -1)) {
SLT_WRN(slot, "failed to truncate tokens with position >= %d - clearing the memory\n", p0);

slot.prompt_clear(true);

// there is no common part left
slot.n_prompt_tokens_cache = 0;
if (slot.ctx_seq_rm_type == COMMON_CONTEXT_SEQ_RM_TYPE_FULL && slot.n_prompt_tokens_cache > 0) {
// hybrid/recurrent: partial seq_rm always fails, but checkpoint restored valid state
SLT_INF(slot, "seq_rm failed (expected for hybrid) - keeping %d cached tokens from checkpoint\n", slot.n_prompt_tokens_cache);
} else {
SLT_WRN(slot, "failed to truncate tokens with position >= %d - clearing the memory\n", p0);

slot.prompt_clear(true);

// there is no common part left
slot.n_prompt_tokens_cache = 0;
}
}

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