Skip to content

Studio: fix audio.cpp partial downloads, aligner progress, CPU fallback - #13515

Merged
danielhanchen merged 22 commits into
unslothai:mainfrom
Etherll:fix/studio-audio-cpp-downloads
Oct 13, 2026
Merged

danielhanchen merged 22 commits into
unslothai:mainfrom
Etherll:fix/studio-audio-cpp-downloads

Conversation

@Etherll

@Etherll Etherll commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes six problems Unsloth Studio users hit with audio.cpp models from the audio-cpp/audio.cpp-gguf umbrella repo. Problems covered: cancelled downloads, the hidden timestamp aligner download, and CUDA builds on machines with no visible GPU.

Fixes

  • After a cancelled or incomplete download, the quant row had no ⋮ menu, so its .incomplete files could not be removed. _audio_cpp_variants_answer never set partial on umbrella rows. A row is now partial when it has a cached file that only it lists, or when the cache scan finds its blobs incomplete. It also reports download_remaining_bytes, partial_transport and partial_resumable. Files that every row lists (package configs, a voice folder, a shared codec) are not counted for one row, so siblings do not show as partial.
  • Reloading the page during a download dropped the row's progress and stalled the staged queue for multi-size folders like Moonshine. folder_row_for_download rebuilt Q8_0 instead of small/Q8_0, because the file in flight has no cache entry yet. download_target now records the row id and quant when the job starts, and folder_row_for_download reads that first. The cache and planner-path fallbacks are unchanged. Only a resolve whose listing came from the Hub is recorded, so an offline status read or a failed Hub call that fell back to the cache cannot rename a started job. The record is also saved, one small file per planner key in the Hub state dir, so a backend restarted mid-download (or another backend on the same install) still names the job by row; a file name alone cannot give the row key, which depends on the sizes beside it. A finished download drops its file, since the cache names the row then.
  • With Timestamps on, Transcribe downloaded Qwen3-ForcedAligner-0.6B (about 1.1 GB) with no Downloads entry, progress or cancel. /stt capabilities now return the aligner's id and variant. The new useAlignerDownload hook stages the aligner through the shared download manager as a normal quant download before the run starts. While it downloads, Transcribe shows "Downloading the timing aligner…". When it finishes, the run starts only if the page is still visible, still in Transcribe mode and still on the same audio. Turning Timestamps off, or starting a run without them, drops the waiting run and unblocks Transcribe. Cancelling drops the run and shows a toast saying to download again or turn Timestamps off. A sign-in or sign-out in another tab, which clears every download, also drops the waiting aligner plan, so Transcribe is not left blocked. A finished model download now clears audio.cpp's remembered cache misses, so the refresh on completion sees the aligner.
  • The Downloads panel showed an audio.cpp folder STT download as "Qwen3-ASR-0.6B-GGUF · Qwen3-ASR-0.6B-GGUF". The entry now shows the quant after the folder name.
  • A CUDA audio.cpp build failed on device "auto" when no GPU was visible (for example CUDA_VISIBLE_DEVICES=""), with a 501 wrapped in "the model file may be incomplete". select_backend trusted the install record's cuda. It now checks host_gpu_vendors(), with CUDA_VISIBLE_DEVICES / HIP_VISIBLE_DEVICES / ROCR_VISIBLE_DEVICES applied on every platform (Windows detection only sees driver DLLs), and launches on CPU when the build's GPU vendor (NVIDIA for CUDA, AMD for HIP) is not visible. If the vendor check fails, it keeps the build's backend. UNSLOTH_AUDIO_CPP_BACKEND and an explicit CPU choice still win. If the server still exits with GPU init output, the error now says no usable GPU is visible and points to the CPU device or UNSLOTH_AUDIO_CPP_BACKEND=cpu, not to the model file. The runtime status adds launch_backend next to the build's backend, read off the event loop because choosing it can run the binary's --version. The STT server records the backend it actually launched on, so a CPU fallback is not reloaded when training starts or ends.
  • The audio page's staged TTS download had no onCancelled, so a cancelled or failed download left a pending load behind. It now calls invalidatePendingStagedTts.

The umbrella download job already fetches every file a row lists plus companions. A test now checks that each row's download covers the files it lists and the bytes it shows.

Testing

Backend:

cd studio/backend
python -m pytest tests/test_audio_cpp_models.py tests/test_audio_cpp_server_http.py tests/test_audio_cpp_runtime_status.py tests/test_stt_capabilities.py -q

Results: the audio, STT, TTS, GGUF, download and Hub suites pass (about 4,250 in the last full run). The new cases fail on the base commit or on the commit before each fix.

