Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions common/preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,26 @@ common_presets common_presets_load(const std::string & path, common_params_conte
auto key_to_opt = get_map_key_opt(ctx_params);
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) {
common_preset preset;
if (section.first.empty()) {
Expand Down
6 changes: 6 additions & 0 deletions tools/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,12 @@ Example:
```ini
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,
; this will be used as the default config for that model
[ggml-org/MY-MODEL-GGUF:Q8_0]
Expand Down
Loading