Skip to content

Studio: quiet noisy logs, log real progress, and speed up Windows/macOS dataset prep - #7087

Merged
danielhanchen merged 28 commits into
mainfrom
fix/studio-export-status-log-noise
Jul 15, 2026
Merged

danielhanchen merged 28 commits into
mainfrom
fix/studio-export-status-log-noise

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Jul 12, 2026 •

Copy link
Copy Markdown
Member

Summary

The Studio request access log was dominated by high-frequency UI polls and per-turn chat CRUD that carry no signal. This trims that noise while keeping the informative events (generation, tool calls, code execution, engine stats, and errors), adds real download, model-load, training, and llama.cpp-update progress, silences a cosmetic transformers deprecation warning, and speeds up dataset prep on Windows/macOS.

Changes

  1. Exclude /api/export/status from the access log (polled every 5s to detect export start). Handled like the existing /api/train/status (_EXCLUDED_PATHS).
  2. Collapse the pure-liveness polls (/api/health, /api/auth/status, /api/inference/status, /api/inference/monitor) to a 10s heartbeat via _QUIET_POLL_PATHS, instead of one line per poll.
  3. Log real progress instead of poll pings: emit one hub_download_progress line per 10% step (shared snapshot reader) and one inference_load_progress line per 10% step (load-progress route).
  4. Fully suppress the successful (2xx) access line for the download and load progress polls. This covers the model-browser hub polls (download-status, download-progress, gguf-download-progress, active-downloads, transport-status, and the datasets/ equivalents), the training-tab polls (/api/models/download-progress, /api/models/gguf-download-progress, /api/datasets/download-progress), and /api/inference/load-progress. They fire about twice a second for the whole download or load; progress surfaces via the change 3 events and the UI, so the per-poll line adds nothing.
  5. Drop chat thread/project CRUD from the access log. A chat turn fans out about twenty requests under /api/chat/threads and /api/chat/projects (list, fetch, per-message forks, message writes) that only reflect the UI re-rendering, and on first load these fire before the initial token refresh so they 401 until /api/auth/refresh runs and the retries succeed. Suppress both the 2xx line and that transient pre-auth 401 (_is_quiet_success); genuine 4xx/5xx on these paths still log.
  6. Silence the transformers torch_dtype deprecation warning. It is emitted once via logger.warning_once (logging, not warnings), so a warnings filter cannot catch it; a small logging.Filter in setup_logging drops that record on the transformers loggers that emit it.
  7. Consolidate the tab-switch list polls and per-poll internal logs. Switching between the Train, Export, and Chat tabs refetches /api/train/runs, /api/models/checkpoints, /api/models/local, and /api/rag/knowledge-bases on a timer; collapse these to the 10s _QUIET_POLL_PATHS heartbeat (first hit and errors still log). Also downgrade two INFO lines that fired once per poll or reconnect to debug: the checkpoints scan summary (Found N training runs) and the per-reconnect SSE resume line (SSE reconnect: resuming from step N). The meaningful replayed N missed steps line, logged only when steps were actually replayed, stays at info.
  8. Speed up dataset prep on Windows/macOS. TOKENIZERS_PARALLELISM was forced off globally to stop datasets' forked map() workers from deadlocking, but that fork only happens on Linux; on spawn platforms map() runs in-process (dataset_map_num_proc returns None), so the flag just left the fast tokenizer single-threaded and dataset prep ran serially on one core. Keep it off on Linux (fork safety) and on for Windows/macOS, where nothing forks. Measured about 7x faster tokenization (12.5s to 1.7s for 20k rows on a 32-core Windows box); multiprocessing was slower there (spawn re-imports), so single-process plus tokenizer threads is the fastest option.
  9. Log training status to the server log. Step/loss/epoch only streamed to the UI via SSE, so the log showed inference engine_stats and train/runs heartbeats but nothing about the run itself. Emit one throttled training_progress line (step/total, percent, loss, epoch, eta) from the training event pump: the first step, then at most every 30s, plus the final step, resyncing when a new run restarts the step counter. Per-step UI streaming is unchanged.
  10. Quiet the llama.cpp prebuilt update polls and log real update progress. Clicking Update polls /api/llama/update-status about twice a second for the whole download and install; suppress its 2xx access line (_QUIET_SUCCESS_PATHS) and emit one throttled llama_update_progress line per 10% step from the status route, so the update reports progress without a line per poll. The existing llama update: installing and llama update: success events still bracket it.
  11. Quiet the export log-tail poll. The Export tab polls /api/export/logs about once a second to stream the subprocess output into the UI panel; suppress its 2xx access line (_QUIET_SUCCESS_PATHS). The real progress is already logged as event-driven Export subprocess status: <phase> lines plus the subprocess start and checkpoint-loaded events, and errors still log.