New cases cover partial rows for cancelled umbrella quants, MioTTS codec rows and package mixes, a crowded-folder job in flight keeping its row, an offline status read leaving a started job's row alone, CPU fallback for CUDA and HIP builds with no visible GPU (including masks on a simulated Windows host), the GPU init error message, launch_backend in the runtime status (read off the event loop), a Hub listing failure not recording a cached guess, a finished download clearing a remembered aligner miss, a CPU-fallback STT server kept across training, crowded-folder jobs keeping their row after a restart with nothing in memory or cache, damaged saved records, and pruning only on completion.

Frontend:

cd studio/frontend
node --experimental-strip-types --test tests/audio-transcribe-aligner-download.test.ts tests/audio-tts-download-manager.test.ts tests/stt-download-mirror-policy.test.ts

The full npm test run passes (11773) and npm run typecheck is clean. alignerDownloadEntry is unit tested. The aligner wiring, the TTS onCancelled and the Downloads label are checked against source text, not run in a browser.

Screenshots

Merge base 67fbacd vs head 40a5e81, CPU-only Unsloth Studio, headless Chromium. Scene 1 uses a real cancelled Q8_0 .incomplete blob; scenes 2 and 3 stub the download network.

Before and after

  1. A cancelled Q8_0 quant is marked partial and gets a ⋮ menu with Delete.
  2. With Timestamps on, the aligner is staged in Downloads and Transcribe waits ("Downloading the timing aligner…").
  3. The Downloads entry names the quant instead of repeating the folder.

Known limits

  • Delete and Show in folder on a partial umbrella row (audio-cpp/audio.cpp-gguf/<Folder>) still need the umbrella-id fix in the deletion and reveal routes, which is a separate PR. That fix must also cover a quant that left only .incomplete blobs and download state, since such a quant has no snapshot file.
  • Capabilities are cached per STT model. After the aligner downloads through one Qwen3-ASR size, another size visited earlier in the session can still report it missing and stage a quick redundant download.
  • A finished Downloads item can still cover the audio page's History list for a few seconds. That overlay is app-wide and is not changed here.

The branch also carries a pre-commit.ci autofix commit that reformats four diffusion files (formatting only, no code change).

Review fixes and evidence (maintainer)

Commits added during review:

  • Merged main, which drops the four diffusion files from the diff (they already matched main).
  • A partial audio.cpp package row (MiniMax Music 3, YuE) is priced from every missing component, with finished and resumable component blobs credited.
  • A partial row with no download manifest is priced from its missing files and companions; when a companion cannot be resolved (offline), the remainder stays unknown instead of reading 0.
  • An umbrella download's row is saved to disk only when the download starts, so a status poll after completion no longer recreates the dropped record.
  • If the aligner finishes while a model is loading or another task runs, Transcribe shows a toast asking to press it again instead of dropping the run.

CPU fallback on the real audio.cpp CUDA build (v0.9.0-unsloth.1 and v0.9.1-unsloth.1, Moonshine tiny, B200 host):

CUDA_VISIBLE_DEVICES merge base this PR
"" fails: CUDA backend requested but registry 'CUDA' has no device 0, reported as "the model file may be incomplete" starts on cpu
0 starts on cuda starts on cuda

Cancelled BF16 download of Qwen3-TTS-12Hz-0.6B-Base-GGUF in the Audio page clone selector, merge base vs this PR. The row is now marked partial and gets a menu (API: partial false -> true):

Cancelled umbrella quant, before and after

…CPU fallback

- Umbrella folder and package quant rows report partial after a cancelled or
  incomplete download, so the row menu can clean them up.
- An in-flight umbrella download keeps its folder row and quant (e.g.
  Moonshine small/Q8_0) after a page reload.
- Timestamps on Transcribe fetch the Qwen3 forced aligner through the
  Downloads panel, with progress and cancel, before the run.
- The Downloads panel names an audio.cpp folder STT download by its quant.
- A CUDA or HIP audio.cpp build launches on CPU on auto when no GPU of that
  vendor is visible; GPU init failures no longer read as an incomplete model
  file, and the runtime status reports the launch backend.
- The audio page's staged TTS download clears its pending load on cancel.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T13:16:06.613779Z cd11505 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

pre-commit-ci Bot and others added 13 commits October 13, 2026 03:03
…indows

host_gpu_vendors only checks driver DLLs on Windows, so a CUDA or HIP build
with CUDA_VISIBLE_DEVICES or HIP_VISIBLE_DEVICES hiding every device still
launched on the GPU backend there. Apply the masks in _gpu_vendors on every
platform.
When the Hub listing call fails, resolve falls back to the HF cache, where a
crowded folder can name another size's file under the requested row. Carry the
listing's provenance on the resolved model and record the job's row only when it
came from the Hub.
…me status off the event loop

An umbrella folder whose family is not recognized resolved through an early
return that dropped from_hub, so its download row was never recorded. The
runtime status's launch backend can run the binary's --version, so the async
STT status route now reads it in a worker thread.
…r its download

Turning Timestamps off while the aligner downloads no longer keeps Transcribe
blocked, and a run without timestamps replaces one waiting on the aligner. A
finished model download now clears audio.cpp's remembered cache misses, so the
capabilities refresh on completion reports the aligner as downloaded.
…ack STT server across training

