Repository navigation
Studio: clearer audio.cpp errors, cleaner Speak/Clone, reproducible takes - #14075
danielhanchen merged 24 commits into
Conversation
…le takes
- audio_cpp_failures.py classifies audio.cpp failures (runtime missing, family
unknown to the runtime, out of memory, GPU unavailable, eSpeak missing,
incomplete file) from the upstream messages and returns a structured
{code, message} detail with a 4xx/503 status instead of the generic 500.
Out of memory lists smaller variants with a memory estimate and names expert
offload options when the runtime spec declares them. A GPU that cannot start
falls back to the CPU once. The update banner can install a missing runtime.
- The audio pages map each code to an existing control: the runtime update,
the CPU RAM device choice, a smaller variant, or the model selector.
- Options the loaded model does not take are dropped and returned as
ignored_options, shown with a warning toast.
- Speak and Clone: one voice picker, no "Alias of"/JSON rows, the description
and Clone language only when the model reads them, saved voices on Speak,
the reference transcribed automatically when a model needs it and an STT
model is on disk, and a reference length hint.
- Takes: a Seed field, the seed used returned with each clip and saved in
history, "Reuse seed" in the clip menu, and sequential music takes sent one
by one so Stop keeps finished takes, with "Take i of n" status.
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. |
…takes - Out of memory offers the variant key the variant listing uses, gives CPU advice when the run was already on the CPU, and no longer offers CPU RAM there. - eSpeak is only named when the library or its data is missing. - Separate returns classified failures; the OOM retry and API monitor read them. - A CPU fallback after a restart reaches the parent. - Clone auto-transcribe waits for an idle page; music group ids work over plain HTTP. - The update banner says "audio runtime" for a first install.
When history could not keep the first sequential take, the run answered with inline audio and no clips, so later takes lost the seed and fixed-seed music models restarted from a new random base. The inline audio now carries the seed and the takes loop reads it there too. Also round-trips a capacity failure through from_payload in the tests, and trims per-line source citations (the strings grep at v0.9.2) to stay within the size cap.
A runtime 4xx 'does not fit in device memory' on a CPU run kept the GPU-side advice and no device extra, so the page offered Load into CPU RAM, which fails the same way. It now says to shorten the input and marks the failure as already on the CPU.
…e phase The installer can exit 0 without installing anything when the release lookup cannot answer. That case only changed the message, so the update job reported success and the page said the runtime was updated. It now fails the phase, so the action stays retryable.
|
Review fixes are in. The head is now What changed since the first round
UI evidenceAll scenes were captured on a CPU-only Unsloth Studio with the real backend and Chromium at 1280x800. Base is 1. A runtime that runs out of memory on a CPU run, at load and during Generate. Before: a 500 with raw runtime text, and "Choose a different model". After: a named out-of-memory message with RAM advice for a CPU run. It does not offer to retry on the CPU. 2. Speak with Kokoro. There is one voice picker, the description box Kokoro ignores is gone, and Seed is under Advanced. 3. Clone with a model that needs the reference transcript. The uploaded reference is transcribed automatically with the STT model already on disk. 4. Reuse seed. The clip menu gains "Reuse seed", which fills the Seed field. With Kokoro, seeds 1, 2 and then 1 again gave audio hashes Tests at this head
|
…o too A Speak or Clone run that history could not keep returned inline audio without the seed it used, and Stable Audio left a blank seed to the runtime, so neither take could be reproduced. The inline audio now carries the run's seed, and a blank seed is filled for every music family (one seed still varies a batch). The fixed_seed flag had no other use and is gone. Trims a few test comments to stay within the size cap.
Clicking Load into CPU RAM while the failed load was still settling queued the retry without its device override, so the replay depended on the device choice having re-rendered. The queue now carries it.
The Speak load test pins the queued pick's fields, which now include deviceOverride.
…ts a first install - A Separate run's worker reply now carries the runtime fields, so a restart that fell back to the CPU reaches the model info. - take and group_id are accepted only together. - A first audio runtime install probes the installer's own accelerator pick; a macOS release publishes Metal bundles only, so the CPU probe never offered it there. Shortens a few test fixture strings to verbatim prefixes to stay within the size cap.
|
@codex review |
|
@codex security review |
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
…Clone page [skip ci]
… top-level language
…ure, not a failed load
…e load sequence stays together [skip ci]
…cks takes and cancels by id (#14080) Includes #14075 (Studio: clearer audio.cpp errors, cleaner Speak/Clone, reproducible takes); review the non-merge commits from 14e6b65 to HEAD (skipping #14075's own fix commits that came in by merge), or `git diff dfa58e0..HEAD` against #14075's head. ## Summary An agent using Unsloth Studio over MCP could not tell when a music duration was clamped or an option was dropped, got bare error text from audio.cpp failures, had no way to check a finished take, and could not stop an audio run (`cancel` said "Audio runs cannot be cancelled"). This adds those four things to the audio routes and the MCP tools. ## Changes Audio routes: - `/audio/run` answers with `applied` (the music `duration_s` actually used) and `warnings` (`"duration_s 600 clamped to 240"`, plus one `Ignored option <name>` line per entry in `ignored_options`). Clip rows carry `voice_id` and `source_clip_id`, and Separate stem rows carry `source_clip_id`. - `/audio/run` takes an optional `cancel_id`. `POST /audio/cancel {"cancel_id": ...}` stops that run the way a client disconnect does: it answers 499 and saves nothing. The key is namespaced as `("audio", id)`, so a chat `cancel_id` cannot stop an audio run. The run registers its id before any model switch, so a cancel sent while a cold model is still loading stops the run once the load ends, before anything is generated. A cancel that arrives while the clips are being saved removes the clips the run made, including an Edit source recording it saved (one an earlier run kept, or one another Edit now plays, stays; an Edit's source handoff and this cleanup share a lock), and still answers 499. A second run under a `cancel_id` that a running audio run holds gets 409, so one cancel never stops two runs. A cancel that arrives before the run starts is kept for 30 s. - New `POST /audio/analyze` measures an upload, history clip or saved voice: duration, integrated loudness (BS.1770-4, gated), true peak (4x oversampled), clipped samples (runs of 3+ identical samples at full scale that the waveform lands on or leaves more steeply than a smooth peak could: PCM rounds a clean peak to a flat top of L samples that it leaves by at most about ((L + 1) / (L - 1))² quantization steps, so the limit is twice that, using the WAV's own sample width (for 32-bit PCM the float32 spacing near full scale, 2^-24). Clean 16-bit tones from 1 Hz to 2 kHz at 0.99-1.0 of full scale count 0 (400 random tones), and a 2% overdrive counts from 10 Hz to 1 kHz, in 8-bit too, where a clean tone within 1% of full scale also reads as clipped because 8-bit is too coarse to tell the two apart) and the span that holds sound (a final partial 20 ms frame counts, so a 6 ms beep has a span). With `expected_text` it transcribes with the resident speech-to-text model (or the default) and returns `match_score`, 1 minus the word error rate, or null when the two texts are too long to align (over 50 million word pairs, about a quarter second of numpy work). Nothing is saved. Clips over 10 minutes get 413. The measurements are in `core/inference/audio_metrics.py`, which uses numpy only and walks the audio in chunks: a 10-minute 48 kHz stereo clip needs about 21 MiB of working memory on top of the decoded audio, and clipping runs are judged per chunk, so even audio at full scale every other sample stays at a few MiB. Transcript scoring runs off the event loop. - An audio.cpp runtime that dies or goes silent mid-request on generate, separate or music now raises a 500 with code `runtime_stopped` and the message "The audio runtime stopped: <reason>. Try again; if it fails again, load the model again." Paths and tokens are removed from the reason. A failure that #14075 already classified (out of memory and so on) is re-raised unchanged. MCP tools: - `generate_audio` returns `applied`, `warnings`, `ignored_options` and `cancel_id`. It accepts a `cancel_id` and makes one (`mcp-<hex>`) when omitted. A reused id that is still running or was cancelled in the last 30 s is refused. - When the loaded music model makes variations one at a time (`variations.how == "sequential"` in status), `generate_audio` sends them take by take under one `group_id`, reusing take 1's seed, as the Audio page does. A cancel between takes stops before the next POST and keeps the finished takes. A take that fails after earlier takes succeeded becomes a warning instead of losing the finished clips. - `cancel(kind="audio", id=<cancel_id>)` stops a run: between takes it stops locally, otherwise it posts to `/api/inference/audio/cancel`. - Audio route failures with a known code now start with a `[code]` tag and end with what to do next, from `AUDIO_HINTS` in `studio_mcp/errors.py`. For example `[out_of_memory]` suggests `device='cpu'` and lists the smaller variants when the error body carries them (the `/v1` error envelope that `generate_audio` reads keeps only the code, so there the hint stays generic), and `[runtime_stopped]` says to retry once and then reload the model. - `transcribe` gains `speakers` (labels each segment's speaker; it needs a diarizing model and always uses the stored-audio route) and `expected_text` (adds `match_score`). - New `analyze_audio` tool wraps `/audio/analyze`. It is not marked read-only, because inline audio or a path is uploaded to Unsloth Studio first. If the speech-to-text model is not downloaded, the 409 hint says to run `transcribe` once or leave out `expected_text`. - `studio_status` lists the active music model's `duration_s` min, max and default per mode as `audio_music`, so an agent can see the clamp range before it asks for a duration. - `studio/MCP.md` documents `analyze_audio` and the new `transcribe` arguments. Its `cancel` row and the "Audio runs cannot be cancelled" sentence are left alone here: #14081 rewrites that row into a kind-agnostic form and #14089 removes the sentence, and those PRs own those lines. The audio kind is documented in the `cancel` tool's own docstring. One small edit lands on #14075's code (the only edit outside this PR's own files, in its own commit): - d46103b: `_CODES` in `audio_cpp_failures.py` gains `runtime_stopped`, so the worker and orchestrator keep that code when they rebuild a failure. ## Testing New tests: - `tests/test_audio_metrics.py`: a -20 dBFS 1 kHz sine measures -23.0 LUFS and -20.0 dBTP within 0.05; hard clipping is detected and clean full-scale 10 Hz, 100 Hz and 1 kHz sines are not, also as 16-bit WAVs at 10 Hz and 40 Hz and at 50 Hz and 0.999 of full scale, while a 10% overdriven 10 Hz WAV is, and so is an overdriven 100 Hz 8-bit WAV; 8-bit clipping counts on both rails; small chunk sizes give exactly the one-pass numbers; padded silence gives the expected span; silence gives `None`; cross-checks against pyloudnorm and jiwer when installed. - `tests/test_audio_analyze_route.py`: metrics, `match_score` with a stubbed transcriber, the speech-to-text 409, non-WAV input through transcode, on both mounts. - `tests/test_audio_edit_route.py`: a cancel during the save removes the source recording the run saved (with or without a kept output) and keeps one an earlier run saved or another Edit now plays. - `tests/test_audio_run_cancel.py`: two concurrent runs with ids A and B; cancelling A gives A 499 and B 200; a chat `/cancel` with id A stops nothing; a cancel sent during a slow model load gives 499 and never starts generation; a cancel sent while the clip saves gives 499 and removes the saved clip; a second run under a live `cancel_id` gets 409. - `tests/test_audio_run_extras.py`: `applied`, clamp and ignored-option warnings, `voice_id` and `source_clip_id` on clip rows. - `tests/test_audio_runtime_stopped.py`: generate, separate and music map a mid-request stop to `runtime_stopped` with no path or token in the message; an attached `out_of_memory` passes through unchanged; the code survives the worker, orchestrator, route and `/v1` envelope. - `tests/test_mcp_audio_takes.py`, `tests/test_mcp_audio_reports.py`, `tests/test_mcp_audio_hints.py`: take-by-take runs and cancel during and between takes, reused id refusal, batch mode as one request, reported fields, and `[code]` hints. Existing MCP contract tests (`test_mcp_server.py`, `test_mcp_tool_contract.py`, `test_mcp_no_host_paths.py`, `test_mcp_tools_audio.py`, `test_mcp_tools_status.py`) are updated for the new tool, the `audio` cancel kind and the new output fields. Results on c7d6ade (Linux, CPU): - Every test file this PR touches (25 files, including `test_audio_run_route.py` and `test_audio_edit_route.py`) plus `test_audio_edit_requests.py` and `test_audio_gallery.py`: 1035 passed. - On 2e46efe, all `tests/test_mcp_*.py`: 1475 passed, 3 skipped, 3 failed. The 3 failures are in `test_mcp_images.py` and fail the same way on #14075's head (a transformers / huggingface-hub version mismatch in the test venv). - A live check on an earlier head: with a dead audio runtime injected on the first request, a fresh agent driving the MCP tools got `[runtime_stopped]`, retried once as the hint says, and got its clip. - Negative controls: without the new except branches the three runtime_stopped cases raise the bare runtime error; with `runtime_stopped` removed from `_CODES` the orchestrator drops the code; without the namespaced cancel key `/audio/cancel` stops nothing and a chat `/cancel` would stop the audio run; without the run-length rule a 2-sample burst counts as clipping; with the cancel registered only after the model switch (the previous code), the slow-load cancel test times out because the run goes on to generate; without the after-save check the save-time cancel answers 200 and keeps the clip. The first commit (14e6b65) is the shared one-name-per-line reshape of `test_mcp_server.py`, byte-identical to the same commit in the sibling MCP PRs, so their tool-name additions merge cleanly. ```bash cd studio/backend python -m pytest tests/test_audio_metrics.py tests/test_audio_analyze_route.py tests/test_audio_run_cancel.py tests/test_audio_run_extras.py tests/test_audio_runtime_stopped.py tests/test_mcp_audio_takes.py tests/test_mcp_audio_reports.py tests/test_mcp_audio_hints.py tests/test_mcp_server.py tests/test_mcp_tool_contract.py tests/test_mcp_no_host_paths.py tests/test_mcp_tools_audio.py tests/test_mcp_tools_status.py -q ``` --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
…14106) Includes #14088; review the last 10 commits (21c5b4c..HEAD). The own commits are 21c5b4c, 53691de, dd7f1ea, 42f9da9, 7c33268, 4bbf7ee (formatting only), c0044d3, ec93a37, dc903fe and 5932e71. The merge commits only bring in #14088. ## Summary With Keep multiple models loaded set to When they fit or Always, loading an image or video model no longer unloads the chat model when both fit on the GPU. Before this, every image or video load evicted chat regardless of the setting. The new `core/inference/gpu_residency.py` prices an image or video load from the checkpoint files already on disk (weights plus generation headroom) and compares it with live free VRAM per physical GPU, with a 1 GiB margin. An image load must also keep its transformer resident under the diffusion planner, so "fits" never means streaming weights. When the load fits, nothing is unloaded. When it does not: - When they fit unloads the cheapest residents on the same GPUs first and re-checks after each one. If it is still short, it unloads the rest on those GPUs, as Off does. - Always refuses the load and names the models that would have to go. - Residents on other GPUs are never touched. Chat loads pass the GPUs they target, and an image or video load passes its GPU even when it can't be priced. An idle H3 video server next to a video model on other GPUs stays too. - A resident image or video model that is still loading counts at its full price, since its weights are not in live free VRAM yet. A failed load's price stops counting once nothing is loaded or loading. - When freeing room for a primary chat load, anything freed (an idle video server counts) earns a retry at full size. The replace fallback, which has no retry after it, never refuses a partial fit. The chat side changes too: - GGUF launches add `media_held_mib()` (what resident image and video models hold) to the VRAM already planned by other servers, so llama-server sizes itself around them. - A primary chat load that only partially fits beside an image or video model refuses the partial fit. When they fit then frees the image or video model and retries. Always only accepts a smaller context, otherwise it refuses. - Under Always, a chat load that runs out of memory beside an image or video model is refused instead of retried. - An image or video load that arrives while a chat load on unknown GPUs is in flight gets a retryable 409 under Always, since the chat model's size is not known until it launches. When they fit unloads chat as before. A CPU chat load, or one on known GPUs, is left to the per-GPU check. - Under Always, refusals name only the image or video models on the GPUs that are short. - A chat load whose GPU start fell back to the CPU releases its GPU claim, so it does not evict image or video models for nothing. Evictions made by the co-residency path are reported through the arbiter's eviction sink, the same way #14088 reports other unloads. There is no UI change. ## Upgrade behaviour change #14088 migrates installs that had the old chat-only Keep multiple models loaded switch turned on to When they fit. With this PR on top, those installs see a behaviour change with no extra opt-in: image and video loads stop evicting chat whenever the fit check passes, and chat GGUF launches count `media_held_mib` when sizing. Installs on Off behave as before, apart from the CPU-fallback release noted below. Release note: Unsloth Studio can keep an image or video model loaded beside a chat model when Keep multiple models loaded is set to When they fit or Always and both fit in GPU memory. ## Known limits - Macs, unified-memory hosts and hosts with UUID or MIG masked GPUs cannot be priced, so co-residency is denied there and the load behaves as under Off (When they fit) or is refused (Always). - sd.cpp on GPU, MLX and H3 video loads have no price yet. They evict what shares their GPU first under When they fit, and are refused under Always when anything does. - The route-level `require_no_foreign_generations()` check in the media routes still refuses globally. That is outside this PR. - The CPU-fallback release only acts once the audio.cpp PR (#14075) records `audio_device_fallback`. It runs under Off too, so a primary that fell back to the CPU no longer holds the GPU claim there either. - The GPUs recorded for chat only grow while any chat model stays loaded. Unloading one kept chat model does not shrink them, so a later load on that GPU behaves as under #14088 there. - A failed image or video replacement that keeps the old model keeps the new model's price until the next load. ## Testing New and extended tests: - `studio/backend/tests/test_gpu_arbiter.py` - `studio/backend/tests/test_gpu_residency_coexistence.py` - `studio/backend/tests/test_gpu_arbitration_sim.py` - `studio/backend/tests/test_audio_cpu_fallback_claim.py` - `studio/backend/tests/test_multi_model_primary_fit.py` - `studio/backend/tests/test_media_auto_switch.py` ```bash cd studio/backend python -m pytest tests/test_gpu_arbiter.py tests/test_gpu_residency_coexistence.py tests/test_gpu_arbitration_sim.py tests/test_audio_cpu_fallback_claim.py tests/test_multi_model_primary_fit.py tests/test_media_auto_switch.py -q ``` On head 5932e71: 505 tests pass in the focused set (the files above plus #14088's multi-model, arbiter, MCP status and owner-mode tests), and `tests/test_media_auto_switch.py` passes on its own (111 passed, 1 skipped). The 49 other backend test files that touch the arbiter pass too (3,373 passed), except `test_account_deactivated_account_fences.py::test_owner_run_cannot_take_a_deactivated_accounts_supervisor_slot`, which fails the same way on #14088's head. GPU check on head 5932e71, on one B200 (GPU 7), through the Unsloth Studio API: - Under When they fit, `unsloth/Qwen3-8B-GGUF` Q4_K_M and `unsloth/Z-Image-Turbo-GGUF` Q4_K_M were both resident with `evicted=[]`, in both load orders (chat then image, image then chat). An image generation and a chat completion then both returned 200, with the two models holding about 6.6 GB and 14.6 GB. The same check also passed on 4bbf7ee and dc903fe. - Under Off, the image load unloaded the chat model and reported it: `evicted=['unsloth/Qwen3-8B-GGUF']`, `evicted_slots=[{'kind': 'chat', 'model': 'unsloth/Qwen3-8B-GGUF'}]`. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Etherl <[email protected]> Co-authored-by: Daniel Han <[email protected]>
… the chat context when an image or video model takes the GPU (#14108) Includes #14088 and #14106; review the last 7 commits (2fc1ef2..HEAD). The own commits are 2fc1ef2, e9c75e1, 0372bd3, da5685f, ab3ffac, 38b83a8 and 39c691f, plus one pre-commit.ci format fix (1b49896). The merge commits only bring in #14088 and #14106, so `git diff 4bbf7ee HEAD` shows only this PR. ## Summary Settings › Resources › Model memory now has a "Keep multiple models loaded" Select with three values: Off, When they fit and Always. The description under it changes with the selected value. The image/video idle auto-unload row moved from API keys into the same Model memory section. Both rows show up in settings search, and a new `resources-model-memory` deep link opens the dialog on that section. Saving the moved row through `PUT /api/settings/openai-auto-switch` no longer needs `enabled`. The field is optional now, so a save from Model memory can't resend a stale value. On the Images and Video pages, the "Model loaded" toast now names the models the load unloaded. Chat shows the same eviction notice. A load refused under Always shows a "Model not loaded" toast with the backend's sentence, plus an "Open settings" action for the account owner only. Unsloth Studio recognises a refusal by the `X-Unsloth-Refusal` header first, then by the headers in a padded `_deferred_error` body, then by the backend wording. When an image or video load is about to evict a GGUF chat model, Unsloth Studio saves the chat KV first: - The save runs outside every lock and is capped at 45 s. While it runs, load-progress reports the phase `saving_chat_context`. - The saved stash is promoted only when the chat model is actually evicted. If the load ends up not evicting chat, the pending save is dropped, and a save that finishes after the 45 s cap has its files deleted. - The stash is tagged with its origin, so saving the media idle TTL no longer purges it. Turning "Keep chat context across unloads" off still does. - Loading the same chat model again restores the saved KV, so the conversation does not have to be re-read. - The save runs only when the load will really unload chat. Under When they fit, chat on other GPUs stays and an idle image or video model on the same GPUs is unloaded first, the same order the residency code uses. The peek counts that as making room only with the 1 GB fit margin to spare, and a chat model still loading on those GPUs counts as unloaded. A save is dropped if "Keep chat context across unloads" is turned off while it runs. - A client that disconnects mid-load no longer drops the save: the routes close it only once the acquire thread is done, so a late eviction still keeps it. - A `/v1/images/generations` or `/v1/videos` call that loads its model through the auto-switch also saves the chat KV. Before, the call counted itself as chat work and skipped the save. The "Keep chat context across unloads" row on API keys is now always shown, with new copy. ## How it fits R1/R2 This PR reads R1's stored mode and its K2/K4 rules, and R2's `can_load_alongside` plus the fit keywords the media acquire uses. The pre-swap check `would_evict` asks the same question `acquire_for` will: under Always it never evicts (the load is refused instead), and under When they fit a priced load that fits alongside chat does not trigger a save. Under When they fit the model lifecycle row for the eviction is R2's "evicted" row. Under Off this PR writes the "swap" row. ## Testing Frontend: - Full node suite: 12,547 pass. Three files (`anthropic-dated-model-ids-reach-the-picker`, `custom-provider-api-type`, `llama-cpp-auto-reload`) hit the load timeout in the full run and pass when run alone. None of them is touched here. - `typecheck` and `i18n:check:strict` pass on the merged head, and the 80 tests in the files below pass there. - New tests: `model-memory-multi-model-mode.test.ts`, `images-evicted-toast.test.ts`, `load-refusal-header.test.ts`, `media-saving-chat-context.test.ts`. Extended: `settings-search.test.ts`, `media-auto-switch-setting.test.ts`, `media-idle-unload-api-only.test.ts`, `media-load-cancel.test.ts`, `tests/studio/playwright_settings_tabs.py`. Backend: - New tests: `test_swap_kv_resume.py` and `test_auto_switch_partial_save.py` (85 pass). The tests for the When they fit order, the `/v1` save, keep KV turned off mid-save and the Off peek fail on the code before ab3ffac and 38b83a8. - On the merged #14088 + #14106 head, the swap, arbiter, co-residency, Always and auto-switch suites give 1,415 passed (547 on the targeted rerun after ab3ffac). Two fail: `test_a_model_type_without_architectures_is_not_switchable` needs huggingface-hub < 1.0 (it fails the same way on main), and `test_setup_keeps_the_gate_and_lock_after_the_caller_gives_up` is a timing test that passes 3/3 on its own. Neither file is touched here. Real GPU run with Qwen3-1.7B-GGUF Q4_K_M (chat) and Z-Image-Turbo-GGUF Q4_K_M (image), keep KV on, Keep multiple models loaded set to Off: - The chat reached 5015 prompt tokens. - Image load: POST took 1.50 s, and `saving_chat_context` showed for about 0.22 s. - Reloading the chat model plus one new turn (5052 tokens) evaluated 37 tokens. With keep KV off, the same reload evaluated all 5052. The Playwright settings-tabs harness passes. The GPU run and the screenshots used head 0500dbb412. Later commits change only the When they fit peek (same fit keywords as the acquire), the lifecycle row under When they fit, and tests. ## UI evidence <!-- screenshots added in a comment --> ## Follow-ups - Only the primary chat model's KV is saved. Extra chat models kept by Keep multiple models loaded are unloaded without a save, as the chat idle unload already does; saving and restoring them needs a per-slot stash. - Read `LoadModelError.headers` for the chat refusal once #14075 merges. Until then chat recognises a refusal by its wording. <!-- ui-evidence:start --> ### UI before / after BEFORE is the head of #14106 (this PR's base), AFTER is this PR, two separate installs. Settings > Resources > Model memory: "Keep multiple models loaded" changes from a switch to an Off / When they fit / Always selector, and a new "Idle auto-unload for image and video" row appears in this section.  With the setting at Always, the description follows the selected value.  The "Keep multiple models loaded" hint now covers chat, image and video models and explains GPU placement and the 1 GB margin of When they fit.  Settings > API keys > Model auto-switch: the image/video idle-unload row moved out of this section, and "Keep chat context across unloads" shows even when chat idle unload is off.  <!-- ui-evidence:end --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Etherl <[email protected]> Co-authored-by: Daniel Han <[email protected]>
…eset the startup budget to the build (#14168) ## Summary Main is over the startup bundle budget, so `Frontend build + bundle sanity` fails on every PR based on it: ``` over the startup budget: transfer 2005.9 KB > 2003.5 KB, raw 6665.4 KB > 6659.1 KB (main at 2fee36f) ``` This PR takes two steps. It moves #14137's prompt upsampler client out of the startup chunks, which is real growth with a lazy home. It then resets both limits to the measured build. Main has gone over this budget repeatedly, and the root of that is a shortfall in how the limits were raised, which this corrects. ## Cause **#14137 (FLUX.3 prompt upsampling).** The Images page is lazy (`ImagesPage = lazy(...)` in `__root.tsx`), but `features/images/api.ts` is not. Startup modules import it for other calls (`loaded-models-api.ts`, `loaded-models-sources.ts`, `use-media-companion-bytes.ts`). #14137 put the four upsampler calls there, with value imports from `lib/prompt-enhance.ts`, so that module joined the startup chunks. Only `prompt-enhance-panel.tsx`, inside the lazy Images page, calls them. **The limits themselves.** Each raise since #14073 was sized from its own PR's delta and added to the previous limit. That previous limit already sat below the build, starting at #14073: - `475a02ac` measures 2,047,700 B transfer against the 2,047,608 B limit #14073 set. - By `2fee36ff` the gap is 6,500 B raw and 2,409 B transfer. The raises since (#14072, #14075, #14110, #14108, #14113) each added their delta, so the shortfall carried forward. CI agrees with my machine to the byte: the first run of this PR read 1999.7 KB transfer on both. ## Change - **New `features/images/prompt-upsampler-api.ts`:** holds `getPromptUpsamplerStatus`, `startPromptUpsamplerDownload`, `cancelPromptUpsamplerDownload` and `previewEnhancedPrompt`, moved unchanged, with the same `parseJson` error handling. - **`api.ts`:** now imports only the `PromptEnhancement` type from `lib/prompt-enhance` (erased at build). - **`prompt-enhance-panel.tsx`:** imports the calls from the new module. - **No behavior change** in the app. - **`check-bundle-budget.ts`:** both limits are reset to the measured build plus the usual margin (160 B raw, 189 B transfer), with an entry in the BUDGET comment block explaining why the reset is absolute rather than by delta. - `rawBytes`: 6,819,206 (main after #14113) -> 6,825,885. - `transferBytes`: 2,051,727 -> 2,054,261. ## Testing One machine and build, Node 24, exact byte totals from the budget script, 95 chunks throughout: | tree | raw B | transfer B | |---|---|---| | main `2fee36ff` | 6,825,378 | 2,053,999 | | main `2fee36ff` + the move | 6,821,006 | 2,052,708 | | main `78e5eefa4d` (adds #14113) + the move | 6,821,334 | 2,052,857 | | + #14183 | 6,821,410 | 2,052,614 | | + #14172 (one tooltip design) | 6,825,307 | 2,053,990 | | this PR (main `b227654927`, adds #14184, + the move) | 6,825,725 | 2,054,072 | - **The move saves:** 4,372 B raw and 1,291 B transfer. - **#14113 adds:** 328 B raw and 149 B transfer on this build. - **Landed while main was over, with no raise:** #14183 (+76 B raw, -243 B transfer), #14172 (+3,897 B raw, +1,376 B transfer, the shared tooltip is in the eager shell) and #14184 (+418 B raw, +82 B transfer). This is the treadmill the absolute reset stops: while main is red on this check, growth lands unaccounted. - **With the new limits:** `within budget (0.2 KB transfer, 0.2 KB raw to spare)`. - **`npm run typecheck`:** clean. - **`bundle-budget-cli.test.ts`, `bundle-budget-closure.test.ts`, `image-prompt-enhance.test.ts` and `loaded-models-platform-matrix.test.ts`:** 74 passed. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…14901) The generate path drops options the request will not carry (`ignored_options`, unslothai#14075) before `filled_options` folds the audio.cpp v0.9.2 renamed option names (unslothai#14073). The option panel shows a renamed option under its legacy name and a strict v0.9.2 contract lists only the canonical name, so valid values were dropped and the defaults sent instead: - Seed-VC with a strict v0.9.2 spec: `length_adjust` or `duration_scale` 1.5 reached the runtime as `duration_scale` 1.0. - Seed-VC with an older strict spec: `duration_scale` 1.5 was dropped and `length_adjust` 1.0 sent. - Chatterbox: `flow_guidance_scale` 1.0 was dropped and `s3gen_cfg_rate` 0.7 sent. `ignored_options` now judges a renamed option under its legacy name and widens strict keys with the legacy name, matching `filled_options`. Options the model does not take are still dropped and reported. Tests: `test_generation_keeps_a_renamed_option_under_either_name` in `test_audio_cpp_option_renames.py` drives a Convert generation through the backend with a fake server for both names on Seed-VC (old and new specs) and Chatterbox, and checks that an unknown option is still reported. 4 of its 5 cases fail on main and all pass here. Across the audio test files: 2312 passed vs 2308 on main; the 6 remaining failures (`test_native_audio.py`, `soundfile` missing locally) are the same on both sides. Not run against a live audio.cpp server.




Summary
When audio.cpp fails to load or generate, Unsloth Studio now says why and offers the matching fix, instead of a generic 500 with "Choose a different model". The Speak and Clone forms drop rows the loaded model does not use. Every Speak, Clone and Music take now records the seed it used, so a take can be reproduced.
This is the third of three audio.cpp PRs built in parallel from
main. PR 1 adds audio.cpp v0.9.2 support and PR 2 routes models to the right audio pages. This one does not depend on either.Changes
Named failures
core/inference/audio_cpp_failures.pyclassifies audio.cpp output into six codes:runtime_missing,family_unknown_to_runtime,espeak_missing,gpu_unavailable,out_of_memoryandfile_incomplete. The load and generate routes returndetail: {code, message}with 422 for an incomplete file, 400 when the input or model does not fit device memory (a runtime capacity refusal, or the GPU placement check before load), and 503 for the rest. Raw runtime text is only matched against, never returned; any runtime line in a message goes throughsanitize_runtime_tail.audio_device_fallback: "cpu", the page shows a warning toast, and the model is not reloaded just because Auto is still selected.On the audio pages, each code maps to an existing control: "Update the audio runtime", "Load into CPU RAM", "Use ", or the model selector. Load failures get the same action in their toast. Unclassified errors keep "Choose a different model".
Speak and Clone
ignored_options. The page shows a warning toast naming them.voice_id/speakerrows are dropped; otherwise that row becomes the picker and keeps its own name on the wire.instruct/instruction/language. The newaudio_request_inputsfield on the model info carries that list.Seeds and takes
seedout. A blank seed picks a random one per take./audio/generateresponse,/audio/runclips and saved history settings now include the seed used. "Reuse seed" in a clip's menu puts it back in the Seed field.take,group_idonAudioRunRequest), with "Take i of n" status. Stop now keeps the takes that already finished. Later takes reuse take 1's seed and the server offsets it by take number.Behavior changes
audio_cpp_option_golden.json).previous_takesoption is hidden, since its spec describes it as JSON. It can no longer be set from the form.detailis an object withcodeandmessageinstead of a string, and the status is 4xx/503 instead of 500/501. Unclassified errors keep the old shape.variations > 1still get one request for all takes, so Stop on those still loses finished takes. Only the Unsloth Studio Music page sends takes one at a time.Testing
New backend tests:
cd studio/backend python -m pytest tests/test_audio_cpp_failures.py tests/test_audio_cpp_failure_routes.py tests/test_audio_cpp_models.py tests/test_audio_cpp_server_http.py tests/test_audio_cpp_update.py tests/test_audio_run_route.py tests/test_audio_cpp_music_requests.py tests/test_audio_cpp_clone_requests.py tests/test_audio_device_guards.py tests/test_pr7699_worker_audio_mirror.py tests/test_gguf_load_cache_reuse.py -qNew frontend tests:
cd studio/frontend node --experimental-strip-types --test tests/audio-api-error.test.ts tests/audio-failure-actions.test.ts tests/audio-music-takes.test.ts tests/audio-seed-reuse.test.ts tests/audio-clone-auto-transcribe.test.ts tests/audio-clone-panels.test.ts tests/audio-request-inputs.test.ts tests/update-banner-flex-priority.test.tsResults at this head (CPU, local):
test_audio_cpp_*.py,test_audio_runtime_errors.py,test_audio_voices.py,test_audio_tts_cancellation.py,test_combined_update.py,test_mcp_tools_audio.pyandtest_openai_audio_speech_route.py: 1400 passed, 7 skipped. A wider run oftests/test_audio_*.pyplus the MCP, multi-model and tunnel suites showed only failures that also fail onmainin this environment (test_audio_eval_dataset.pyandtest_audio_type_inconclusive.py, from a huggingface-hub version mismatch).tests/*audio*.test.tsplus the update-banner and llama-update tests: 686 passed.npm run typecheckpasses, and so doesnpm run build.UI before / after
With no audio runtime installed, the update card now offers a first install: title "Install the audio runtime", version line "Install the audio runtime v0.9.2-unsloth.1", no "from ->" arrow. Before this PR no audio card appeared at all. BEFORE is the merge base, AFTER is this PR, two separate installs, each with its audio.cpp folder moved aside so both report no runtime.