-ub, --ubatch-size <n> (default: 512)
-ctk, --cache-type-k <t> (default: f16)
-ctv, --cache-type-v <t> (default: f16)
- -t, --threads <n> (default: 16)
+ -dt, --defrag-thold <f> (default: -1)
+ -t, --threads <n> (default: system dependent)
-C, --cpu-mask <hex,hex> (default: 0x0)
--cpu-strict <0|1> (default: 0)
--poll <0...100> (default: 50)
-ngl, --n-gpu-layers <n> (default: 99)
- -rpc, --rpc <rpc_servers> (default: )
+ -rpc, --rpc <rpc_servers> (default: none)
-sm, --split-mode <none|layer|row> (default: layer)
-mg, --main-gpu <i> (default: 0)
-nkvo, --no-kv-offload <0|1> (default: 0)
Multiple values can be given for each parameter by separating them with ','
or by specifying the parameter multiple times. Ranges can be given as
-'start-end' or 'start-end+step' or 'start-end*mult'.
+'first-last' or 'first-last+step' or 'first-last*mult'.
```
llama-bench can perform three types of tests:
for (int i = first; i <= last;) {
result.push_back(i);
+ int prev_i = i;
+
if (op == '+') {
i += step;
} else if (op == '*') {
} else {
throw std::invalid_argument("invalid range format");
}
+
+ if (i <= prev_i) {
+ throw std::invalid_argument("invalid range");
+ }
}
search_start = match.suffix().first;
}
std::vector<int> n_ubatch;
std::vector<ggml_type> type_k;
std::vector<ggml_type> type_v;
+ std::vector<float> defrag_thold;
std::vector<int> n_threads;
std::vector<std::string> cpu_mask;
std::vector<bool> cpu_strict;
/* n_ubatch */ { 512 },
/* type_k */ { GGML_TYPE_F16 },
/* type_v */ { GGML_TYPE_F16 },
+ /* defrag_thold */ { -1.0f },
/* n_threads */ { cpu_get_num_math() },
/* cpu_mask */ { "0x0" },
/* cpu_strict */ { false },
join(transform_to_str(cmd_params_defaults.type_k, ggml_type_name), ",").c_str());
printf(" -ctv, --cache-type-v <t> (default: %s)\n",
join(transform_to_str(cmd_params_defaults.type_v, ggml_type_name), ",").c_str());
+ printf(" -dt, --defrag-thold <f> (default: %s)\n",
+ join(cmd_params_defaults.defrag_thold, ",").c_str());
printf(" -t, --threads <n> (default: %s)\n",
join(cmd_params_defaults.n_threads, ",").c_str());
printf(" -C, --cpu-mask <hex,hex> (default: %s)\n",
printf(
"Multiple values can be given for each parameter by separating them with ','\n"
"or by specifying the parameter multiple times. Ranges can be given as\n"
- "'start-end' or 'start-end+step' or 'start-end*mult'.\n");
+ "'first-last' or 'first-last+step' or 'first-last*mult'.\n");
}
static ggml_type ggml_type_from_name(const std::string & s) {
break;
}
params.type_v.insert(params.type_v.end(), types.begin(), types.end());
+ } else if (arg == "-dt" || arg == "--defrag-thold") {
+ if (++i >= argc) {
+ invalid_param = true;
+ break;
+ }
+ auto p = string_split<float>(argv[i], split_delim);
+ params.defrag_thold.insert(params.defrag_thold.end(), p.begin(), p.end());
} else if (arg == "-t" || arg == "--threads") {
if (++i >= argc) {
invalid_param = true;
if (params.type_v.empty()) {
params.type_v = cmd_params_defaults.type_v;
}
+ if (params.defrag_thold.empty()) {
+ params.defrag_thold = cmd_params_defaults.defrag_thold;
+ }
if (params.n_gpu_layers.empty()) {
params.n_gpu_layers = cmd_params_defaults.n_gpu_layers;
}
int n_ubatch;
ggml_type type_k;
ggml_type type_v;
+ float defrag_thold;
int n_threads;
std::string cpu_mask;
bool cpu_strict;
llama_context_params to_llama_cparams() const {
llama_context_params cparams = llama_context_default_params();
- cparams.n_ctx = n_prompt + n_gen + n_depth;
- cparams.n_batch = n_batch;
- cparams.n_ubatch = n_ubatch;
- cparams.type_k = type_k;
- cparams.type_v = type_v;
- cparams.offload_kqv = !no_kv_offload;
- cparams.flash_attn = flash_attn;
- cparams.embeddings = embeddings;
- cparams.op_offload = !no_op_offload;
+ cparams.n_ctx = n_prompt + n_gen + n_depth;
+ cparams.n_batch = n_batch;
+ cparams.n_ubatch = n_ubatch;
+ cparams.type_k = type_k;
+ cparams.type_v = type_v;
+ cparams.defrag_thold = defrag_thold;
+ cparams.offload_kqv = !no_kv_offload;
+ cparams.flash_attn = flash_attn;
+ cparams.embeddings = embeddings;
+ cparams.op_offload = !no_op_offload;
return cparams;
}
for (const auto & nub : params.n_ubatch)
for (const auto & tk : params.type_k)
for (const auto & tv : params.type_v)
+ for (const auto & defrag_thold : params.defrag_thold)
for (const auto & nkvo : params.no_kv_offload)
for (const auto & fa : params.flash_attn)
for (const auto & nt : params.n_threads)
/* .n_ubatch = */ nub,
/* .type_k = */ tk,
/* .type_v = */ tv,
+ /* .defrag_thold = */ defrag_thold,
/* .n_threads = */ nt,
/* .cpu_mask = */ cm,
/* .cpu_strict = */ cs,
/* .n_ubatch = */ nub,
/* .type_k = */ tk,
/* .type_v = */ tv,
+ /* .defrag_thold = */ defrag_thold,
/* .n_threads = */ nt,
/* .cpu_mask = */ cm,
/* .cpu_strict = */ cs,
/* .n_ubatch = */ nub,
/* .type_k = */ tk,
/* .type_v = */ tv,
+ /* .defrag_thold = */ defrag_thold,
/* .n_threads = */ nt,
/* .cpu_mask = */ cm,
/* .cpu_strict = */ cs,
int poll;
ggml_type type_k;
ggml_type type_v;
+ float defrag_thold;
int n_gpu_layers;
llama_split_mode split_mode;
int main_gpu;
poll = inst.poll;
type_k = inst.type_k;
type_v = inst.type_v;
+ defrag_thold = inst.defrag_thold;
n_gpu_layers = inst.n_gpu_layers;
split_mode = inst.split_mode;
main_gpu = inst.main_gpu;
"model_type", "model_size", "model_n_params", "n_batch", "n_ubatch", "n_threads",
"cpu_mask", "cpu_strict", "poll", "type_k", "type_v", "n_gpu_layers",
"split_mode", "main_gpu", "no_kv_offload", "flash_attn", "tensor_split", "tensor_buft_overrides",
+ "defrag_thold",
"use_mmap", "embeddings", "no_op_offload", "n_prompt", "n_gen", "n_depth", "test_time",
"avg_ns", "stddev_ns", "avg_ts", "stddev_ts",
};
field == "use_mmap" || field == "embeddings") {
return BOOL;
}
- if (field == "avg_ts" || field == "stddev_ts") {
+ if (field == "avg_ts" || field == "stddev_ts" || field == "defrag_thold") {
return FLOAT;
}
return STRING;
std::to_string(flash_attn),
tensor_split_str,
tensor_buft_overrides_str,
+ std::to_string(defrag_thold),
std::to_string(use_mmap),
std::to_string(embeddings),
std::to_string(no_op_offload),
if (params.type_v.size() > 1 || params.type_v != cmd_params_defaults.type_v) {
fields.emplace_back("type_v");
}
+ if (params.defrag_thold.size() > 1 || params.defrag_thold != cmd_params_defaults.defrag_thold) {
+ fields.emplace_back("defrag_thold");
+ }
if (params.main_gpu.size() > 1 || params.main_gpu != cmd_params_defaults.main_gpu) {
fields.emplace_back("main_gpu");
}