add some warnings if shifting fails

This commit is contained in:
Concedo
2026-04-04 23:16:26 +08:00
parent d3d50a7b3c
commit db8bc40731
+10 -2
View File
@@ -2030,11 +2030,12 @@ bool DoContextShifting(llama_context * ctx, llama_context * draft_ctx, std::vect
int found = ArrFindIndexOf(current_context_tokens,shared);
if(found>=0 && found > trimstart)
{
bool ok = true;
if(!dryrun)
{
//extract the unwanted tokens out from context and KV
int diff = found - trimstart;
llama_memory_seq_rm(llama_get_memory(ctx), 0, trimstart, trimstart + diff);
ok = llama_memory_seq_rm(llama_get_memory(ctx), 0, trimstart, trimstart + diff);
llama_memory_seq_add(llama_get_memory(ctx), 0, trimstart + diff, -1, -diff);
if(draft_ctx)
{
@@ -2045,7 +2046,14 @@ bool DoContextShifting(llama_context * ctx, llama_context * draft_ctx, std::vect
{
current_context_tokens[i - diff] = current_context_tokens[i];
}
printf("\n[Context Shifting: Erased %d tokens at position %d]", diff, trimstart + 1);
if(ok)
{
printf("\n[Context Shifting: Erased %d tokens at position %d]", diff, trimstart + 1);
}
else
{
printf("\n[Warning: Context Shifting FAILED to erase %d tokens at position %d]", diff, trimstart + 1);
}
current_context_tokens.resize(current_context_tokens.size() - diff);
}
return true;