DeepseekV4: clear cache only for seq rather than full#25521
Conversation
|
This had fixed full prompt recomputations on every agentic turn for me, now it only computes last turn |
| if (seq_id >= 0) { | ||
| clear_compressed_stream((uint32_t) seq_id, true); | ||
| } else { | ||
| clear_compressed(true); | ||
| } |
There was a problem hiding this comment.
Instead of introducing clear_compressed and clear_compressed_stream, can't we call the seq_rm of all the caches?
There was a problem hiding this comment.
Moreover, do we even have to clear anything in the compressed caches? Wouldn't the masks produced by the kv_raw mask away any stale data?
There was a problem hiding this comment.
I guess we don't use masks for the compressed caches and instead rely on the position:
llama.cpp/src/llama-kv-cache-dsv4.cpp
Lines 434 to 438 in 0badc06
So similar comment as in #25325 (comment). This should eventually be reworked to follow the llama_kv_cache pattern of managing a host-side KV cells information, which is decoupled from the token positions and the contents of the buffers. This way, clearing here would not be necessary (hence why I was confused).
Maybe add a reference to this comment inside the code.
There was a problem hiding this comment.
Yes we rely on n_visible. Let me add a TODO
There was a problem hiding this comment.
No, all of these need the correct sequence wise remove
- ggml-org#24231: LID GGML OP by fairydreaming: ggml-org#24231 @ 428831b - ggml-org#25521: clear cache only for seq rather than full by am17an: ggml-org#25521 @ 8026938
8026938 to
fcf2bb7
Compare
This comment has been minimized.
This comment has been minimized.
|
@TacoTakumi I assume you have read the contributing guidelines. Copy pasting LLM outputs is not allowed |
My apologies, I was tired and in a rush. I knew it was a bad look. |
|
@ggml-org/maintainers can I get another approval? |
@am17an actually it's just better now, but full reprocessing still happens even after this PR merge (it now reprocess every 5-7 turns instead of every one (like before)), also tested with #25588 applied - same behavior |
Overview
Currently the dsv4 cache has amneisa (#25171, #25171), this is because on
clearwe clear the entire cache. Instead we should clear for the particular seq_id.Additional information
Requirements