Notes

  • No API change. The only behavior change is faster tokenization on spawn platforms (change 8); the UI is otherwise unaffected (progress bars and chat read the response bodies, not the logs).
  • Only successful (2xx) access lines are suppressed, plus the transient pre-auth 401 on chat thread/project polls. All other non-2xx responses and request_failed always log.
  • Progress logging is throttled per job/load/run/update and re-syncs across restarts.

The frontend polls /api/export/status every 5s to detect export start, so it
fires continuously even when idle. Each poll emitted an info request_completed
access line, making up most of the server access logs. Add it to _EXCLUDED_PATHS
alongside /api/train/status. The endpoint is unchanged; export state is still
logged by the export modules and streamed over SSE, so no signal is lost.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds the /api/export/status endpoint to the set of excluded paths in the logging handlers configuration. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@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: 3b0aab9a47

ℹ️ 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 thread studio/backend/loggers/handlers.py Outdated
"/api/train/status",
"/api/train/metrics",
"/api/train/hardware",
"/api/export/status",

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 Preserve non-2xx access logs for export status

Adding this path to _EXCLUDED_PATHS suppresses every completed /api/export/status response before _is_redundant_repeat can apply its GET/2xx-only logic. Since the route is protected by Depends(get_current_subject) and converts backend failures into HTTP responses, expired-token 401/403 responses and status-check 500s now lose their request_completed access line, even though the middleware comments and commit intent say errors/non-2xx should remain visible. Consider quiet-poll deduping this path instead, or only excluding successful GETs.

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.

Good catch. Moved /api/export/status out of _EXCLUDED_PATHS into _QUIET_SUCCESS_PATHS in 4e17ee5, so only 2xx is suppressed and 401/403/500 still log. Covered by test_export_status_error_still_logs.

download-status and gguf-download-progress (plus the dataset equivalents)
are polled about twice a second for the whole download, so each emitted an
info request_completed line. Add them to _QUIET_POLL_PATHS so they collapse
to one heartbeat line per 10s instead of one per poll.
The access log carried no real progress, only poll pings. Emit one
hub_download_progress line per 10% step from the shared snapshot progress
reader, so an active download shows actual percentage without a line per
poll. Throttled per job and resynced if the same download restarts.
@danielhanchen danielhanchen changed the title Studio: exclude /api/export/status from request access logs Studio: quiet noisy request access-log polls and log real download progress Jul 12, 2026
pre-commit-ci Bot and others added 2 commits July 12, 2026 11:28
A single chat turn fans out about twenty requests under /api/chat/threads
and /api/chat/projects (list, fetch, per-message forks, and the message
writes) that only reflect the UI re-rendering. Suppress their 2xx access
line so the log keeps the signal (generation, tool calls, code execution,
engine stats) and errors. Non-2xx on these paths still log.

@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: 11e18300b8