Turning Timestamps off while the aligner downloads now drops the waiting
transcription instead of starting it without timestamps later. The audio.cpp
STT sidecar records where its server actually runs, so a GPU build that
already fell back to the CPU is not reloaded when training starts or ends.
download_target's (planner key -> row, quant) record lived only in memory, so a
backend restarted mid-download named a multi-size folder's job by its bare
quant (Moonshine small/Q8_0 as Q8_0). The record is now also saved in the Hub
state dir, read after the in-memory one, validated on read and dropped when the
job ends. A file name alone cannot give the row key: it depends on the sizes
beside it.
Two backends on one install could each read the shared JSON map and replace it
with only their own update, dropping the other's row. Each planner key now has
its own file, written by one atomic replace and removed when the job ends, so
concurrent writers never merge. Any unreadable record, including absurdly
nested JSON, reads as absent.
…d until its download finishes

A cross-tab session change cleared every download job but left a mounted
page's staged plan behind, so Transcribe stayed blocked on the aligner. Staging
hooks now drop their plan (and run onCancelled) when the download manager
resets. A cancelled or failed umbrella job no longer deletes its saved row,
which stays correct and may serve another backend's download of the same key;
only a finished download, whose row the cache then names, removes it.
…celled

Images and the Hub queue start their next plan from onCancelled, so calling it
on a cross-tab session reset carried the old session's queued plans into the
new one. Staging hooks now call a separate optional onReset; the aligner and
the audio TTS slot use it to drop their pending run, and everyone else just
loses the stale plan.
…handles it

Dropping every staged plan on a cross-tab session reset left the Images page
and the Hub queue holding their own plans with nothing behind them. Only a
consumer that passes onReset (the aligner and the audio TTS slot) now loses
its plan; the rest keep the old behavior. The test now fails if the reset
path calls onCancelled.
@danielhanchen danielhanchen self-assigned this Oct 13, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…p rows; tell the user when the aligner finishes mid-load
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Failed to sample tokens
ℹ️ 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".

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

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

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

from hub.utils.gguf import gguf_variant_key

return model.repo_id, gguf_variant_key(model.variant.primary)
key = gguf_variant_key(model.variant.primary)

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 Resolve folder polls from the saved target mapping

When an umbrella download is polled from a sibling/restarted backend while the Hub listing is unavailable, resolve(identifier, variant) can see only cached siblings; for a crowded folder it marks the requested variant unsupported but returns the default cached sibling. Deriving key from that fallback makes _audio_cpp_target status/progress/cancel calls address the sibling job (or return 404 when no sibling is cached), even though the new persisted row record contains the active real key. Consult that mapping in the forward direction before falling back to cache-only resolution.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not changing this here: forward resolution of a row is unchanged from the merge base (download_target already resolved from the cache when the Hub listing fails), and it needs a restarted or sibling backend polling a crowded-folder job during a Hub outage. Out of scope for this PR.

companions_cached
and audio_cpp_files.cached_files(model.with_variant(variant)) is not None
)
row_model = model.with_variant(variant)

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 Include state-only variants in cache-only audio listings

When Hub access is unavailable after a download was interrupted before all files were linked, _cached_listing excludes the .incomplete blobs and _package_variants omits an incomplete package mix, so that target is absent from model.variants. Because the new partial detection only runs for variants entering this loop, a cache-only umbrella/package listing drops the canceled row entirely (or returns 404 if it is the only row) despite its manifest and cancel marker, preventing the interrupted variant from being surfaced for resume; reconcile state-only variants before building these rows as the generic GGUF path does.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not changing this here: the cache-only listing is unchanged from the merge base, which also dropped an interrupted umbrella variant whose files are only .incomplete blobs; this PR adds partial rows to the online listing. Offline reconciliation of state-only variants is a separate change.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

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

ℹ️ 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 +144 to +148
queueRef.current = null;
generation.current += 1;
inFlight.current = null;
setQueue(null);
onResetRef.current?.();

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 Abort in-flight staged starts during session resets

When a sign-in/sign-out reset fires while downloadManager.requestStart(...) is still awaiting transport, status, or start round trips, this handler only clears React ownership and increments the local generation; it does not cancel or epoch-gate the pending request. That request can resume after resetDownloadManagerState() and repopulate the cleared manager, or finish starting an orphan backend job, so an aligner/TTS download from the previous session survives the boundary even though onReset dropped its pending action. Carry the reset epoch or an abort signal into the start path and reject it before manager/backend side effects.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not changing this here: an in-flight requestStart racing a cross-tab sign-in/out lives in the shared download manager and applies to every download start on the merge base too; this PR only adds dropping the staged plan on reset. Epoch-gating requestStart is a separate change to the download manager.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: cd1150545a

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

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.

2 participants