Repository navigation
Studio: audio.cpp models land on the right pages - #14072
Conversation
A model family that Unsloth Studio's tables don't list now lands on every Audio page its runtime spec allows, not just the first task: a spec with tts and clone shows on Text to Speech and Clone (fish_drama3, kitten_tts2), sep on Separate, asr on Transcribe, music/sfx on Music with a conservative music setup. Voice conversion stays limited to the families Unsloth Studio already configures. mira_tts and sopro_tts are Clone only, since they need a reference on every run. The default variant follows the spec's recommended_package, and K/IQ quants rank after the established order. GET /api/inference/audio/catalog lists every umbrella folder (300 s TTL, saved last-good listing, HF-cache fallback) plus Community repos named by the runtime's model specs. The Audio pages use one pageModels() resolver and show a "More models" group in the existing picker, with the pages, languages and status in the row tooltip and the size in the size column. The nightly catalog check warns on a new folder instead of failing. MCP: list_models takes a workflow filter, generate_audio takes model, and the switch guard names the pages a model runs on.
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. |
- A catalog entry the backend could not place no longer hides a model the bundled seed already knows, so a degraded catalog (no runtime specs, late header probes) leaves every page as it was. - A build whose family probe missed the deadline is cached for 30 s, not 300 s; concurrent cold requests share one build; a spec package with an empty file list no longer fails the whole catalog. - More models rows follow the picker's format and fit filters, show when the Recommended list is empty, and appear on Transcribe for catalog ASR models.
A More models row has no Hub pipeline tag, so a catalog ASR model picked on Transcribe was treated as a speech model and loaded on Text to Speech. The pick now carries the catalog's speech-recognition task.
The picker's loading spinner and Hub failure hint replaced the whole list, so catalog rows that were already available stayed hidden until the Hub answered. Those states now apply only when neither list has rows.
…catalog rows - More models rows now join the picker's roving option list after the recommended rows, in the order they are drawn. Before, each got the shared fallback option id and arrow keys could not reach them. - When the backend read the installed runtime's own model specs, its catalog verdict decides which umbrella folders appear under More models, so a folder the static unoffered list holds back shows up once the runtime supports it. Without runtime specs the static list still applies.
… folder's spec The audio catalog guessed a folder's family from its name when no runtime spec placed it. Voxtral-4B-TTS reads as voxtral_realtime, whose spec places the Voxtral Realtime folder, so on a runtime without voxtral_tts the TTS folder was offered on Transcribe. A hint whose runtime spec places other folders but not this one is now ignored, and the GGUF header decides.
|
Audio models missing from the bundled list now appear on every Audio page their runtime spec allows. On b74c455, a spec with What changed
Testing
Community rows need runtime specs, which prebuilt runtimes don't ship yet. The screenshots below therefore use a catalog response that the real backend built from the v0.9.2 and HEAD runtime specs. Each "After" picker is scrolled to the More group. |
|
@codex review |
|
@codex security review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3ca3fe2c1
ℹ️ 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".
| useEffect(() => { | ||
| if (enabled) void store.refresh(); | ||
| }, [enabled]); |
There was a problem hiding this comment.
Schedule catalog retries and TTL refreshes
When the initial catalog request fails, or after a successful response reaches its TTL, nothing calls store.refresh() again: enabled remains true, and the Audio page is kept mounted while users navigate elsewhere, so this effect runs only once. The store's nextFetchAt only rejects early calls; it does not schedule a future call. A transient 503 therefore leaves all dynamic/community models absent for the rest of the SPA session, and a successful catalog never refreshes until a full reload. Schedule a retry/refresh timer (or refresh on activation/focus) rather than only invoking the store on the initial effect.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in fec462e: the hook now refreshes when the persistent Audio page becomes active and polls refresh (a no-op until the retry or TTL is due) while it stays active.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fec462e5d0
ℹ️ 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".
|
|
||
| test("the Audio page builds its picker lists from pageModels and the catalog hook", () => { | ||
| const page = readSrc("features/audio/audio-page.tsx"); | ||
| assert.match(page, /const audioCatalog = useAudioCatalog\(true\);/); |
There was a problem hiding this comment.
Match the assertion to the active catalog hook
The frontend test job in studio-frontend-ci.yml runs npm test, and this assertion cannot match the implementation introduced here: audio-page.tsx calls useAudioCatalog(active), not the literal true. With dependencies installed, audio-page-models.test.ts therefore fails every run before validating the rest; assert the active argument instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in d70fd94: the assertion now matches useAudioCatalog(active).
| source: response.source, | ||
| runtimeSpecs: response.runtime_specs === true, | ||
| }; | ||
| nextFetchAt = now() + ttlMs; |
There was a problem hiding this comment.
Honor the backend's degraded catalog retry interval
The fresh case not covered by the polling fix is a successful but degraded response: when /audio/catalog returns saved/cache, or a hub response with incomplete header probes, the backend intentionally caches it for only 30 seconds, but this branch unconditionally suppresses frontend fetches for the default 300 seconds. The new 30-second timer consequently no-ops for five minutes, leaving missing dynamic/community rows stale after a transient Hub or probe failure; allow polling refreshes through so the backend can enforce its own TTL.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in d70fd94: a saved or cache answer now sets the next fetch at the retry interval, so the poll re-asks once the backend's degraded TTL lapses; hub answers keep the 5 minute TTL.
…pdate the hook assertion [skip ci]
|
@codex review |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! 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". |
|
@codex review |
1 similar comment
|
@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 |
1 similar comment
|
@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". |
…munity package needs sidecars [skip ci]
…cpp format [skip ci]
…ol annotations (#14077) Includes #14072 (Studio: audio.cpp models land on the right pages); review this PR's own commits from 4d58b31 on. `git diff e1d6db4 HEAD` (the #14072 head) shows only this PR's changes; the merge commit just brings #14072 up to date. ## Summary Connecting an agent to the Unsloth Studio MCP server meant copying a per-agent command from `MCP.md`, and the documented Claude Code command expanded `$UNSLOTH_API_KEY` in the shell, so the key itself was written into `~/.claude.json`. Agents also had no way to see which image, video or audio models they could download, or whether one would fit on the GPU. This adds a setup command, a connection check, a download catalog in `list_models`, and two recipe prompts. ## Changes `unsloth mcp add {claude-code,codex,cursor,generic}` writes the agent's MCP entry. The entry names an environment variable (`UNSLOTH_API_KEY` by default, `--env-var` to change it) in the `Authorization` header, and the command never reads, prints or writes the key. - It uses `--url`, then `UNSLOTH_STUDIO_URL`, then a running Unsloth Studio on this machine, then `http://127.0.0.1:8888`. - Claude Code goes through `claude mcp add --scope user` when `claude` is on PATH, otherwise it edits `~/.claude.json` directly. Codex gets a `[mcp_servers.unsloth-studio]` table with `tool_timeout_sec = 300`, and the edit is refused if any other TOML setting would change. Cursor gets `~/.cursor/mcp.json` with `${env:UNSLOTH_API_KEY}`. `generic` prints a JSON snippet, or merges it into `--output`. - `--dry-run` prints just the entry it would write and writes nothing. It never prints the old entry it would replace, since one written by hand may hold a key. Re-running with the same arguments reports "unchanged". New config files are created with mode 0600, and existing files keep their mode. `unsloth doctor --mcp [--env-var NAME]` checks that Unsloth Studio answers, that the key is accepted, and that `/mcp/` is on (it tells "turned off" apart from "this Unsloth Studio predates MCP"). It warns, without failing, when a configured Codex or Claude Code tool timeout is under 240 s. Plain `--mcp` skips the GPU checks; `--mcp --gpus` runs both. `list_models(source="catalog")` lists image, video and audio models Unsloth Studio can download. Audio rows are forwarded from the audio.cpp catalog route in #14072 (`/api/inference/audio/catalog`), rather than importing its builder, so they stay filtered per account like every other MCP call. Image and video rows come from a new `GET /api/inference/media/catalog`, built from the diffusion and video family registries, filtered to what the calling account may load, and limited to the video families this device can run (as on the Video page). Catalog rows carry `size_bytes` (decimal bytes), `low_vram` (a video family's GGUF repo) and `fits_now`, which compares the size against the free memory of the single GPU with the most free memory, or is null when either value is unknown. The default `source="local"` output is unchanged. LLM rows in `list_models(source="catalog")` are a possible follow-up pending a maintainer decision. For now the docstring tells agents to list downloaded LLMs with the default source or load a Hugging Face id. The MCP server now offers two prompts, which Claude Code shows as slash commands: - `make_short_film(idea, length_seconds)` reads free GPU memory, loaded models and the video, music and voice catalog rows that fit now, then lists the calls from `load_model` through `generate_video`, `get_job` and `generate_audio`. - `build_dataset_and_train(goal, base_model)` reads the downloaded LLMs and lists the dataset, Data Recipe, `start_training` and `export_model` calls. Both fall back to plain steps when Unsloth Studio can't be read, and the rendered text is capped at 4000 characters. `MCP.md` gets a "One command" section for `mcp add` and `doctor --mcp`, the catalog in the `list_models` row, and a Prompts section. The hand-written Claude Code commands now single-quote `${UNSLOTH_API_KEY}` and use `--scope user`, so the key stays out of `~/.claude.json`. Tool annotations (titles, `idempotentHint`, `destructiveHint` on `load_model`) will land as a final commit after the other MCP PRs merge. ## Testing New tests: `unsloth_cli/tests/test_mcp_add.py`, `unsloth_cli/tests/test_doctor_mcp.py`, `studio/backend/tests/test_mcp_prompts.py`, `studio/backend/tests/test_media_catalog.py`, and catalog cases in `studio/backend/tests/test_mcp_tools_models.py`. `test_mcp_no_host_paths.py` also runs `list_models(source="catalog")`, and the `list_models` schema row in `test_mcp_server.py` is now a superset check, so it accepts `source`. - `unsloth_cli/tests/`: 2084 passed, 4 skipped. The 1 failure, `test_studio_update_verify.py::test_a_no_torch_install_keeps_that_mode_in_the_reinstall`, fails the same way on the #14072 head. - `studio/backend/tests/test_mcp_*.py` plus the media and audio.cpp catalog tests: 1708 passed, 3 skipped (fastmcp 3.4.8). The MCP, catalog and prompt files also pass on fastmcp 3.2.4. `FastMCP.prompt(title=)` exists back to the 3.0.2 floor. - Leak tests: a dry run over configs holding literal keys (any `Bearer` spelling, other headers, `args`, TOML `bearer_token` in any quoting, multi-line strings, another server's token) prints none of them, across 56 probe cases. Another test sets `UNSLOTH_API_KEY` to a canary and checks stdout, every written file and the `claude` argv for all four agents, with and without `--dry-run`. - `fits_now` is covered for a stubbed 24 GB and 12 GB card (Wan2.2-TI2V-5B, 24.2 GB, fits only the first), the GiB/GB boundary, and two GPUs (the max counts, not the sum). - Negative controls: `unsloth doctor --no-gpus` output is byte-identical to the #14072 head, and `doctor --help` only gains the `--mcp` line. Dumping every MCP tool's schema, description and annotations before and after shows only `list_models` changed. Against a running Unsloth Studio (no model loaded): - `unsloth doctor --mcp` with a valid key printed "API key: set, accepted", "MCP endpoint: on" and "Verdict: OK", exit 0. With a wrong key it printed "set, refused" and exit 1. The key appeared in neither output. - `mcp add claude-code`, `codex` and `cursor`, each run twice in a sandboxed home, wrote once and then reported "unchanged". `--dry-run` printed the diff and wrote nothing, and every created file was mode 600. `claude mcp get` and `codex mcp get` read the entries back with the env var name, not a key. - Claude Code 2.1.302 expands `${UNSLOTH_API_KEY}` in a user-scope header when it connects, so the entry `mcp add claude-code` writes authenticates. - A no-context Claude Code agent with only this MCP server, asked to plan a 20 s film with music and a voice-over for one 24 GB GPU, called `studio_status`, then `list_models(source="catalog")` for video, audio and TTS. It picked `unsloth/Wan2.2-TI2V-5B-GGUF` (a `low_vram` row), Stable-Audio-3-Medium-GGUF (3.6 GB) and Qwen3-TTS-12Hz-1.7B-VoiceDesign-GGUF (2.8 GB). That took 6 tool calls with no errors. The full catalog is 130 rows (33 KB) and returns in 0.09 s. - `prompts/list` and `prompts/get` for both prompts work over HTTP with live GPU and catalog data. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 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>






Summary
An audio.cpp model family that Unsloth Studio's tables don't list used to land on one Audio page, picked from the first task in its runtime spec. It now lands on every page the spec allows: a spec with
ttsandcloneshows on Text to Speech and Clone (fish_drama3,kitten_tts2),sepon Separate,asron Transcribe, andmusic/sfxon Music with a conservative setup (lyrics only when the spec declares alyricsoption, and no seed when its declared options leaveseedout). Voice conversion stays limited to the families Unsloth Studio already configures.The Audio pages can also list umbrella folders and Community repos that the bundled seed doesn't know about yet, so a new upload shows up without a frontend release. For example,
Jmica/Drama-3-GGUF(named by thefish_drama3spec) shows under "More models" on Text to Speech and Clone.Community rows come from the installed runtime's
model_specs/. Prebuilt runtimes don't ship that folder yet; the audio.cpp v0.9.2 support PR adds it at install. Until then the catalog lists umbrella folders only (runtime_specs: false), and the pickers behave as before for everything in the bundled seed.Changes
Backend placement (
audio_cpp_models.py):_family_from_spec_tasksbuilds one page set per family from the spec. Clone sends a reference on every run, soreference_textis required when the spec declares it and unused when the spec declares a request list without it.mira_ttsandsopro_ttsare Clone only, since both need a reference clip on every run.ui.recommended_package(falling back to its default GGUF package). K and IQ quants are ranked afterF32, so the existing preference order is unchanged.New
GET /api/inference/audio/catalog(audio_cpp_catalog.py):model_specs/, with pages, languages, status, size and whether it is downloaded.account_access.filter_model_rows. Failures return a 503 without exception text.Frontend:
pageModels()resolver (page-models.ts) decides which models each Audio page shows. The per-page filters and orderings inclone-page.tsx,convert-page.tsx,edit-page.tsx,music-page.tsx,separate-page.tsxandspeak-page.tsxare removed, andaudioRowMatchesWorkflownow calls the same resolver.moreModelsprop onModelSelector/HubModelPicker). The row tooltip shows pages, languages and status, and the size column shows the size. A downloaded new folder still lists under On Device.catalog:check --networknow emits a::warning::for an umbrella folder the seed doesn't list, instead of failing. A staleAUDIO_CPP_UNOFFERED_FOLDERSentry still fails.MCP:
list_modelstakes aworkflowfilter that keeps only audio models whoseaudio_workflowsinclude that page.generate_audiotakesmodel, which Unsloth Studio loads first when "Switch model by request" is on. Option checking against the loaded model is skipped when a different model will run the request.Not in this PR
Testing
tests/test_audio_cpp_*.py,test_audio_catalog_route.py,test_audio_run_route.py,test_audio_inputs.py,test_openai_auto_switch.py,test_mcp_*.py,test_stt_*.py: 3894 passed, 4 skipped. The affected files were rerun after the last edits: 1081 passed, plus 837 passed intest_openai_auto_switch.py -k "audio or switch".ruff checkis clean.fish_drama3-like spec lands on Text to Speech only) and passes here.sopro_ttsmodel on a plainttssession returns audio for/v1/audio/speechwithvoice_ref, and refuses without one. So spec-derived clone families run Clone on the speech session, with noclontask.npm testpasses (the files that timed out under load pass when rerun alone, 61/61).npm run typecheck,npm run catalog:check,npm run catalog:check:network,npm run i18n:check:strictandnpm run buildpass. A throwaway parity script showedpageModels()gives the same lists, in the same order, as the six removed page functions for every page, with and without Mac, over the bundled seed.UI before / after
Audio > Text to Speech model picker, scrolled to the end of the list: before, the list stops at the last Recommended row; after, a new "More models" group lists Plapre-3-GGUF with its 1.1 GB size. BEFORE is the merge base, AFTER is this PR, two separate installs. Community rows need a runtime with
model_specs/, which this capture host does not have.Audio > Clone model picker: the same "More models" group appears under Recommended.