Repository navigation
Stop the GGUF header and the chat detail polls from filling the log - #10040
Conversation
Driving four chat tabs against Qwen3.8-27B UD-Q4_K_XL for twenty seconds wrote
296 structured lines. 140 of them, 47%, were one model's capabilities repeated,
and another 46 were two polls saying a generation in progress was still in
progress. The same session now writes 117.
GGUF metadata, 140 lines to 5. Ten call sites reach _read_gguf_metadata, each
through its own throwaway probe so the live backend's state is never clobbered,
so nothing is shared between them: one POST /api/inference/estimate-memory walks
the header three to five times and the Load Model panel fires that route on
every slider change. The facts are identical every time, so only the first read
of a given file says them out loud and the repeats go to debug. Keyed on
(path, size, mtime), so a rebuilt or re-downloaded GGUF is described again, and
failing open when the file cannot be stat'd. detect_reasoning_flags takes the
level from its caller. Detected remote GGUF repo goes to debug for the same
reason: from_identifier is re-resolved on every validate, estimate and load, and
the load path already announces the model it starts.
Chat detail polls, 46 lines to 7. /api/chat/threads/{id} and its /forks sibling
are driven by the streaming persistence loop, measured 0.57s and 0.40s apart
across the four tabs. Every suppressor set matches a path exactly, which #7087
chose deliberately so detail and message reads kept their access line, so a
templated path could not join any class. normalize_poll_path collapses the id
segment for classification and for the de-duplication bucket only; the line that
is emitted still names the real thread. They join the existing 10s heartbeat
rather than being dropped, so detail reads stay visible, which is what #7087 was
protecting. One bucket per template, like the liveness group: four tabs polling
four threads ask one question. Deeper paths are deliberately out of reach, so a
message read still logs every time.
log_budget follows: policy.classify and bucket_of read the middleware's own
normaliser rather than a second copy, both paths are declared in session.py with
measured periods, and BUSY_LINE_ENVELOPE moves 260 to 325. That rise is an
accounting change, not a volume regression. These two paths sat in the normal
class and were in no scenario at all, so the envelope never saw them; modelled
over the busy window unsuppressed they are 675 lines. They now enter at 59.
Errors, mutations and --verbose are unaffected, and there are tests for each.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3692a26dbe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| first_read = _note_gguf_metadata_read(gguf_path) | ||
| level = "info" if first_read else "debug" | ||
| log_at = logger.info if first_read else logger.debug |
There was a problem hiding this comment.
Apply the dedupe level to diffusion detection
For a diffusion GGUF, the logger.info at lines 12727–12731 executes before log_at is selected, so every header probe still emits the diffusion-detection line at info. Since the estimate-memory path reads the same header several times per request, DiffusionGemma models retain an unbounded repeated GGUF metadata: line; select the level before this check and route that message through the same dedupe decision.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The observation is right: the diffusion line at llama_cpp.py:12727 is emitted about sixty lines before first_read is computed at :12788, so it is not deduped. It stays as it is. self._is_diffusion is assigned at :12724 on every read and is what routes the model to the diffusion runner, so nothing stops being detected and nothing is lost; this is a level preference on one more line, and it is pre-existing behaviour rather than something this PR introduces. The 140 repeated lines this PR was measured against were the capability block, not this one.
| # over one 20s session with four chat tabs, this block was 140 of 296 log | ||
| # lines, 47% of everything Studio wrote. The facts are identical every time, | ||
| # so only the first read of a given file says them out loud. | ||
| first_read = _note_gguf_metadata_read(gguf_path) |
There was a problem hiding this comment.
Key model-sensitive metadata logs by their identifier
When the first reader is a generic probe, the file-only cache can suppress the first accurate capability description. For example, routes/models.py sets _model_identifier = "kv-estimate" before reading a DeepSeek GGUF; detect_reasoning_flags therefore does not recognize its thinking template, but this call marks the file as logged, and the later live load with the real DeepSeek identifier sends its correct reasoning line only to debug. Include the effective model identity in the dedupe decision or avoid marking these placeholder probes as the authoritative first read.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The setup is real: routes/models.py:3908 sets _model_identifier to kv-estimate right before read_gguf_metadata, and the DeepSeek arm of detect_reasoning_flags is the one gated on the identifier rather than the template. It is not a collision hazard though. The key is (abspath, size, mtime_ns), which identifies a file, and every fact in the block (context_length, chat_template length, and all seven flags) is derived from that file's bytes, so two different models cannot share a key and produce different capabilities. More to the point, detection does not depend on the level: at llama_cpp.py:12795-12808 detect_reasoning_flags runs and all seven self. attributes are assigned whatever log_level is, and _supports_reasoning is surfaced to clients rather than being log-only. The demoted line carries nothing that nothing else carries.
|
Confirmed the header block still logs at info on every probe in studio/backend/core/inference/llama_cpp.py, and that the templated thread and forks reads fall outside the exact-match sets from #7087, so they were never covered. Will get this reviewed. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Measurement
Four chat tabs against
unsloth/Qwen3.8-27B-GGUFUD-Q4_K_XL, prompts sent together, twenty seconds of a real session:GGUF metadata:blockDetected remote GGUF repoGET /api/chat/threads/{id}GET /api/chat/threads/{id}/forksThe GGUF header block
_read_gguf_metadatahas ten call sites, and each builds its own throwaway probe viaobject.__new__precisely so the live backend's metadata is never clobbered, so nothing is shared between them. OnePOST /api/inference/estimate-memorywalks the header three to five times through_gguf_memory_breakdown,_gguf_runtime_bytes,_gguf_layer_count,_is_embedding_ggufand_classify_diffusion_gguf, and the Load Model panel fires that route on every slider change.The five lines say the same thing about the same file every time, so only the first read of a given file says them at info and the repeats go to debug. Keyed on
(path, size, mtime)rather than name, so a rebuilt or re-downloaded GGUF at the same path is described again, and failing open to "log it" when the file cannot be stat'd, because an unidentifiable read is better said out loud than silently swallowed.detect_reasoning_flagstakes the level from its caller.Detected remote GGUF repogoes to debug for the same reason:from_identifieris re-resolved on every validate, estimate and load, and the load path already announces the model it actually starts.The chat detail polls
/api/chat/threads/{id}and/api/chat/threads/{id}/forksare driven by the streaming persistence loop, not a timer: measured 0.57s and 0.40s apart aggregated across the four tabs.Every suppressor set matches a path exactly. That was deliberate, from #7087, so that thread detail and message reads kept their access line while the list polls were suppressed, which is still the right call for a read a user triggers. What changed is that streaming now drives these two on a loop, and a templated path cannot join any existing class.
normalize_poll_pathcollapses the id segment. It is used for classification and for the de-duplication bucket only; the line that is emitted still names the real thread. They join the existing 10s heartbeat rather than being dropped outright, so detail reads stay visible, which is what #7087 was protecting. One bucket per template, the same choice the liveness group makes: four tabs polling four different threads are asking one question, so budgeting them per id would expect four lines where the design intends one.Deeper paths are deliberately out of reach of the pattern, so
/threads/{id}/messages/{mid}still logs every time.log_budget
policy.classifyandpolicy.bucket_ofcall the middleware's own normaliser throughgetattr, so the class is still derived fromloggers/handlers.pyat run time rather than duplicated, and the harness still works on a revision without it.session.pywith measured periods, recorded at the replay's 0.5s tick since that is the grain it can actually poll on.BUSY_LINE_ENVELOPEmoves 260 to 325. That rise is an accounting change, not a volume regression, and it is worth being explicit about: these two paths sat in thenormalclass and were in no scenario at all, so the envelope never saw them. Modelled over the busy window unsuppressed they are 675 lines. They now enter at 59.KNOWN_UNCLASSIFIED_POLLSstays empty.STEADY_IDLE_LINE_ENVELOPEis unchanged: these are busy-only.Tests
Seven new cases in
test_logging_middleware.py: the heartbeat, four tabs sharing one bucket, message reads not collapsing, the list path untouched, a failing poll still logging, mutations still logging, and--verboserestoring every line. Six in a newtest_gguf_metadata_log_volume.py: first read speaks, repeats do not, a changed file is described again, an unstattable path fails open, the cache is bounded, and demoting the level does not change what is detected.The last one matters most: this is a logging change, and a capability that quietly disappeared when the line was demoted would be a real regression hiding behind a quieter log.
test_log_budget.pyandtest_log_rule_parity.pypass. Wider run over-k "log or logging or gguf or metadata or reasoning or inference or llama": 6314 passed, 10 failed. Cleanmainwith the identical selection: 6301 passed, the same 10 failed. The +13 are the new tests; the 10 are pre-existingtest_diffusion_*,test_safetensors_reasoning_stream,test_cached_gguf_routesandtest_training_progress_callbackfailures from a local environment mismatch.