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();