add option --keep-inp-out-in-metal and fix bugs in unmap

This commit is contained in:
Lizonghang
2025-01-22 11:15:19 +04:00
parent ce2ef9699f
commit facb4ea736
5 changed files with 142 additions and 131 deletions
+8
View File
@@ -737,6 +737,14 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
params.cuda_mem = value; // in GiB
}
).set_env("LLAMA_ARG_CUDA_MEM"));
// "--keep-inp-out-in-metal" is a temporary option to keep the input and output in metal
add_opt(llama_arg(
{"--keep-inp-out-in-metal"},
format("whether to keep input and output weight in metal (default: %s)", params.keep_inp_out_in_metal ? "true" : "false"),
[](gpt_params & params) {
params.keep_inp_out_in_metal = true;
}
).set_env("LLAMA_ARG_KEEP_INP_OUT_IN_METAL"));
add_opt(llama_arg(
{"-n", "--predict", "--n-predict"}, "N",
format("number of tokens to predict (default: %d, -1 = infinity, -2 = until context filled)", params.n_predict),
+1
View File
@@ -1603,6 +1603,7 @@ struct llama_model_params llama_model_params_from_gpt_params(const gpt_params &
mparams.use_mmap = params.use_mmap;
mparams.use_mlock = params.use_mlock;
mparams.check_tensors = params.check_tensors;
mparams.keep_inp_out_in_metal = params.keep_inp_out_in_metal;
std::copy(std::begin(params.n_layer_window), std::end(params.n_layer_window), mparams.n_layer_window);
if (params.kv_overrides.empty()) {
mparams.kv_overrides = NULL;
+1
View File
@@ -148,6 +148,7 @@ struct gpt_params {
std::string master_ip = "localhost"; // ip address of the master node
std::string next_node_ip = "localhost"; // ip address of my next node
bool unload = false; // unload layer weights after use or not
bool keep_inp_out_in_metal = false; // whether to keep input/output weight in metal, not by default
int32_t cuda_mem = 999.0; // cuda memory to use, in GiB
int32_t n_predict = -1; // new tokens to predict
int32_t n_ctx = 0; // context size