This commit is contained in:
Owen Qwen
2026-07-29 17:17:25 -05:00
parent fdd9fcf85e
commit a673afad85
17 changed files with 1071 additions and 11 deletions
+37
View File
@@ -1234,6 +1234,15 @@ bool common_params_parse(int argc, char ** argv, common_params & params, llama_e
exit(0);
}
params.lr.init();
llama_token_cache_params token_cache_params = llama_token_cache_default_params();
token_cache_params.path = params.token_cache_path.empty() ? nullptr : params.token_cache_path.c_str();
token_cache_params.capacity_bytes = params.token_cache_size_mib * 1024ull * 1024ull;
if (!llama_token_cache_configure(token_cache_params) && params.token_cache_size_mib != 0) {
LOG_WRN("%s", "token cache was already initialized; keeping its existing configuration\n");
}
if (params.token_cache_clear && !llama_token_cache_clear()) {
throw std::runtime_error("failed to clear token cache");
}
} catch (const std::invalid_argument & ex) {
fprintf(stderr, "%s\n", ex.what());
ctx_arg.params = params_org;
@@ -1636,6 +1645,34 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
params.cache_ram_mib = value;
}
).set_env("LLAMA_ARG_CACHE_RAM").set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}));
add_opt(common_arg(
{"--token-cache-size"}, "N",
string_format("shared tokenizer and tokenized-text cache size in MiB (default: %llu, 0 = disable)",
(unsigned long long) params.token_cache_size_mib),
[](common_params & params, int value) {
if (value < 0) {
throw std::invalid_argument("token-cache-size must be non-negative");
}
params.token_cache_size_mib = value;
}
).set_env("LLAMA_ARG_TOKEN_CACHE_SIZE"));
add_opt(common_arg(
{"--token-cache-dir"}, "PATH",
"path to the shared tokenizer and tokenized-text cache database",
[](common_params & params, const std::string & value) {
if (value.empty()) {
throw std::invalid_argument("token-cache-dir must not be empty");
}
params.token_cache_path = value;
}
).set_env("LLAMA_ARG_TOKEN_CACHE_DIR"));
add_opt(common_arg(
{"--token-cache-clear"},
"clear the shared tokenizer and tokenized-text cache before loading the model",
[](common_params & params) {
params.token_cache_clear = true;
}
).set_env("LLAMA_ARG_TOKEN_CACHE_CLEAR"));
add_opt(common_arg(
{"-kvu", "--kv-unified"},
{"-no-kvu", "--no-kv-unified"},