This commit is contained in:
Xuan-Son Nguyen 2025-12-16 23:11:48 -05:00 committed by GitHub
commit 1f7589c46f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -177,6 +177,26 @@ common_presets common_presets_load(const std::string & path, common_params_conte
auto key_to_opt = get_map_key_opt(ctx_params); auto key_to_opt = get_map_key_opt(ctx_params);
auto ini_data = parse_ini_from_file(path); auto ini_data = parse_ini_from_file(path);
// merge "added" into "base", preserving existing keys in "base"
auto merge_sections = [](std::map<std::string, std::string> & base, const std::map<std::string, std::string> & added) {
for (const auto & [key, value] : added) {
if (base.find(key) == base.end()) {
base[key] = value;
}
}
};
// handle the "global" section as the default preset
if (ini_data.find("*") != ini_data.end()) {
auto & global_section = ini_data["*"];
for (auto & item : ini_data) {
merge_sections(item.second, global_section);
}
}
// TODO: support inheritance between presets in the future
// note: server-models also need to be aware of the case where presets inherit from cached models
for (auto section : ini_data) { for (auto section : ini_data) {
common_preset preset; common_preset preset;
if (section.first.empty()) { if (section.first.empty()) {

View File

@ -1438,6 +1438,12 @@ Example:
```ini ```ini
version = 1 version = 1
; (Optional) This section provides global settings shared across all presets.
; If the same key is defined in a specific preset, it will override the value in this global section.
[*]
c = 8192
n-gpu-layer = 8
; If the key corresponds to an existing model on the server, ; If the key corresponds to an existing model on the server,
; this will be used as the default config for that model ; this will be used as the default config for that model
[ggml-org/MY-MODEL-GGUF:Q8_0] [ggml-org/MY-MODEL-GGUF:Q8_0]