ℹ️ 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 thread studio/backend/loggers/handlers.py Outdated
scope["method"], path, scope.get("query_string", b""), status_code, end_time
if (
not excluded
and not _is_chat_crud_noise(path, status_code)

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 Update stale logging middleware expectations

This new unconditional chat CRUD filter suppresses successful /api/chat/threads and /api/chat/projects responses before the dedupe logic runs. The checked-in middleware tests still use those routes as normal logged requests (test_duplicate_get_within_window_deduped, test_mutations_and_errors_are_never_deduped, and test_quiet_poll_paths_use_longer_heartbeat_window in studio/backend/tests/test_logging_middleware.py), so the backend test suite will fail unless those expectations are updated to use non-quiet paths or explicitly assert the new suppression.

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.

Right, the tests were updated in 4e17ee5 to match the new suppression (GET-only, chat mutations still log, quiet paths use non-suppressed routes). test_logging_middleware.py passes 16/16 at head.

transformers logs "`torch_dtype` is deprecated! Use `dtype` instead!" once at
model-config load via logger.warning_once (logging, not warnings), so a warnings
filter cannot catch it. Attach a small logging.Filter in setup_logging, which
runs before any model config is parsed, to drop that record on the transformers
loggers that emit it.
…ogress

The frontend polls /api/inference/load-progress about twice a second for the
whole model load, so each emitted a request_completed line. Add it to
_QUIET_POLL_PATHS (heartbeat) and emit one inference_load_progress line per 10%
step from the load-progress route, so a load shows real percentage instead of a
line per poll.
@danielhanchen danielhanchen changed the title Studio: quiet noisy request access-log polls and log real download progress Studio: quiet noisy access-log polls and chat CRUD, log real download/load progress Jul 12, 2026
The download-status, download-progress, gguf-download-progress, active-downloads
and transport-status polls (model and dataset), plus inference load-progress,
fire ~2x/s for the whole download or load. Their progress is now reported by the
hub_download_progress / inference_load_progress events (and the viewer's progress
line), so the per-poll access line adds nothing. Drop it on 2xx and keep it on
errors, instead of the prior 10s heartbeat. Chat CRUD suppression is folded into
the same _is_quiet_success helper.
The training tab polls /api/models/download-progress and
/api/datasets/download-progress about twice a second for the whole prep phase.
These are separate routes from the /api/hub equivalents and only scan the cache,
so their 2xx access line adds nothing (on Windows they always read 0 since the
bytes live in snapshots/, not blobs/). Suppress the 2xx line and keep errors,
alongside /api/models/gguf-download-progress.

@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: 155641f795

ℹ️ 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 thread studio/backend/loggers/handlers.py Outdated
Comment on lines +74 to +76
"/api/models/download-progress",
"/api/models/gguf-download-progress",
"/api/datasets/download-progress",

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 Keep legacy progress polls visible until instrumented

When chat/model-load or training flows poll the legacy /api/models/*download-progress and /api/datasets/download-progress endpoints, these handlers still live in routes/models.py and routes/datasets.py and do not call hub.services.snapshot_progress, so they never emit the new hub_download_progress event. Suppressing their 2xx access lines here removes all log visibility for download progress in those flows; either leave these legacy paths deduped/logged or add equivalent progress-event logging to those handlers before quieting them.

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.

Agreed. The legacy /api/models and /api/datasets download-progress paths now sit in _QUIET_POLL_PATHS (10s heartbeat) instead of being suppressed, so they keep a signal. See test_legacy_download_progress_heartbeats_not_suppressed.

On first load the SPA fires chat thread/project GETs before the initial token
refresh, so they 401 until /api/auth/refresh runs and the retries succeed. That
pre-auth 401 is a bootstrap artifact, not an error; suppress it alongside the
already-quiet 2xx line. Genuine 4xx/5xx on these paths, the download/load poll
401s, and all /api/auth/* still log.
Switching between the Train, Export, and Chat tabs refetches list endpoints on a
timer, and each hit re-logs internal detail. Heartbeat /api/train/runs,
/api/models/checkpoints, /api/models/local and /api/rag/knowledge-bases (10s
window, first hit and errors still log), and downgrade two per-poll INFO lines to
debug: the checkpoints scan summary ("Found N training runs") and the
per-reconnect SSE resume line. The meaningful "replayed N missed steps" line,
logged only when steps were actually replayed, stays at info.

@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: 5ca28cdb29

ℹ️ 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 thread studio/backend/loggers/handlers.py Outdated
def _is_quiet_success(path: str, status_code: int) -> bool:
if 200 <= status_code < 300:
return path in _QUIET_SUCCESS_PATHS or path.startswith(_QUIET_SUCCESS_PREFIXES)
return status_code == 401 and path.startswith(_QUIET_SUCCESS_PREFIXES)

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 Keep chat 401s visible in access logs

For any chat thread/project request that returns 401 outside the initial refresh race (for example, a direct API call or browser tab with a missing/expired token hitting /api/chat/threads), this predicate treats it as quiet and suppresses the middleware access log before the normal non-2xx logging path. The chat routes are protected by Depends(get_current_subject) and do not emit their own auth-failure log, so these real unauthorized failures disappear while other endpoint 401s remain visible; consider narrowing this to the known pre-refresh case or leaving 401s logged.

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.

Fixed in c72e41e. Chat 401 suppression is now gated on a per-middleware bootstrap latch (_auth_refreshed) that flips on the first successful /api/auth/refresh, so a genuine post-bootstrap 401 logs. See test_chat_401_logged_after_first_auth_refresh.

danielhanchen and others added 2 commits July 12, 2026 23:38
TOKENIZERS_PARALLELISM was forced off everywhere to stop datasets' forked map()
workers from deadlocking, but that fork only happens on Linux. On spawn platforms
(Windows/macOS) dataset.map() runs in-process (dataset_map_num_proc returns None),
so disabling tokenizer parallelism leaves the fast tokenizer single-threaded and
dataset prep runs serially on one core. Keep it off on Linux (fork safety) and on
for spawn platforms, where there is no fork to deadlock. Measured ~7x faster
tokenization (12.5s -> 1.7s for 20k rows on a 32-core Windows box).
@danielhanchen danielhanchen changed the title Studio: quiet noisy access-log polls and chat CRUD, log real download/load progress Studio: quiet noisy logs, log real progress, and speed up Windows/macOS dataset prep Jul 13, 2026
Training step/loss/epoch only went to the UI via SSE, so the server log showed
inference engine_stats and train/runs heartbeats but nothing about the actual
run. Emit one throttled training_progress line (step/total, percent, loss, epoch,
eta) from the CUDA event pump: the first step, then at most every 30s, plus the
final step, resyncing when a new run restarts the counter. Per-step UI streaming
is unchanged.
…progress

The prebuilt llama.cpp update polls /api/llama/update-status about twice a second
for the whole download and install. Suppress its 2xx access line (errors still
log) and emit one throttled llama_update_progress line per 10% step from the
status route, so the update shows progress without a line per poll. The existing
"llama update: installing" and "llama update: success" events still bracket it.
The Export tab polls /api/export/logs about once a second to stream the export
subprocess output into the UI panel. Suppress its 2xx access line; the real
progress is already logged as event-driven "Export subprocess status: <phase>"
lines plus the subprocess start and checkpoint-loaded events, and errors still log.
Make the quiet-success access-log suppression GET-only so chat thread/project
mutations (POST/PUT/DELETE) still log; only their list-poll 2xx and the
transient pre-auth 401 are dropped.

Suppress /api/export/status 2xx only (move it out of the all-status exclude
set) so a 401/403/500 on it stays visible.

Legacy /api/models and /api/datasets download-progress polls emit no
hub_download_progress events, so heartbeat them via the 10s quiet-poll window
instead of suppressing outright, keeping download visibility (notably on
Linux). The event-emitting /api/hub download polls stay fully suppressed.

Update and extend the middleware tests to cover GET-only suppression, the
export-status error path, and the legacy download heartbeat.
@danielhanchen

Copy link
Copy Markdown
Member Author

Follow-up in 4e17ee5 addresses the review feedback:

  • Access-log suppression is now GET-only, so chat thread/project mutations (POST/PUT/DELETE) still log; only their list-poll 2xx and the transient first-load pre-auth 401 are dropped.
  • /api/export/status is suppressed on 2xx only (moved out of the all-status exclude set), so a 401/403/500 on it stays visible.
  • The legacy /api/models and /api/datasets download-progress polls emit no hub_download_progress events, so they now heartbeat on the 10s quiet-poll window instead of being suppressed outright, which keeps download visibility (notably on Linux). The event-emitting /api/hub download polls stay fully suppressed.
  • Middleware tests updated and extended to cover GET-only suppression, the export-status error path, and the legacy download heartbeat.

pre-commit-ci Bot and others added 2 commits July 13, 2026 11:47
Comment-only pass: collapse the multi-line explanations in the logging
middleware and the throttled training-progress logger to fewer lines while
keeping the rationale. No behavior change.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

Emit a structured export_progress event per phase (consolidated in the server
log like training and download progress) instead of a plain status string, and
add a phase milestone at the start of the heavy export step so the
merge/save/convert is visible in the server log, not only in the forwarded
stdout panel.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@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: 2030235499

ℹ️ 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 thread studio/backend/loggers/handlers.py Outdated
if method != "GET":
return False
if 200 <= status_code < 300:
return path in _QUIET_SUCCESS_PATHS or path.startswith(_QUIET_SUCCESS_PREFIXES)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Limit chat suppression to the intended list polls

When a successful GET hits detail routes such as /api/chat/threads/{thread_id}, /api/chat/projects/{project_id}, or /api/chat/threads/{thread_id}/messages (all present in routes/chat_history.py), this startswith branch treats them as quiet list polls and drops request_completed. Those endpoints are not the high-frequency list polls described by the comment, so successful detail/message reads lose all access and latency logging; use exact list paths or a more specific allowlist before suppressing.

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.

Fixed in 82be8f2. Switched to exact list-path matching, so only GET /api/chat/threads and /api/chat/projects are suppressed; detail and message reads (/threads/{id}, /threads/{id}/messages, /projects/{id}, ...) keep their access and latency logs. Added test_chat_detail_and_message_reads_still_log.

The chat thread/project suppression matched by startswith, so it also dropped the 2xx access line for detail and message reads (/threads/{id}, /threads/{id}/messages, /threads/{id}/messages/{id}, /projects/{id}) that are not the high-frequency list polls, losing their access and latency logging. Match the two list paths exactly instead, so only the intended list polls (and their pre-auth 401 race) are suppressed while detail and message reads keep their access line. Add a regression test.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

Resolve start_training conflict: keep main's spawn-tracking refactor (#7056)
and re-apply the progress-log throttle reset inside the new reset-state block.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@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: 3d79208513

ℹ️ 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 +185 to +190
if 200 <= status_code < 300 and path == _AUTH_REFRESH_PATH:
self._auth_refreshed = True
if (
not excluded
and not _is_quiet_success(
scope["method"], path, status_code, not self._auth_refreshed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Track auth bootstrap per client

Because this flag is stored once on the middleware instance, a successful /api/auth/refresh from any session permanently closes the bootstrap window for the whole server. On a later page reload or a different browser session, the chat list GETs can again race ahead of that session's refresh and return the same transient 401s, but pre_auth is now false so those noisy failures are logged as real ones; the suppression only works until the first refresh after startup.

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.

The read is correct: the latch is per-process, so after the first refresh a later bootstrap race is logged rather than suppressed. Keeping it as is though. It errs toward visibility (it never hides a genuine failure, it only lets a few transient 401s through), and it cannot be made robust: a pre-auth race 401 and a real expired-token 401 are the same event (an expired token), so there is no server-side signal that separates a reload the client will auto-refresh from a genuinely expired session. The latch suppresses the cold-start burst, which is the common case, without a per-client heuristic that still could not tell the two apart.

Comment on lines +5455 to +5457
prev = _last_load_progress_step
if step == prev:
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Reset load progress for each load

If a previous GGUF load logged the 100% step, a later small or cached load whose first sampled /api/inference/load-progress response is already fraction=1.0 hits step == prev and returns, so that new load emits no inference_load_progress line while the access log for this endpoint is suppressed. Resetting/keying the throttle by the current load/process would preserve the intended per-load progress signal.

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.

Fixed in e52aa11. The throttle now resets at load initiation (_load_model_impl), so a cached load that reports 100% on its first poll still logs its inference_load_progress line instead of hitting step == prev from a prior completed load. Added test_load_progress_throttle.

The load-progress throttle (_last_load_progress_step) is a module global that persisted across loads, so a cached or small load whose first sampled /api/inference/load-progress response already reported fraction=1.0 hit step == prev (10) from a prior completed load and emitted no inference_load_progress line, while that endpoint's access log is suppressed, leaving the new load with no progress signal. Arm the throttle at load initiation in _load_model_impl so each load's first step always logs. Add a regression test.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: e52aa11b30

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

Collapse a few verbose comments (tokenizer-parallelism note, torch_dtype filter, legacy download-poll heartbeat, chat list-path suppression) to fewer lines without changing intent or code.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen
danielhanchen merged commit a6aa4ff into main Jul 15, 2026
48 of 49 checks passed
@danielhanchen
danielhanchen deleted the fix/studio-export-status-log-noise branch July 15, 2026 13:49
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: fefcfb6e30

ℹ️ 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 that referenced this pull request Aug 25, 2026
Log reduction in Studio is several PRs deep (#6377, #7087, #8310, #8311)
and every round started the same way: someone noticed a log was huge,
measured it, and trimmed it. Nothing stopped the next chatty endpoint,
and nothing told the author they had added one.

Five guards, all CPU-only, no network, no sleeping. A 30 minute idle
session and a 5 minute in-flight session are replayed through the real
LoggingMiddleware against a virtual clock, so a thirty minute scenario
runs in a second and lands identically on a loaded runner.

  budget       lines per class against a formula of the poll period and
               the dedup window, plus an envelope on the whole scenario
  classify     a path cannot be quieted without recording how often it
               is polled, and cannot be polled without being classified
  signal       failures and mutations log at every interval, and the
               scenario is proved to have exercised the real middleware
               before any count from it is trusted
  parity       one JSON fixture defines a successful access record for
               both the backend and the desktop shell
  bounds       every log family prunes, and the two line caps agree

The signal guard is the point. An upper bound on log lines is satisfied
just as well by a middleware that was never mounted, a logger replaced
with a no-op, a scenario that stopped issuing requests, or an error log
someone deleted to get under the number. Each of those now fails.

Two ledgers record what is already broken rather than weakening the
rules to accommodate it: /api/settings/remote-access and /api/liveness
sit in the 300ms burst class and write a line per poll, and the
llama-server and diffusion-server directories never prune. Both ledgers
are self-expiring, so fixing an entry forces its removal.

Verified by mutation: eight deliberate breakages, each turning exactly
the intended guard red.
danielhanchen added a commit that referenced this pull request Aug 25, 2026
* Studio: guard log volume in CI so it cannot regress unnoticed

Log reduction in Studio is several PRs deep (#6377, #7087, #8310, #8311)
and every round started the same way: someone noticed a log was huge,
measured it, and trimmed it. Nothing stopped the next chatty endpoint,
and nothing told the author they had added one.

Five guards, all CPU-only, no network, no sleeping. A 30 minute idle
session and a 5 minute in-flight session are replayed through the real
LoggingMiddleware against a virtual clock, so a thirty minute scenario
runs in a second and lands identically on a loaded runner.

  budget       lines per class against a formula of the poll period and
               the dedup window, plus an envelope on the whole scenario
  classify     a path cannot be quieted without recording how often it
               is polled, and cannot be polled without being classified
  signal       failures and mutations log at every interval, and the
               scenario is proved to have exercised the real middleware
               before any count from it is trusted
  parity       one JSON fixture defines a successful access record for
               both the backend and the desktop shell
  bounds       every log family prunes, and the two line caps agree

The signal guard is the point. An upper bound on log lines is satisfied
just as well by a middleware that was never mounted, a logger replaced
with a no-op, a scenario that stopped issuing requests, or an error log
someone deleted to get under the number. Each of those now fails.

Two ledgers record what is already broken rather than weakening the
rules to accommodate it: /api/settings/remote-access and /api/liveness
sit in the 300ms burst class and write a line per poll, and the
llama-server and diffusion-server directories never prune. Both ledgers
are self-expiring, so fixing an entry forces its removal.

Verified by mutation: eight deliberate breakages, each turning exactly
the intended guard red.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: fail CI when the app polls a path the log budget never declared

The budget suite compares two backend files against each other: the suppression
sets in loggers/handlers.py and the poll cadences in log_budget/session.py. A
pull request that adds a polling call site in the frontend edits neither, so
nothing fails, the endpoint lands in the normal class on a 300 ms window, and
the access log grows by lines nobody chose.

Static analysis does not close it. Polling here is 53 setInterval call sites,
most of them UI timers rather than fetches, plus 257 setTimeout of which an
unknown number are recursive poll loops, and the fetch usually sits several
helper layers below the timer.

So watch the browser. Walk the sidebar sections, count API requests per dwell
rather than across the walk (a timer repeats within one dwell, a per-view fetch
fires once and stops, and summing the two is what makes navigation look like
polling), and fail on any path repeated inside a single dwell that is absent
from the budget.

Measured on a runner with no GPU and no model, two paths qualify. The floor is
set there so a run that observed nothing fails instead of reporting green, and
the docstring states plainly that polls gated behind a loaded model are outside
what this can see.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Run the declared-polls guard where a backend actually exists

The step landed in studio-frontend-ci's build job, which drives Playwright
against a vite dev server: no backend, no BASE_URL, no auth. The suite reads
BASE_URL at import, so it would have failed on a KeyError every run rather than
guarding anything.

Move it to studio-ui-smoke's ui-indicator job, which installs Studio with
--local --no-torch and already boots an authenticated server per engine, and
reuse that job's boot/rotate/teardown script instead of duplicating it. The
script's suite path becomes STUDIO_PW_SUITE with its current value as the
default, so every existing caller is unchanged.

Own port and home, for the reason the three engines get one each: a shared home
races on the bootstrap password. tests/studio/** is already in this workflow's
paths filter, so no trigger change is needed.

* Ratchet the log budget onto a main that has #8763

Rebasing onto the merge turned three of these guards red, which is what they are
for: each one refuses to let a ledger outlive the problem it records.

  KNOWN_UNCLASSIFIED_POLLS  /api/liveness and /api/settings/remote-access now
                            have heartbeat classes, so both entries went stale.
  KNOWN_UNBOUNDED_FAMILIES  llama-server and diffusion-server now prune.
  the Rust parity check     process.rs implements the success rule but no Rust
                            test read the shared fixture, so the corpus was only
                            ever checked from Python.

Both ledgers are now empty. Added the shared_access_log_fixture_tests module the
fixture names, which asserts all 14 cases against is_backend_access_log_line;
verified green with cargo test.

Idle envelope ratcheted 1450 -> 1170 against a re-measured 1110. The old note
predicted the fix would take idle to roughly 930 and that was wrong: a 10s
heartbeat against a 5s poll still emits half of /api/settings/remote-access, 180
lines over 30 minutes, now the joint-largest contributor. Left at 1450 there
would have been 340 lines of slack, enough for a new 10s endpoint to land
unnoticed; at 1170 that same endpoint trips the envelope.

* Name the declared-polls suite where CI can see it

test_every_playwright_driver_is_invoked_by_ci caught this, and it was right on
both counts.

Routing the suite through STUDIO_PW_SUITE meant the only place its path appeared
was an env: block, and that guard reads run:, uses: and with:, never env:. Worse,
wrapping the script's invocation in ${STUDIO_PW_SUITE:-...} hid the suite that
was already there: the guard reported TWO orphans, mine and
playwright_loaded_models_indicator.py, which had been named literally since it
was written. A parameterisation that makes an existing suite invisible is a bad
trade even when it saves duplication.

So drop the indirection. The script goes back untouched, and the step moves to
the ui-smoke extra shard, which already boots a Studio on 18894 and already mints
the credentials, so every sibling step there is just 'python tests/studio/<driver>.py' against
it. Mine now reads the same, needs no second
boot, and the guard matches it the ordinary way.

Placed last in the shard: it dwells for two minutes and rotates the bootstrap
password, so a step after it would wait, then meet a password it did not mint.

Verified locally: the full Workflow guard suites step, 698 passed.

* Let the replay model a slow request

The harness could not express the case the suppressors are blindest to. Both of
them key on the status code and neither reads how long the request took, so a
200 that took a minute is indistinguishable from a 200 that took a millisecond
-- and _app_returning sent its response without touching the clock, so every
replayed request cost zero virtual time. A budget cannot bound what its harness
cannot express.

Request grows a duration_ms, defaulting to 0 so every existing scenario is
unchanged, and the poll loop now reads the clock instead of its own counter so
time spent inside a slow handler counts against the session rather than
extending it. Idle stays at 1110 and busy at 239, measured, and all 93 tests
pass.

The two new tests assert TODAY's behaviour, not the desired behaviour: a slow
success on a quiet-success path still writes nothing. The gap is worth closing,
but a guard that tolerated either answer would let an exemption be added and
then removed again unnoticed, so closing it should flip these deliberately and
budget the new volume. Measured, an unbounded exemption emits one line per
request on a sustained degradation, which is the growth these budgets exist to
stop; it needs a heartbeat of its own.

The third test guards the other two. If duration_ms ever stopped reaching the
middleware, every "slow" assertion here would silently be testing a fast
request. Verified by breaking the advance on purpose: that test, and only that
test, goes red.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen added a commit that referenced this pull request Aug 25, 2026
* Studio: guard log volume in CI so it cannot regress unnoticed

Log reduction in Studio is several PRs deep (#6377, #7087, #8310, #8311)
and every round started the same way: someone noticed a log was huge,
measured it, and trimmed it. Nothing stopped the next chatty endpoint,
and nothing told the author they had added one.

Five guards, all CPU-only, no network, no sleeping. A 30 minute idle
session and a 5 minute in-flight session are replayed through the real
LoggingMiddleware against a virtual clock, so a thirty minute scenario
runs in a second and lands identically on a loaded runner.

  budget       lines per class against a formula of the poll period and
               the dedup window, plus an envelope on the whole scenario
  classify     a path cannot be quieted without recording how often it
               is polled, and cannot be polled without being classified
  signal       failures and mutations log at every interval, and the
               scenario is proved to have exercised the real middleware
               before any count from it is trusted
  parity       one JSON fixture defines a successful access record for
               both the backend and the desktop shell
  bounds       every log family prunes, and the two line caps agree

The signal guard is the point. An upper bound on log lines is satisfied
just as well by a middleware that was never mounted, a logger replaced
with a no-op, a scenario that stopped issuing requests, or an error log
someone deleted to get under the number. Each of those now fails.

Two ledgers record what is already broken rather than weakening the
rules to accommodate it: /api/settings/remote-access and /api/liveness
sit in the 300ms burst class and write a line per poll, and the
llama-server and diffusion-server directories never prune. Both ledgers
are self-expiring, so fixing an entry forces its removal.

Verified by mutation: eight deliberate breakages, each turning exactly
the intended guard red.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: fail CI when the app polls a path the log budget never declared

The budget suite compares two backend files against each other: the suppression
sets in loggers/handlers.py and the poll cadences in log_budget/session.py. A
pull request that adds a polling call site in the frontend edits neither, so
nothing fails, the endpoint lands in the normal class on a 300 ms window, and
the access log grows by lines nobody chose.

Static analysis does not close it. Polling here is 53 setInterval call sites,
most of them UI timers rather than fetches, plus 257 setTimeout of which an
unknown number are recursive poll loops, and the fetch usually sits several
helper layers below the timer.

So watch the browser. Walk the sidebar sections, count API requests per dwell
rather than across the walk (a timer repeats within one dwell, a per-view fetch
fires once and stops, and summing the two is what makes navigation look like
polling), and fail on any path repeated inside a single dwell that is absent
from the budget.

Measured on a runner with no GPU and no model, two paths qualify. The floor is
set there so a run that observed nothing fails instead of reporting green, and
the docstring states plainly that polls gated behind a loaded model are outside
what this can see.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Run the declared-polls guard where a backend actually exists

The step landed in studio-frontend-ci's build job, which drives Playwright
against a vite dev server: no backend, no BASE_URL, no auth. The suite reads
BASE_URL at import, so it would have failed on a KeyError every run rather than
guarding anything.

Move it to studio-ui-smoke's ui-indicator job, which installs Studio with
--local --no-torch and already boots an authenticated server per engine, and
reuse that job's boot/rotate/teardown script instead of duplicating it. The
script's suite path becomes STUDIO_PW_SUITE with its current value as the
default, so every existing caller is unchanged.

Own port and home, for the reason the three engines get one each: a shared home
races on the bootstrap password. tests/studio/** is already in this workflow's
paths filter, so no trigger change is needed.

* Ratchet the log budget onto a main that has #8763

Rebasing onto the merge turned three of these guards red, which is what they are
for: each one refuses to let a ledger outlive the problem it records.

  KNOWN_UNCLASSIFIED_POLLS  /api/liveness and /api/settings/remote-access now
                            have heartbeat classes, so both entries went stale.
  KNOWN_UNBOUNDED_FAMILIES  llama-server and diffusion-server now prune.
  the Rust parity check     process.rs implements the success rule but no Rust
                            test read the shared fixture, so the corpus was only
                            ever checked from Python.

Both ledgers are now empty. Added the shared_access_log_fixture_tests module the
fixture names, which asserts all 14 cases against is_backend_access_log_line;
verified green with cargo test.

Idle envelope ratcheted 1450 -> 1170 against a re-measured 1110. The old note
predicted the fix would take idle to roughly 930 and that was wrong: a 10s
heartbeat against a 5s poll still emits half of /api/settings/remote-access, 180
lines over 30 minutes, now the joint-largest contributor. Left at 1450 there
would have been 340 lines of slack, enough for a new 10s endpoint to land
unnoticed; at 1170 that same endpoint trips the envelope.

* Name the declared-polls suite where CI can see it

test_every_playwright_driver_is_invoked_by_ci caught this, and it was right on
both counts.

Routing the suite through STUDIO_PW_SUITE meant the only place its path appeared
was an env: block, and that guard reads run:, uses: and with:, never env:. Worse,
wrapping the script's invocation in ${STUDIO_PW_SUITE:-...} hid the suite that
was already there: the guard reported TWO orphans, mine and
playwright_loaded_models_indicator.py, which had been named literally since it
was written. A parameterisation that makes an existing suite invisible is a bad
trade even when it saves duplication.

So drop the indirection. The script goes back untouched, and the step moves to
the ui-smoke extra shard, which already boots a Studio on 18894 and already mints
the credentials, so every sibling step there is just 'python tests/studio/<driver>.py' against
it. Mine now reads the same, needs no second
boot, and the guard matches it the ordinary way.

Placed last in the shard: it dwells for two minutes and rotates the bootstrap
password, so a step after it would wait, then meet a password it did not mint.

Verified locally: the full Workflow guard suites step, 698 passed.

* Let the replay model a slow request

The harness could not express the case the suppressors are blindest to. Both of
them key on the status code and neither reads how long the request took, so a
200 that took a minute is indistinguishable from a 200 that took a millisecond
-- and _app_returning sent its response without touching the clock, so every
replayed request cost zero virtual time. A budget cannot bound what its harness
cannot express.

Request grows a duration_ms, defaulting to 0 so every existing scenario is
unchanged, and the poll loop now reads the clock instead of its own counter so
time spent inside a slow handler counts against the session rather than
extending it. Idle stays at 1110 and busy at 239, measured, and all 93 tests
pass.

The two new tests assert TODAY's behaviour, not the desired behaviour: a slow
success on a quiet-success path still writes nothing. The gap is worth closing,
but a guard that tolerated either answer would let an exemption be added and
then removed again unnoticed, so closing it should flip these deliberately and
budget the new volume. Measured, an unbounded exemption emits one line per
request on a sustained degradation, which is the growth these budgets exist to
stop; it needs a heartbeat of its own.

The third test guards the other two. If duration_ms ever stopped reaching the
middleware, every "slow" assertion here would silently be testing a fast
request. Verified by breaking the advance on purpose: that test, and only that
test, goes red.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen added a commit that referenced this pull request Aug 31, 2026
…10040)

* Stop the GGUF header and the chat detail polls from filling the log

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.

* Tighten the comments on the log noise changes

---------

Co-authored-by: danielhanchen <[email protected]>
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