mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-18 08:44:49 +02:00
spec: remove --spec-config
This commit is contained in:
+23
-69
@@ -626,43 +626,6 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
|
||||
if (!params.speculative.tensor_buft_overrides.empty()) {
|
||||
params.speculative.tensor_buft_overrides.push_back({nullptr, nullptr});
|
||||
}
|
||||
{
|
||||
bool has_draft =!params.speculative.model.path.empty();
|
||||
bool has_draft_eagle3 = false; // TODO PR-18039: if params.speculative.eagle3
|
||||
bool has_lookup_caches = !params.speculative.lookup_cache_static.empty()
|
||||
&& !params.speculative.lookup_cache_dynamic.empty();
|
||||
bool has_simple = (params.speculative.draftless_type == COMMON_SPECULATIVE_TYPE_NGRAM_SIMPLE);
|
||||
bool found_config_draft = false;
|
||||
bool found_config_eagle3 = false;
|
||||
bool found_config_ngram_cache = false;
|
||||
bool found_config_ngram_simple = false;
|
||||
for (const auto & config : params.speculative.configs) {
|
||||
if (config.type == COMMON_SPECULATIVE_TYPE_DRAFT) {
|
||||
found_config_draft = true;
|
||||
}
|
||||
if (config.type == COMMON_SPECULATIVE_TYPE_EAGLE3) {
|
||||
found_config_eagle3 = true;
|
||||
}
|
||||
if (config.type == COMMON_SPECULATIVE_TYPE_NGRAM_CACHE) {
|
||||
found_config_ngram_cache = true;
|
||||
}
|
||||
if (config.type == COMMON_SPECULATIVE_TYPE_NGRAM_SIMPLE) {
|
||||
found_config_ngram_simple = true;
|
||||
}
|
||||
}
|
||||
if (has_simple && !found_config_ngram_simple) {
|
||||
params.speculative.configs.push_back(common_speculative_config(COMMON_SPECULATIVE_TYPE_NGRAM_SIMPLE));
|
||||
}
|
||||
if (has_lookup_caches && !found_config_ngram_cache) {
|
||||
params.speculative.configs.push_back(common_speculative_config(COMMON_SPECULATIVE_TYPE_NGRAM_CACHE));
|
||||
}
|
||||
if (has_draft && !found_config_draft) {
|
||||
params.speculative.configs.push_back(common_speculative_config(COMMON_SPECULATIVE_TYPE_DRAFT));
|
||||
}
|
||||
if (has_draft_eagle3 && !found_config_eagle3) {
|
||||
params.speculative.configs.push_back(common_speculative_config(COMMON_SPECULATIVE_TYPE_EAGLE3));
|
||||
}
|
||||
}
|
||||
|
||||
if (!params.chat_template.empty() && !common_chat_verify_template(params.chat_template, params.use_jinja)) {
|
||||
throw std::runtime_error(string_format(
|
||||
@@ -3431,17 +3394,20 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
|
||||
}
|
||||
).set_examples({LLAMA_EXAMPLE_SPECULATIVE, LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}));
|
||||
add_opt(common_arg(
|
||||
{"--spec-draftless"}, "[none|ngram-cache|ngram-simple]",
|
||||
{"--spec-draftless"}, "[none|ngram-cache|ngram-simple|ngram-map-k|ngram-map-k4v]",
|
||||
string_format("type of speculative decoding to use when no draft model is provided (default: %s)\n",
|
||||
common_speculative_type_to_str(params.speculative.draftless_type).c_str()),
|
||||
[](common_params & params, const std::string & value) {
|
||||
if (value == "none") {
|
||||
params.speculative.draftless_type = COMMON_SPECULATIVE_TYPE_NONE;
|
||||
} else if (value == "ngram-cache") {
|
||||
// TODO: this does nothing atm
|
||||
params.speculative.draftless_type = COMMON_SPECULATIVE_TYPE_NGRAM_CACHE;
|
||||
} else if (value == "ngram-simple") {
|
||||
params.speculative.draftless_type = COMMON_SPECULATIVE_TYPE_NGRAM_SIMPLE;
|
||||
} else if (value == "ngram-map-k") {
|
||||
params.speculative.draftless_type = COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K;
|
||||
} else if (value == "ngram-map-k4v") {
|
||||
params.speculative.draftless_type = COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K4V;
|
||||
} else {
|
||||
throw std::invalid_argument("unknown speculative decoding type without draft model");
|
||||
}
|
||||
@@ -3449,7 +3415,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
|
||||
).set_examples({LLAMA_EXAMPLE_SERVER}));
|
||||
add_opt(common_arg(
|
||||
{"--spec-ngram-size-n"}, "N",
|
||||
string_format("ngram size N for ngram-map speculative decoding, length of lookup n-gram (default: %d)", params.speculative.spec_ngram_size_n),
|
||||
string_format("ngram size N for ngram-simple/ngram-map speculative decoding, length of lookup n-gram (default: %d)", params.speculative.spec_ngram_size_n),
|
||||
[](common_params & params, int value) {
|
||||
if (value < 1 || value > 1024) {
|
||||
throw std::invalid_argument("ngram size N must be between 1 and 1024 inclusive");
|
||||
@@ -3459,7 +3425,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
|
||||
).set_examples({LLAMA_EXAMPLE_SERVER}));
|
||||
add_opt(common_arg(
|
||||
{"--spec-ngram-size-m"}, "N",
|
||||
string_format("ngram size M for ngram-map speculative decoding, length of draft m-gram (default: %d)", params.speculative.spec_ngram_size_m),
|
||||
string_format("ngram size M for ngram-simple/ngram-map speculative decoding, length of draft m-gram (default: %d)", params.speculative.spec_ngram_size_m),
|
||||
[](common_params & params, int value) {
|
||||
if (value < 1 || value > 1024) {
|
||||
throw std::invalid_argument("ngram size M must be between 1 and 1024 inclusive");
|
||||
@@ -3468,35 +3434,23 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
|
||||
}
|
||||
).set_examples({LLAMA_EXAMPLE_SERVER}));
|
||||
add_opt(common_arg(
|
||||
{"--spec-config"}, "SPECULATIVE_CONFIG",
|
||||
string_format("list of speculative decoding types, separated by ';', optionally followed by a colon and a comma-separated list of key=value pairs\n(types: %s)\n", common_speculative_type_name_str().c_str()),
|
||||
[](common_params & params, const std::string & value) {
|
||||
const auto config_strings = string_split<std::string>(value, ';');
|
||||
for (const auto & config_string : config_strings) {
|
||||
const auto parts = string_split<std::string>(config_string, ':');
|
||||
if (parts.size() < 1 || parts.size() > 2) {
|
||||
throw std::invalid_argument("invalid speculative decoding config");
|
||||
}
|
||||
const auto type_str = parts[0];
|
||||
const auto type = common_speculative_type_from_name(type_str);
|
||||
if (type == COMMON_SPECULATIVE_TYPE_COUNT) {
|
||||
throw std::invalid_argument(string_format("unknown speculative decoding type: %s", type_str.c_str()));
|
||||
}
|
||||
common_speculative_config spec_config = {type};
|
||||
if (parts.size() == 2) {
|
||||
const auto key_value_pairs = string_split<std::string>(parts[1], ',');
|
||||
for (const auto & key_value_pair : key_value_pairs) {
|
||||
const auto key_value = string_split<std::string>(key_value_pair, '=');
|
||||
if (key_value.size() != 2) {
|
||||
throw std::invalid_argument("invalid key=value pair");
|
||||
}
|
||||
const auto & key = key_value[0];
|
||||
const auto & value = key_value[1];
|
||||
spec_config.config[key] = value;
|
||||
}
|
||||
}
|
||||
params.speculative.configs.push_back(spec_config);
|
||||
{"--spec-ngram-check-rate"}, "N",
|
||||
string_format("ngram check rate for ngram-simple/ngram-map speculative decoding (default: %d)", params.speculative.spec_ngram_check_rate),
|
||||
[](common_params & params, int value) {
|
||||
if (value < 1) {
|
||||
throw std::invalid_argument("ngram check rate must be at least 1");
|
||||
}
|
||||
params.speculative.spec_ngram_check_rate = value;
|
||||
}
|
||||
).set_examples({LLAMA_EXAMPLE_SERVER}));
|
||||
add_opt(common_arg(
|
||||
{"--spec-ngram-min-hits"}, "N",
|
||||
string_format("minimum hits for ngram-map speculative decoding (default: %d)", params.speculative.spec_ngram_min_hits),
|
||||
[](common_params & params, int value) {
|
||||
if (value < 1) {
|
||||
throw std::invalid_argument("ngram min hits must be at least 1");
|
||||
}
|
||||
params.speculative.spec_ngram_min_hits = value;
|
||||
}
|
||||
).set_examples({LLAMA_EXAMPLE_SERVER}));
|
||||
add_opt(common_arg(
|
||||
|
||||
Reference in New Issue
Block a user