Repository navigation
Studio: say why a generation or a model load failed, and offer the log - #8804
Conversation
Three complaints from the same report, all of the shape 'it failed and I have no idea why'. Settings > Logs gave people somewhere to look; nothing pointed at it, and two of the three surfaces had thrown the reason away before it got that far. Video threw it away. core/inference/video.py logged the exception and then overwrote str(exc) with a bare literal, so the transport carried a constant. It now classifies, reusing the OOM and math-SDPA detection #8233 already does for the log: an OOM under native SDPA names the quadratic score matrix and says to lower resolution or frames, a plain OOM says what to reduce, a native crash points at the log. Fixed text only, never the engine's own message, matching the image classifier's rule about paths and argv. The synchronous 500 uses the same classifier, so which handler caught a failure no longer changes what the user is told. Image generation had two branches that skipped its classifier and answered the bare fallback, so an OOM named its cause or not depending on which class torch raised. Both route through it now, and the generate-progress model gains the error field its load twin already had. The GGUF load path was the opposite problem: the backend already sends a summary, the llama-server tail and the log's path, and it arrived intact. It was rendered as an 8 second toast title with no white-space rule, so every newline collapsed and a structured diagnostic read as a wall of prose. Summary as the title, the rest as the description, and pre-wrap so the structure survives. All three now offer View logs, which opens the pane on the family that failed: llama-server for a load, server for a generation. By family rather than source id, since an id is a digest of a path the frontend cannot compute, and at the moment of failure the newest file in the family is the attempt that just failed.
video.py takes main's rewritten begin_generate and keeps the per-run reset of the resolved shape inside the lock that reserves the job. The worker's failure path records the classified reason and reports the same one to the client, rather than the outcome keeping the bare fallback. routes/video.py classifies at main's relocated handler inside the auto-switch retry loop; the handler the branch had added ahead of it is gone from that position on main. routes/inference.py keeps main's _generate_failure_detail and extends it to both bare-Exception arms. The settings store carries logFamilyRequested through requestsFor, the sibling openers and closeDialog, so a pending View-logs request has the same lifetime as the archive and connection ones. openLogs adopts focusForOpen. The Logs tab keeps main's log-root read. test_video_routes uses main's _shared_setup_4 helper. debug-log-export gains a stub for the store the tab now imports.
The action and the logFamilyRequested request had no test on any of the three surfaces that raise them. The only test loading the Logs tab is stubbed to the no-request branch, so it could neither exercise nor detect any of it. Asserts the action's label comes from the shipped catalogue, that a load failure asks for llama-server and a generation for server, and the request's lifetime: consumed by the panel, kept across a navigation landing back on Logs, dropped by any other tab, by closeDialog, and by each sibling opener. Removing the requestsFor entry fails the lifetime case 5 pass / 1 fail, so that one is a real control rather than a restatement.
Two review items on the View logs action. This hook loads GGUF diffusion models as well, and llama_cpp.py writes their runner output under logs/diffusion-server, which utils/debug_log_sources.py names as its own family. A fixed llama-server therefore opened an unrelated LLM log for exactly the loads whose diagnostic the action exists to surface. The family is now chosen from the resolved target and diffusion-server joins FailureLogFamily. Family recency also picks the wrong file after a rolled-back switch. performLoad reloads the previous model before rethrowing, and that rollback writes a newer log in the same family, so the newest one is the attempt that SUCCEEDED. llama_cpp.py already appends "Full log: <path>" to the message it raises, so the action now carries that path and the tab prefers the source whose realpath matches, falling back to family recency when a diagnostic has no path in it. The path rides with the family and is dropped with it, so a later visit cannot land on a stale file. npm test 8175 pass, typecheck clean, i18n:check:strict parity.
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. |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…ures to the server log Two ways View logs still opened the wrong file. Only a GGUF load goes through a runner that writes its own file per attempt. A Transformers or MLX load reaches the same catch in performLoad, and its reason is in the backend's current server log, but the family was picked from isDiffusion alone so those answered llama-server: on a host with any older GGUF attempt that opens an unrelated runner log, which reads as the reason and is not. The decision moves into loadFailureLogFamily(isGguf, isDiffusion). The exact-path match compared strings across a boundary where the two sides spell paths differently. _swa_cache_path() builds Path(home) raw, so with a relative or unexpanded UNSLOTH_STUDIO_HOME the runner reports a relative path or one with a literal ~ component while list_sources() reports an os.path.realpath. Equality missed and the viewer fell back to family recency, which after a rolled-back load is the newer log of the attempt that succeeded, the confusion carrying the path was meant to prevent. So match it where both spellings are known. debug_log_sources gains source_id_for_path, which canonicalises through the existing _identity (the Windows extended-length-prefix and case quirks it already documents) and tries both the raw and the expanded spelling, the way _scan_roots does. The sources route takes an optional diagnostic_path and answers matched_source_id, always an id already in its own allowlist, and the tab selects by that id. Additive and optional: a caller sending no path, or an older client, is unaffected.
Settings > Logs is owner-only and resolveSettingsTab sends a managed account asking for it to General, while /debug/logs/sources is owner-guarded as well. A non-owner can still run an image or video generation, or a model load, so the unconditional action opened Settings on an unrelated tab and read as a broken link rather than as a route to the reason. viewLogsAction now returns undefined for a non-owner. Every call site already passes the result straight through as sonner's action, where undefined renders nothing, so no button beats a dead one. Ownership comes from a new non-hook isAccountOwner(), since two of the call sites raise their toast from a callback outside a component body; useIsAccountOwner now reads through it.
performLoad's catch also sees PREFLIGHT failures: a rejected staged-metadata read, a cancelled HF token prompt. Those reach it before the load request goes out, so no runner was started and no file of its own exists, but the family was chosen from the artifact type alone and answered llama-server or diffusion-server. View logs then opened the newest unrelated prior attempt on the host, which reads as the reason for this failure and is not. loadFailureLogFamily takes runnerAttempted, set where the load request is issued, and falls back to the server log without it. Same question as isGguf in time rather than in kind: a GGUF load that dies in preflight has no runner log either.
loadModel prepares the HF token itself and only then sends the request, so a flag set before the call was already true when that preparation prompted and was cancelled. A local or native GGUF pick skips the outer preparation, which is exactly where the inner one can prompt, and the failure then offered the newest unrelated runner log for an attempt that never happened. loadModel already has an onRequestStart callback, fired after the token and after the abort check and immediately before the POST, for the same reason the load notice uses it. Set the flag there. tests/load-request-start-boundary.test.ts drives the real module and pins that ordering as a contract: announced between the token and the request, and never announced at all for a cancelled prompt or an abort landing during it.
authFetch's account-transition gate refuses locally, with no request going out, and loadModel announced the send before calling it, so a failed load offered the server log for a request the backend never saw. authFetch takes an onRequestStart option now and fires it immediately before the transport, and loadModel hands its caller's callback through. Both callers gain the stricter guarantee, chat's log decision and Audio's requestStarted cancel, and the ordering they relied on is unchanged: after the token prompt, before the POST.
The route retries a DiffusionModelReplacedError once, so the first raise is not an outcome. The engine had already published the reason on both channels, and an unscoped progress poll has no attempt id to be marked live by, so an Images page opened during the queued retry read a terminal failure for a run that was about to start again. Both records are dropped before the retry lap, which records its own outcome; the second replacement keeps its 409.
| if not isinstance(raw, str) or not raw.strip(): | ||
| return None | ||
| wanted = set() | ||
| for spelling in (Path(raw.strip()), Path(raw.strip()).expanduser()): |
…eration as pending A reloaded page loses its attempt id and polls without one. While its request waits for the generation slot the engine still holds the previous run's failure, so the page toasted that stale reason and stopped polling. Also scope the wiring test to the whole route body.
…sist failure like /images/generate The video classifier missed the runner's own 'sd-cli exited <code>' diagnostic, so a native video crash still read as the bare fallback. The OpenAI images route wrote its persist failure into the unscoped slot of whichever engine was active, over a later execution's reason.
Keep the video failure classifier, the image routes' two unclassified branches, the multi-line load diagnostic as title plus description, and View logs opening the exact log the diagnostic names. Drop the per-attempt failure retention for lost POSTs (main's settleLostGeneration already recovers the result), the request-start plumbing, and the tests that only covered them.
… route already has Opening Logs from a failure toast walked every log directory a second time (about 9 ms more per request on 500 files, a 50% rise); the route now hands its own listing over.
A 404 recovery reselect that finished after a View logs fetch replaced the exact failure log with the default one.
|
Codex Review: Didn't find any major issues. Breezy! 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". |
A stale sources response now bails before touching any state, a repeated identical View logs click carries its own sequence so a mounted Logs tab refetches, and a failed video save offers its log like a failed image save.
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
Follow-up to #8690. That PR gave people somewhere to look; this one points at it, and stops two surfaces throwing the reason away first.
From the same report:
Video threw the reason away
core/inference/video.pylogged the exception and then replaced it with the constant"Video generation failed.". It now classifies, with fixed text only (never the engine's own message, which can carry local paths and argv):sd-cli exited,ggml_abort, signal, lost connection)The synchronous 500 in
routes/video.pyuses the same classifier.Image generation had two branches that skipped its classifier
/images/generateand/v1/images/generationsnamed the bare fallback for any non-RuntimeError, so the same OOM named its cause or not depending on which class torch raised. Both go through_generate_failure_detailnow.The GGUF load diagnostic was one run-on line
The backend already builds a real diagnostic (summary, llama-server tail,
Full log: <path>), but it was the title of a toast with nowhite-spacerule, so every newline collapsed. Summary is now the title, the rest the description, withpre-wrapon both.View logs
diagnostic_pathon the sources route, canonicalised through the module's_identity), since the runner prints whatever spellingUNSLOTH_STUDIO_HOMEhad while the listing reports a realpath. By exact file rather than newest-in-family: a failed switch rolls back, and the rollback writes a newer log of a load that succeeded.serverfamily. Client-input refusals, which carry their own text and are never logged, offer nothing.Not in this PR
sd.cpp drains its renderer output into an in-memory deque at
logger.debug, so after a native image failure the server log holds the classified error and traceback but not the renderer's own output. That is a logging change, and the prerequisite for #8666 being diagnosable from the UI.Verification
test_debug_log_sources.py,test_video_routes.py,test_openai_images_generations_route.py,test_diffusion_routes.py,test_video_backend.py: 711 passed. New cases: OOM and native crash classification (includingsd-cli exited -6/3221225477with an assertion-only tail), unclassified failure keeping the bare fallback, and exact-path matching across a raw, relative and unexpanded~spelling.npm test9331 / 9332 (the one failure,tauri-backend-transport-failure, is a timing test this PR does not touch and passes 16/16 on its own),npm run typecheckclean,npm run i18n:check:strictparity across all 12 locales.Before / after
Two isolated installs, the merge base (949b94a) and this branch (5b423b9), driven through the same scene: a 69-byte GGUF that parses and cannot run is planted in a scan folder and picked from the chat picker's On Device tab. Both sides reach the same real
llama-serverrefusal,key not found in model: llama.context_length.Read from the DOM of the same servers photographed:
white-spacenormal(newlines collapsed)pre-wrapView logsFull log: <path>