From 6c665f38fd8d2178c4ae4c190fd374f3a87c057d Mon Sep 17 00:00:00 2001 From: Nexes the Elder <124105151+Nexesenex@users.noreply.github.com> Date: Fri, 20 Mar 2026 09:40:56 +0100 Subject: [PATCH] sweep-bench: add -minilog argument to reduce verbose logging (#1468) Purpose: Add --minilog flag to llama-sweep-bench that filters log output to show only essential GPU/layer distribution information while suppressing verbose model metadata and per-layer device assignment messages. Changes: - Add llama_selective_log_callback with blacklist approach (sweep-bench.cpp) Blacklisted patterns (hidden): - Per-layer device assignments ('Setting default device in layer') - KV metadata dump header and entries - Tensor type counts - Model validation messages - EOG/special token cache info - Metadata printout (llm_load_print_meta, print_info) - Layer sizes table - Tensor loading info (llm_load_tensors) - Separator lines - Most common cases of incomplete/continuation lines are also hidden All other log output is shown, including: - GPU VRAM info - Split/buffer distribution per device - Graph split estimates - Final benchmark table and timings --- common/common.cpp | 4 +++ common/common.h | 1 + examples/sweep-bench/sweep-bench.cpp | 41 ++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/common/common.cpp b/common/common.cpp index 68d77295..1cd51fef 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -2169,6 +2169,10 @@ bool gpt_params_find_arg(int argc, char ** argv, const std::string & arg, gpt_pa else { invalid_param = true; } return true; } + if (arg == "--minilog") { + params.minilog = true; + return true; + } #ifndef LOG_DISABLE_LOGS // Parse args for logging parameters diff --git a/common/common.h b/common/common.h index 3ae18ceb..aa189a69 100644 --- a/common/common.h +++ b/common/common.h @@ -471,6 +471,7 @@ struct gpt_params { std::string lora_outfile = "ggml-lora-merged-f16.gguf"; bool sweep_bench_output_jsonl = false; + bool minilog = false; }; diff --git a/examples/sweep-bench/sweep-bench.cpp b/examples/sweep-bench/sweep-bench.cpp index 42764ffc..19a0af87 100644 --- a/examples/sweep-bench/sweep-bench.cpp +++ b/examples/sweep-bench/sweep-bench.cpp @@ -14,9 +14,46 @@ #include #include #include +#include #include #include +static void llama_selective_log_callback(ggml_log_level level, const char * text, void * user_data) { + (void) level; + (void) user_data; + const char * skip_patterns[] = { + "Setting default device in layer", + "llama_model_loader: Dumping metadata", + "llama_model_loader: - kv ", + "llama_model_loader: - type ", + "validate_override:", + "load: printing all EOG", + "load: - ", + "load: special tokens cache", + "load: token to piece cache", + "llm_load_print_meta:", + "print_info:", + "------------------- Layer sizes", + "Layer ", + "llm_load_tensors:", + "==========================", + }; + for (const char * pat : skip_patterns) { + if (strstr(text, pat) != nullptr) { + return; + } + } + // Skip incomplete/continuation lines + int i = 0; + while (text[i] == ' ' || text[i] == '\t') { + i++; + } + if (text[i] == ',' || text[i] == '(' || text[i] == ')'|| (text[i] >= '0' && text[i] <= '9')) { + return; + } + LOG_TEE("%s", text); +} + static void print_usage(int, char ** argv) { LOG_TEE("\nexample usage:\n"); LOG_TEE("\n %s -m model.gguf -c 8192 -b 2048 -ub 512\n", argv[0]); @@ -33,6 +70,10 @@ int main(int argc, char ** argv) { } if (params.nrep < 1) params.nrep = 1; + if (params.minilog) { + llama_log_set(llama_selective_log_callback, nullptr); + } + // init LLM llama_backend_init();