Add tokenizer longhaul cache
This commit is contained in:
@@ -817,6 +817,15 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
|
||||
if (params.load_mode == LLAMA_LOAD_MODE_LONGHAUL && params.longhaul_cache_bytes == 0) {
|
||||
throw std::invalid_argument("error: --longhaul requires --longhaul-cache N\n");
|
||||
}
|
||||
if (params.tokenizer_longhaul != (params.tokenizer_longhaul_cache_bytes != 0)) {
|
||||
throw std::invalid_argument(
|
||||
params.tokenizer_longhaul
|
||||
? "error: --tokenizer-longhaul requires --tokenizer-longhaul-cache N\n"
|
||||
: "error: --tokenizer-longhaul-cache requires --tokenizer-longhaul\n");
|
||||
}
|
||||
if (params.tokenizer_longhaul && params.token_cache_size_mib == 0) {
|
||||
throw std::invalid_argument("error: --tokenizer-longhaul requires an enabled persistent token cache\n");
|
||||
}
|
||||
|
||||
postprocess_cpu_params(params.cpuparams, nullptr);
|
||||
postprocess_cpu_params(params.cpuparams_batch, ¶ms.cpuparams);
|
||||
@@ -2646,6 +2655,23 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
|
||||
params.longhaul_cache_bytes = uint64_t(value) * 1024 * 1024 * 1024;
|
||||
}
|
||||
).set_env("LLAMA_ARG_LONGHAUL_CACHE"));
|
||||
add_opt(common_arg(
|
||||
{"--tokenizer-longhaul"},
|
||||
"build and page the Qwen3.5/Laguna tokenizer through a bounded cache",
|
||||
[](common_params & params) {
|
||||
params.tokenizer_longhaul = true;
|
||||
}
|
||||
).set_env("LLAMA_ARG_TOKENIZER_LONGHAUL"));
|
||||
add_opt(common_arg(
|
||||
{"--tokenizer-longhaul-cache"}, "N",
|
||||
"tokenizer-longhaul RAM cache size in MiB",
|
||||
[](common_params & params, int value) {
|
||||
if (value <= 0) {
|
||||
throw std::invalid_argument("tokenizer-longhaul cache size must be positive");
|
||||
}
|
||||
params.tokenizer_longhaul_cache_bytes = uint64_t(value) * 1024 * 1024;
|
||||
}
|
||||
).set_env("LLAMA_ARG_TOKENIZER_LONGHAUL_CACHE"));
|
||||
add_opt(common_arg(
|
||||
{"--numa"}, "TYPE",
|
||||
"attempt optimizations that help on some NUMA systems\n"
|
||||
|
||||
@@ -1592,6 +1592,8 @@ struct llama_model_params common_model_params_to_llama(common_params & params) {
|
||||
mparams.split_mode = params.split_mode;
|
||||
mparams.load_mode = params.load_mode;
|
||||
mparams.longhaul_cache_bytes = params.longhaul_cache_bytes;
|
||||
mparams.tokenizer_longhaul = params.tokenizer_longhaul;
|
||||
mparams.tokenizer_longhaul_cache_bytes = params.tokenizer_longhaul_cache_bytes;
|
||||
mparams.tensor_split = params.tensor_split;
|
||||
mparams.check_tensors = params.check_tensors;
|
||||
mparams.use_extra_bufts = !params.no_extra_bufts;
|
||||
|
||||
@@ -486,6 +486,8 @@ struct common_params {
|
||||
enum llama_split_mode split_mode = LLAMA_SPLIT_MODE_LAYER; // how to split the model across GPUs
|
||||
enum llama_load_mode load_mode = LLAMA_LOAD_MODE_MMAP; // how to load the model
|
||||
uint64_t longhaul_cache_bytes = 0;
|
||||
bool tokenizer_longhaul = false;
|
||||
uint64_t tokenizer_longhaul_cache_bytes = 0;
|
||||
|
||||
common_cpu_params cpuparams;
|
||||
common_cpu_params cpuparams_batch;
|
||||
|
||||
Reference in New Issue
Block a user