From c979ba27df1ddd66c9dcf0574b8901a4b650c6e4 Mon Sep 17 00:00:00 2001 From: lloyal-research Date: Wed, 22 Jul 2026 18:21:58 +1000 Subject: [PATCH] feat(backend): env-configurable llama.cpp log verbosity (LLOYAL_LLAMA_VERBOSITY) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BackendManager pinned common_log_set_verbosity_thold to LOG_DEFAULT_LLAMA (INFO), which filters llama.cpp's per-context KV / recurrent-state / compute-buffer allocation lines — they're emitted at ggml INFO but map to LOG_LEVEL_TRACE, and the callback prints only verbosity <= thold. Make the threshold env-overridable (LLOYAL_LLAMA_VERBOSITY), defaulting to the shipped level when unset, so those allocation lines can be surfaced on demand for memory profiling: LLOYAL_LLAMA_VERBOSITY=4 (TRACE) shows KV self size / RS buffer size / compute buffer size per context. This is the tool that measured the served-host memory breakdown in lloyal-infra scaling.md §8. --- src/BackendManager.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BackendManager.hpp b/src/BackendManager.hpp index 2090a8f..beb51da 100644 --- a/src/BackendManager.hpp +++ b/src/BackendManager.hpp @@ -2,6 +2,7 @@ #include #include "log.h" +#include #include namespace liblloyal_node { @@ -46,7 +47,11 @@ class BackendManager { resolveBackends(); #endif llama_backend_init(); - common_log_set_verbosity_thold(LOG_DEFAULT_LLAMA); + // Verbosity threshold is env-overridable (LLOYAL_LLAMA_VERBOSITY) so llama.cpp's + // per-context KV / compute-buffer allocation lines can be surfaced on demand; + // defaults to the shipped level when the env var is unset. + const char* verbEnv = std::getenv("LLOYAL_LLAMA_VERBOSITY"); + common_log_set_verbosity_thold(verbEnv ? std::atoi(verbEnv) : LOG_DEFAULT_LLAMA); llama_log_set(common_log_default_callback, nullptr); }