The metadata kv dump in llama_model_loader was measured to be very expensive (~10 milliseconds on e.g. Mac M5) for certain models. This was not an issue prior to this bump in version of llama.cpp because we had a custom `llama_model_load_from_file_handle`. Upstream added support for it so we adopted it, but our custom was skipping it. The patch skips the dump using a pre-existing `trace` gate. Differential Revision: https://phabricator.services.mozilla.com/D308368
28 lines
1.1 KiB
Diff
28 lines
1.1 KiB
Diff
diff --git a/src/llama-model-loader.cpp b/src/llama-model-loader.cpp
|
|
index d75719583881..cf3c7fd2945e 100644
|
|
--- a/src/llama-model-loader.cpp
|
|
+++ b/src/llama-model-loader.cpp
|
|
@@ -814,9 +814,11 @@ llama_model_loader::llama_model_loader(
|
|
ftype = (llama_ftype) ftype_val;
|
|
}
|
|
}
|
|
-
|
|
+ // Firefox: this dump proved quite expensive for nothing in profiling.
|
|
+ // Gated away in default builds.
|
|
+ if (trace > 0) {
|
|
LLAMA_LOG_INFO("%s: Dumping metadata keys/values. Note: KV overrides do not apply in this output.\n", __func__);
|
|
-
|
|
+
|
|
for (int i = 0; i < n_kv; i++) {
|
|
const char * name = gguf_get_key(metadata, i);
|
|
const enum gguf_type type = gguf_get_kv_type(metadata, i);
|
|
@@ -834,7 +836,7 @@ llama_model_loader::llama_model_loader(
|
|
|
|
LLAMA_LOG_INFO("%s: - kv %3d: %42s %-16s = %s\n", __func__, i, name, type_name.c_str(), value.c_str());
|
|
}
|
|
-
|
|
+ }
|
|
// print type counts
|
|
for (auto & kv : n_type) {
|
|
if (kv.second == 0) {
|