mirror of
https://github.com/ikawrakow/ik_llama.cpp.git
synced 2026-07-21 10:15:35 +00:00
server: variance based checkpoint eviction (#2020)
Co-authored-by: firecoperana <firecoperana>
This commit is contained in:
co-authored by
firecoperana <firecoperana>
parent
7ccf1d2095
commit
befbc0945b
@@ -498,6 +498,18 @@ common_webui common_webui_from_name(const std::string& format) {
|
||||
}
|
||||
}
|
||||
|
||||
common_checkpoint_eviction common_checkpoint_eviction_from_name(const std::string & format) {
|
||||
if (format == "auto") {
|
||||
return COMMON_CHECKPOINT_EVICTION_AUTO;
|
||||
} else if (format == "fifo") {
|
||||
return COMMON_CHECKPOINT_EVICTION_FIFO;
|
||||
} else if (format == "variance") {
|
||||
return COMMON_CHECKPOINT_EVICTION_VARIANCE;
|
||||
} else {
|
||||
return COMMON_CHECKPOINT_EVICTION_AUTO;
|
||||
}
|
||||
}
|
||||
|
||||
thinking_tokens thinking_tokens_from_string(const std::string& format) {
|
||||
thinking_tokens think_token;
|
||||
std::string token_string = string_strip(format);
|
||||
@@ -2772,6 +2784,11 @@ bool gpt_params_find_arg(int argc, char ** argv, const std::string & arg, gpt_pa
|
||||
params.ctx_checkpoints_tolerance = std::stoi(argv[i]);
|
||||
return true;
|
||||
}
|
||||
if (arg == "--ctx-checkpoints-eviction") {
|
||||
CHECK_ARG
|
||||
params.ctx_checkpoint_eviction= common_checkpoint_eviction_from_name(std::string(argv[i]));
|
||||
return true;
|
||||
}
|
||||
if (arg == "-cram" || arg == "--cache-ram") {
|
||||
CHECK_ARG
|
||||
params.cache_ram_mib = std::stoi(argv[i]);
|
||||
@@ -2982,6 +2999,7 @@ void gpt_params_print_usage(int /*argc*/, char ** argv, const gpt_params & param
|
||||
options.push_back({ "*", "--ctx-checkpoints N", "max number of context checkpoints to create per slot (default: %d)",params.ctx_checkpoints_n});
|
||||
options.push_back({ "*", "--ctx-checkpoints-interval N", "minimum number of tokens between each context checkpoint. (default: %d, <=0 disable)",params.ctx_checkpoints_interval});
|
||||
options.push_back({ "*", "--ctx-checkpoints-tolerance N", "the number of tokens before the full prompt to create the checkpoint. (default: %d, <=0 disable)",params.ctx_checkpoints_tolerance});
|
||||
options.push_back({ "*", "--ctx-checkpoints-eviction NAME", "Eviction strategy for checkpoint. Accepts fifo, variance and auto. Auto defaults to variance. Variance preserves coverage and maintains uniform interval. (default: variance)" });
|
||||
options.push_back({ "*", "-cram, --cache-ram N", "set the maximum cache size in MiB (default: %d, -1 - no limit, 0 - disable)",params.cache_ram_mib });
|
||||
options.push_back({ "*", "-crs, --cache-ram-similarity N", "max of similarity of prompt tokens to cache tokens that triggers prompt cache (default: %.2f).",params.cache_ram_similarity });
|
||||
options.push_back({ "*", "-cram-n-min --cache-ram-n-min N", "minimum number of the cached tokens that triggers prompt cache (default: %d).", params.cache_ram_n_min });
|
||||
|
||||
@@ -127,8 +127,17 @@ enum common_webui {
|
||||
COMMON_WEBUI_LLAMACPP,
|
||||
};
|
||||
|
||||
enum common_checkpoint_eviction {
|
||||
COMMON_CHECKPOINT_EVICTION_AUTO,
|
||||
COMMON_CHECKPOINT_EVICTION_FIFO,
|
||||
COMMON_CHECKPOINT_EVICTION_VARIANCE
|
||||
};
|
||||
|
||||
common_webui common_webui_from_name(const std::string& format);
|
||||
|
||||
common_checkpoint_eviction common_checkpoint_eviction_from_name(const std::string & format);
|
||||
|
||||
|
||||
struct thinking_tokens {
|
||||
bool exclude = true;
|
||||
std::string begin = "<think>";
|
||||
@@ -527,6 +536,7 @@ struct gpt_params {
|
||||
int32_t ctx_checkpoints_n = 32; // max number of context checkpoints per slot
|
||||
int32_t ctx_checkpoints_interval = 512; // minimum number of tokens between each context checkpoints
|
||||
int32_t ctx_checkpoints_tolerance = 5; // the number of tokens before the full prompt to create the checkpoint
|
||||
common_checkpoint_eviction ctx_checkpoint_eviction = COMMON_CHECKPOINT_EVICTION_VARIANCE;
|
||||
int32_t cache_ram_mib = 8192; // -1 = no limit, 0 - disable, 1 = 1 MiB, etc.
|
||||
int32_t cache_ram_n_min = 0; // min number of tokens required to save in the ram
|
||||
float cache_ram_similarity = 0.5f; // similarity of tokens to cached tokens
|
||||
|
||||
Reference in New Issue
Block a user