Skip to content

Studio: stop two lines repeating in the server log for the whole session - #8306

Merged
danielhanchen merged 10 commits into
mainfrom
studio-quiet-repeating-log-lines
Aug 10, 2026
Merged

danielhanchen merged 10 commits into
mainfrom
studio-quiet-repeating-log-lines

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Two lines dominate a normal Studio session's log and neither carries information after its first appearance: the model-defaults resolution, which repeats for as long as a browser tab is open, and the raw transformers weight-load output from the RAG embedder, which is unstructured ANSI text in an otherwise JSON log. Both are quieted the way #7087 and #7869 did it: the signal is kept, the repetition is not.

1. "Loaded default model defaults from ..." repeats every poll

GET /api/inference/status is polled every 5s for as long as the app is open. It calls load_inference_config -> load_model_defaults, which logs the resolved config path at info on every call. The path never changes, so the line just repeats.

Measured on one machine from logs/studio_a.log, counting only that event:

session duration "model defaults" lines rate
before, one tab 8.7 min 22 2.5/min
before, four tabs 10.8 min 206 19.0/min
after 18.2 min 2 0.1/min

The four-tab number is the interesting one: every open tab polls independently, so the line scales with tabs and made up the largest single share of non-access events.

_log_model_defaults now announces each (model, resolved path) once at info and drops later repeats to debug, so --verbose and LOG_LEVEL=debug still show every one. The set is bounded (4096 entries, cleared on overflow) so a long-lived server with many models cannot grow it without end. This covers all four resolution branches plus the "No default config found" warning, which had the same repeat problem.

Deliberately not a cache: the returned dict is unchanged and the file is still read every call, so editing a YAML under assets/configs/model_defaults/ during development still takes effect immediately. Only the logging is deduplicated.

2. Raw transformers output on every boot

Loading the RAG embedder (unsloth/bge-small-en-v1.5, core/rag/embeddings.py) writes this to stdout on every single boot:

Loading weights:   0%|          | 0/199 [00:00<?, ?it/s]Loading weights: 100%|...| 199/199 [00:00<00:00, 4297.35it/s]
[1mBertModel LOAD REPORT[0m from: unsloth/bge-small-en-v1.5
Key                     | Status     |  |
------------------------+------------+--+-
embeddings.position_ids | UNEXPECTED |  |

Notes:
- UNEXPECTED:	can be ignored when loading from different task/architecture; not ok if you expect identical arch.

That is 7 lines, one of them a tqdm progress bar and one carrying ANSI colour codes, in a log whose every other line is JSON. It fires unconditionally because bge-small-en-v1.5 ships a legacy embeddings.position_ids key that the current BertModel does not expect, so the report is identical every time. transformers >= 5 emits it through logger.warning (transformers/utils/loading_report.py), not print, so a filter can reach it, the same technique as the existing _DropTorchDtypeDeprecation in loggers/config.py.

_quiet_transformers_load() wraps only that one load and:

  • attaches a filter that captures the LOAD REPORT record instead of letting it print, then re-emits it on our own logger, at debug when it reports only UNEXPECTED keys and at warning if it ever mentions MISSING, MISMATCH or CONVERSION;
  • disables the transformers progress bar for the duration and restores the previous setting exactly, so a caller that had already disabled bars stays disabled, and every other model load keeps its normal bar and report.

Nothing is lost. embeddings.py already logs loading embedding model <name> on <device> at info, which is the line that actually says what happened, and a report that could change the model's behaviour is promoted rather than hidden.

Measured directly by loading the embedder in a subprocess with and without the change: 7 lines of tqdm and report before, 0 after.

What stays logged

  • The first resolution of every model's defaults, at info.
  • Every repeat, at debug.
  • The "No default config found for model X" warning, once per model, at warning.
  • loading embedding model ... on ..., unchanged.
  • Any load report mentioning MISSING, MISMATCH or CONVERSION, at warning, on the structured logger.
  • All progress bars and load reports for user-visible model loads, untouched.

Tests

studio/backend/tests/test_model_defaults_log_once.py (5 cases): the repeat logs once at info, the repeats are still emitted at debug, a second model gets its own announcement, the announced set stays bounded, and the returned config is unaffected.

studio/backend/tests/test_embedding_load_report_quiet.py (6 cases): the report is swallowed and captured, unrelated transformers warnings still pass through, MISSING is flagged serious, the filter is removed after the context, and the progress-bar setting is restored both when it was on and when the caller had already turned it off.

Related suites, all green on this branch: test_rag_embeddings, test_embedding_model_settings, test_embedding_model_security_gate, test_offline_embedding_minimal, test_model_defaults_none_guard, test_kimi_k3_reasoning_defaults, test_models_get_model_config_case_resolution, test_logging_middleware plus the two new files: 163 passed, 1 skipped.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8122b9bdcc

ℹ️ 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".

Comment on lines +275 to +278
if hub_bars_off:
try:
from huggingface_hub.utils import disable_progress_bars
disable_progress_bars()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not restore a stale Hub progress state

With the optional helper pre-cache enabled, main.py starts that background thread before the post-warm embedder thread; the helper temporarily disables Hub progress bars and reenables them in its finally. If this context snapshots that temporary disabled state and the helper finishes before the embedding load, this block disables Hub bars again after the helper has restored them, leaving progress globally disabled for later downloads. The Hub state restoration needs synchronization with other users or a mechanism that does not overwrite changes made while the context was active.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I looked at this one and left it. The snapshot is only taken when this context also disables the transformers flag, and the worst outcome of losing the race is that Hub bars stay off in a server process that has no terminal and whose download progress already reaches the UI as hub_download_progress events. Adding cross-thread synchronization around a global cosmetic setting would cost more than the failure it prevents.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen and others added 8 commits August 10, 2026 08:31
…Hub state

Re-emit captured reports from a finally so a load that raises still reports
MISSING or MISMATCH; capture only records from the loading thread, since the
filters sit on process-global loggers; snapshot and restore the Hub progress
setting separately, because transformers' enable_progress_bar() also enables
the Hub's.
An UNEXPECTED key other than embeddings.position_ids can change retrieval, so
it stays a warning; adapter-backed embedding models report through
transformers.integrations.peft, which now gets the same filter.
A report listing the legacy buffer and a discarded learned weight was treated
as benign because position_ids appeared somewhere in the table.
transformers appends a Notes section explaining each status, so the UNEXPECTED
note line was read as a key row and made every unexpected report serious. The
test helper now restores propagate and level on the process-global loggers.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen
danielhanchen force-pushed the studio-quiet-repeating-log-lines branch from 42fd452 to c1c2a11 Compare August 10, 2026 08:35
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…tests

This module logs through the stdlib logger, so a serious report was re-emitted
with its ANSI escapes and newlines intact; it is stripped and flattened now.
The once-only announcement check is under a lock, and the tests snapshot and
restore both process-global progress-bar switches.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

encoder.position_ids_projection.weight is a real discarded weight; the key
column is parsed and only embeddings.position_ids, optionally under a module
prefix, is exempt.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 982e725ed0

ℹ️ 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".

danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Aug 10, 2026
@danielhanchen
danielhanchen merged commit c599472 into main Aug 10, 2026
39 of 44 checks passed
@danielhanchen
danielhanchen deleted the studio-quiet-repeating-log-lines branch August 10, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant