Skip to content

feat(backend): env-configurable llama.cpp log verbosity (LLOYAL_LLAMA_VERBOSITY) - #48

Open
lloyal-research wants to merge 1 commit into
mainfrom
feat/llama-verbosity-env
Open

feat(backend): env-configurable llama.cpp log verbosity (LLOYAL_LLAMA_VERBOSITY)#48
lloyal-research wants to merge 1 commit into
mainfrom
feat/llama-verbosity-env

Conversation

@lloyal-research

Copy link
Copy Markdown
Contributor

What

Make llama.cpp's log-verbosity threshold env-overridable via LLOYAL_LLAMA_VERBOSITY.

Why

BackendManager hardcoded common_log_set_verbosity_thold(LOG_DEFAULT_LLAMA) = INFO. llama.cpp's per-context allocation lines (KV self size, RS buffer size, compute buffer size) are emitted at ggml-INFO but map to LOG_LEVEL_TRACE (4), and the callback prints only verbosity <= thold — so at the default INFO (3) they're filtered, making per-context memory invisible.

LLOYAL_LLAMA_VERBOSITY=4 lifts the threshold to TRACE and surfaces them. Default behavior is unchanged when the env is unset.

Impact

This is the tool that produced the served-host memory breakdown in lloyal-infra/docs/scaling.md §8 (the GDN recurrent-state-∝-nSeqMax finding that fixed the Metal multi-session thrash). 6-line, no behavior change unless the env is set. No dedicated publish needed — rides the next natural lloyal.node release.

…_VERBOSITY)

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.
Copilot AI review requested due to automatic review settings July 22, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an environment override for llama.cpp’s log verbosity threshold so operators can surface otherwise-filtered per-context memory/allocation log lines when needed, while keeping the default behavior unchanged when the env var is unset.

Changes:

  • Introduces LLOYAL_LLAMA_VERBOSITY to override the common_log_set_verbosity_thold(...) threshold.
  • Reads the env var during backend initialization and applies the configured threshold (or the default when unset).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/BackendManager.hpp
Comment on lines +53 to +54
const char* verbEnv = std::getenv("LLOYAL_LLAMA_VERBOSITY");
common_log_set_verbosity_thold(verbEnv ? std::atoi(verbEnv) : LOG_DEFAULT_LLAMA);
Comment thread src/BackendManager.hpp
Comment on lines 3 to 6
#include <llama/llama.h>
#include "log.h"
#include <cstdlib>
#include <mutex>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants