Skip to content

llama : refactor kv cache guard #12695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 2, 2025
Merged

llama : refactor kv cache guard #12695

merged 8 commits into from
Apr 2, 2025

Conversation

ggerganov
Copy link
Member

@ggerganov ggerganov commented Apr 1, 2025

Simplify the KV cache guard mechanism. Prepare for separate recurrent cache implementation.

Also, llama_decode now correctly returns 1 when the batch cannot fit in the KV cache and the KV cache state is correctly restored upon failure to process the batch.

@ggerganov ggerganov merged commit a10b36c into master Apr 2, 2025
1 check passed
@ggerganov ggerganov deleted the gg/llama-kv-cache-v4 branch April 2, 2025 11:33
@LostRuins
Copy link
Collaborator

After this commit, it seems like RNN based models like RWKV don't work anymore, and asset at llama-kv-cache.cpp:594: GGML_ASSERT(empty_cell.is_empty()) failed. Reverting the early return line at

return true;
seems to allow RWKV to work again.

cc: @MollySophia

@ggerganov
Copy link
Member Author

@LostRuins In case you can check if the issue is resolved with the upcoming #12799 would appreciate feedback. Thanks.

@LostRuins
Copy link
Collaborator

LostRuins commented Apr 25, 2025

Hi @ggerganov, unfortunately #12799 does not seem to solve the issue. Trying on RWKV7-Goose-World3-2.9B-HF-q3_k_s, I still get this assert:

src/llama-kv-cache.cpp:1803: GGML_ASSERT(empty_cell.is_empty()) failed

@ggerganov
Copy link
Member Author

Do you have a repro with some of the tools in llama.cpp? I tried:

./bin/llama-cli -hf Mungert/RWKV7-Goose-World3-2.9B-HF-GGUF:Q3_K_S -p "I believe the meaning of life is" -no-cnv -n 32

I believe the meaning of life is that we are here to be here.

 [end of text]

And it works. But this also works on master.

@ggerganov
Copy link
Member Author

Nvm, I reproduced with llama-server (didn't notice this is inside seq_rm()).

@ggerganov
Copy link
Member Author

Should be fixed in the latest commit in #12799

@LostRuins
Copy link
Collaborator

LostRuins commented Apr 25, 2025

No more asserts, can confirm it seems to work and generate fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants