koboldcpp/tools
Daniel Bevenius 0b7154066e
common : fix state save in common_prompt_batch_decode (#23468)
* common : fix state save in common_prompt_batch_decode

This commit addresses a bug in common_prompt_batch_decode that affects
the session state store/restore in completion.cpp and
save-load-state.cpp.

The motivation for this is that currently the code is saving n-1 tokens
in both the session_tokens and in the KV cache. Then when loading the
session tokens, and if the prompt matches, it would replay the last
saved token (n-1) into the next position, effectively replaying the
same token in the wrong position.

The fix is to store all n tokens in session_tokens, while the memory
state only reflects n-1 processed tokens as the saving happens before
the last token is decoded in common_prompt_batch_decode.

I ran both completion.cpp and save-load-state.cpp with a transformer, a
recurrent, and a hybrid model.

Resolves: https://github.com/ggml-org/llama.cpp/issues/23400

Co-authored-by: fairydreaming <166155368+fairydreaming@users.noreply.github.com>
2026-06-02 15:44:15 +02:00
..
batched-bench cmake : add install() for impl libraries + fix apple builds (#23511) 2026-05-22 11:46:26 +03:00
cli app: add llama update self updater (#23865) 2026-05-29 23:02:40 +02:00
completion common : fix state save in common_prompt_batch_decode (#23468) 2026-06-02 15:44:15 +02:00
cvector-generator libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
export-lora libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
fit-params cmake : add install() for impl libraries + fix apple builds (#23511) 2026-05-22 11:46:26 +03:00
gguf-split libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
imatrix libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
llama-bench Support -fa auto in llama-bench (#23714) 2026-05-31 02:03:57 +05:30
mtmd model: Add EXAONE 4.5 implementations (#21733) 2026-06-01 11:48:53 +02:00
parser libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
perplexity perplexity : fix format specifier in LOG_ERR (#23788) 2026-05-28 10:34:58 +03:00
quantize cmake : add install() for impl libraries + fix apple builds (#23511) 2026-05-22 11:46:26 +03:00
results libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
rpc fix: rpc-server cache may not work in Windows environments (#22394) 2026-04-27 17:25:09 +03:00
server server: add SSE ping interval (#24013) 2026-06-02 14:14:55 +02:00
tokenize libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
tts logs : reduce (#23021) 2026-05-14 13:05:52 +03:00
ui ui: simplify network error handling (#23431) 2026-06-02 10:45:25 +02:00
CMakeLists.txt ui: Restructure repo to use tools/ui folder and ui / UI / llama-ui / LLAMA_UI naming (#23064) 2026-05-16 02:02:40 +02:00