Skip to content

Commit b8fe4b5

Browse files
committed
main : fix session loading bug (#3400)
1 parent a8bdd65 commit b8fe4b5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/main/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ int main(int argc, char ** argv) {
297297
LOG_TEE("%s: session file matches %zu / %zu tokens of prompt\n",
298298
__func__, n_matching_session_tokens, embd_inp.size());
299299
}
300+
301+
// remove any "future" tokens that we might have inherited from the previous session
302+
llama_kv_cache_tokens_rm(ctx, n_matching_session_tokens, -1);
300303
}
301304

302305
LOGLN(
@@ -545,9 +548,6 @@ int main(int argc, char ** argv) {
545548
if (i > 0) {
546549
embd.erase(embd.begin(), embd.begin() + i);
547550
}
548-
549-
// remove any "future" tokens that we might have inherited from the session from the KV cache
550-
llama_kv_cache_tokens_rm(ctx, n_past, -1);
551551
}
552552

553553
// evaluate tokens in batches

0 commit comments

Comments
 (0)