Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Commit 01d1ebd

Browse files
committed
refactor: manage embeddings kv cache
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent b9978cf commit 01d1ebd

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

llama-box/httpserver.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ struct httpserver {
28882888
if (!support_completion()) {
28892889
// prompt cache
28902890
cache_prompt = false;
2891-
SRV_INF("prompt caching %s\n", cache_prompt ? "unsupported" : "disabled");
2891+
SRV_INF("prompt caching %s\n", params.cache_prompt ? "unsupported" : "disabled");
28922892

28932893
// context shift
28942894
shift_context = params.llm_params.ctx_shift;
@@ -2897,8 +2897,7 @@ struct httpserver {
28972897
}
28982898

28992899
// prompt cache
2900-
cache_prompt =
2901-
llm_model_casual && params.cache_prompt && llm_kv_cache_shift && llama_get_memory(llm_ctx) != nullptr;
2900+
cache_prompt = params.cache_prompt && llm_kv_cache_shift && llama_get_memory(llm_ctx) != nullptr;
29022901
if (cache_prompt) {
29032902
cache_prompts.resize(params.llm_params.n_threads_http);
29042903
}
@@ -4049,7 +4048,7 @@ struct httpserver {
40494048
}
40504049

40514050
// prepare cache - clean cache
4052-
if (cache_prompt) {
4051+
if (llm_kv_cache_shift && cache_prompt) {
40534052
llama_memory_seq_rm(llama_get_memory(llm_ctx), seq_id, 0, -1);
40544053
if (llm_ctx_draft != nullptr) {
40554054
llama_memory_seq_rm(llama_get_memory(llm_ctx_draft), seq_id, 0, -1);
@@ -4721,7 +4720,7 @@ struct httpserver {
47214720
task->embeds[task->embeds.size() - 1][0] = embed[0];
47224721
}
47234722
// clean kv cache
4724-
if (cache_prompt) {
4723+
if (llm_kv_cache_shift) {
47254724
llama_memory_seq_rm(llama_get_memory(llm_ctx), seq_id, 0, -1);
47264725
if (llm_ctx_draft != nullptr) {
47274726
llama_memory_seq_rm(llama_get_memory(llm_ctx_draft), seq_id, 0, -1);

0 commit comments

Comments
 (0)