Skip to content

Studio: add local speech-to-text dictation engine - #7095

Merged
danielhanchen merged 116 commits into
mainfrom
studio-stt-dictation
Jul 23, 2026
Merged

danielhanchen merged 116 commits into
mainfrom
studio-stt-dictation

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

What this does

Adds local, offline speech-to-text dictation alongside the existing browser engine.

Browser dictation uses the browser or operating system speech service and remains the default. Local transcription records audio in the browser and transcribes it on the Studio server. The selected model decides the backend automatically:

  • The five curated Whisper models (Tiny, Base, Small, Large v3 Turbo, Large v3) run as GGML checkpoints through a managed whisper-server subprocess (whisper.cpp). This is the fastest path.
  • Searching Hugging Face from the model picker and selecting another Whisper repository (for example a fine-tuned safetensors checkpoint) runs it through Transformers.

There is no separate engine to configure. After a model is downloaded, dictation works offline and with any loaded chat model, including text-only models.

Curated GGML checkpoints download from the Unsloth-hosted unslothai/whisper-*-GGUF repositories, one repository per model.

Performance

Same checkpoints, greedy decoding, warm model, Apple Silicon (medians):

Whisper Small whisper.cpp Transformers
Model load 0.44 s 0.86 s
8.8 s clip 0.35 s 1.01 s
43.5 s clip 1.13 s 4.21 s

Across the curated models whisper.cpp transcribes 2.4x to 5x faster than Transformers on the same checkpoints and holds its weights in a separate process (about 865 MB resident for Small) instead of the backend process.

Using local dictation

  1. Open Settings > Voice.
  2. Set Dictation engine to Local transcription.
  3. Choose a curated model, or search Hugging Face for another Whisper repository (validated before selection). Selecting a model loads it automatically once downloaded.
  4. Download the model (single progress bar with transfer rate) and start dictating.

The model loads on demand, remains warm for five minutes after the last transcription, and can be unloaded immediately from Voice settings.

Backend

  • Adds a lazily loaded Transformers Whisper sidecar and a GGML sidecar that owns one whisper-server subprocess with idle unload.
  • scripts/build_whisper_cpp.sh builds a pinned static whisper-server into the Studio home; the binary is also discoverable via WHISPER_SERVER_PATH, UNSLOTH_WHISPER_CPP_PATH, or PATH. The stacked Studio: prebuilt whisper.cpp via the shared llama.cpp install core, slim bundles paired to the llama prebuilt #7294 adds prebuilt whisper-server distribution (slim bundles paired to the llama.cpp prebuilt), which makes this source build the opt-in fallback.
  • Both backends download models directly with byte-level progress reported by /audio/stt/status (a GGML checkpoint is a single file, which the Model Hub GGUF planner cannot express; a Transformers checkpoint is a whole snapshot).
  • /audio/stt/status reports per-engine state (transformers and gguf objects with identical shape) and accepts a model query param so downloaded state also covers custom repositories. Top-level fields are kept for existing clients.
  • The downloaded check verifies the files loading actually needs (config, preprocessor config, weight files), so a partial snapshot left by an aborted download surfaces the Download button instead of a load failure.
  • Load, unload, transcription, and download routes accept an engine parameter derived from the selected model; unload without an engine frees both backends.
  • Training memory admission accounts for whichever backend is resident, including the whisper-server subprocess.
  • Transformers uses CUDA float16 when available, MPS float32 on Apple Silicon, and CPU float32 otherwise. whisper.cpp uses its own Metal, CUDA, or CPU backends.
  • Decodes bounded 16 kHz mono audio through PyAV and enforces the 25 MB STT request limit before buffering.

Frontend

  • Dictation engine picker with two options: Browser and Local transcription.
  • Model picker lists the curated models (name, source repository, download size) and searches Hugging Face for other Whisper repositories, validating them before selection. The trigger is a plain button, so the selection never renders inside a text input.
  • One download flow for both backends: byte-level progress bar with transfer rate, then the model loads automatically when its download finishes. Models also load automatically on selection.
  • Dictation history stores every dictation (paginated with Show more, 20 per page), offers Clear history at the top, and links each dictation back to the chat it was spoken into. Deleting a linked dictation can optionally delete the chat too.
  • Archived chats dialog uses the same pagination.
  • Records microphone audio with MediaRecorder; short dictations stay in one clip and longer recordings split near Whisper's 30 second window.
  • Fixes a persistence bug where voice settings and dictation history were silently not saved: the quota-safe localStorage wrapper was declared after the store that uses it, so the persist storage factory failed at module load.

Validation

  • 88 backend STT tests pass (Transformers and GGML sidecars), including coverage for binary discovery, WAV packaging, download tracking, and error contracts.
  • Verified with automated browser sessions and live API checks: model selection closes the picker with no page errors, persisted settings hydrate on reload, curated models download from the unslothai repositories and transcribe through whisper.cpp, searched safetensors models download, load on MPS, and transcribe through Transformers, and a custom repository is rejected by the GGML backend with a 422.
  • Frontend type checking, lint, i18n parity, and production build pass.

shimmyshimmer and others added 13 commits July 11, 2026 03:31
New Voice tab in Settings, placed just before About:

- Dictation: microphone picker, browser STT engine, recognition language,
  and an inline mic test with a live transcript
- Dictation dictionary: entries rewrite matching speech to their exact
  spelling and casing, applied in both dictation paths
- Recent dictations: last 20 final transcripts with copy and clear, so
  text can be recovered if it lands in the wrong place
- Read aloud: optional button on assistant responses with two engines,
  curated system voices (novelty and legacy voices filtered, quality
  ranked, capped at 20) or the TTS audio model loaded in Unsloth via
  /audio/generate (e.g. Orpheus), plus speed, pitch, volume and preview

Settings persist in localStorage (unsloth_voice_settings) and are read
at call time so changes apply without reloading the runtime. Adds en
keys plus the tab label for ja, zh-CN and pt-BR.
The STT engine dropdown only had one entry, so it added noise without
giving a real choice. The engine row can come back once local STT
models land. Also renames the TTS engine option Unsloth TTS model to
Load TTS model to make the action clearer.
Simulated the feature across Chromium, Firefox and WebKit plus node
level unit runs and backend contract checks. Fixes from the findings:

- Dictionary rewrite used a replacement string, so entries containing
  dollar patterns corrupted transcripts (A$$AP became A$AP, $& injected
  the match). Switched to the callback form of String.replace
- Persisted voice settings now validate types on hydration: non string
  micDeviceId, dictationLanguage and ttsVoiceURI, and non boolean
  ttsEnabled fall back to defaults instead of flowing into the UI
- Dictionary entries are trimmed, capped at 120 chars and re-sanitized
  on hydration
- The Test dictation panel now falls back to the default microphone
  when the saved device is unplugged, matching the composer adapter

Test coverage: 46 unit assertions (dictionary regex edge cases across
unicode, word boundaries and injection, voice curation for simulated
macOS, Windows and Linux voice inventories, corrupt storage merge),
13 backend contract checks against /audio/generate on an isolated
instance, and 60 browser assertions across the three engines covering
rendering, degradation without SpeechRecognition, curation in a real
DOM, dictionary persistence with unicode and dollar entries, the
no-model preview error path and corrupt localStorage recovery.
Verified each review comment before acting. Confirmed and fixed:

- Editing a dictionary entry was broken in two ways: the store trimmed
  on every keystroke so spaces could not be typed, and clearing the
  field deleted the entry and unmounted the input mid edit. Updates now
  keep the raw value and a blur commit trims or removes the entry
- The unplugged mic fallback checked instanceof DOMException, but a
  cross browser probe showed Firefox and WebKit throw
  OverconstrainedError objects that are not DOMExceptions, so the
  fallback never fired there. Matching on the error name now
- When the browser ended a dictation test on its own (silence timeout),
  the mic stream stayed open. All recognition end paths now stop the
  tracks and save the transcript through a single finalize path
- The studio TTS audio element now releases its WAV data URL as soon as
  playback ends, fails or is cancelled
- Allow microphone now reports insecure contexts (no mediaDevices)
  accurately instead of claiming access was blocked
- Voice tab copy moved into i18n keys per src/i18n/AGENTS.md, so locale
  overlays can translate it; en is the baseline and parity passes
- unsloth_voice_settings added to the Reset all local preferences key
  list so voice preferences obey the reset
- Non default microphones note that the system default is used when the
  browser speech engine cannot bind a specific device, since browsers
  without the start(track) overload ignore the argument silently

Re-ran the full simulation set after the changes: 46 unit assertions,
13 backend contract checks and 60 browser assertions across Chromium,
Firefox and WebKit all pass, plus a dedicated browser probe for the
dictionary editing behavior.
The Voice tab and its buttons used the hugeicons Mic02 glyph while the
chat composer uses a custom filled mic. Extract that composer icon into
a shared lib/mic-icon component, drop the duplicate inline copies in
thread.tsx and shared-composer.tsx, and use it for the Voice tab icon
and the tab's mic buttons so the microphone looks the same everywhere.
Verified each new comment against the current code first. One item was
already fixed in the previous round (recording transcripts when the
browser ends a dictation test on its own). Confirmed and fixed:

- The microphone row showed a picker with generic names when browsers
  enumerate unlabeled devices before permission, leaving no way to
  grant access from the row. It now branches on whether labels are
  visible and shows Allow microphone otherwise
- Compare chat dictation ignored the selected microphone. It now opens
  the chosen device with the same fallback rules as the main adapter,
  passes the track to recognition where supported and releases the
  stream when recognition ends
- Closing the Voice tab cancelled the shared speechSynthesis even when
  read aloud was playing a chat message. Cleanup now only cancels when
  the tab owns an active preview
- Double clicking Start test could race two recognizers and leak the
  first stream. A starting flag set before the getUserMedia await makes
  start reentrancy safe
- Turning off the read aloud setting mid playback removed the only stop
  control. The stop button now renders whenever a message is speaking
- When an engine lacks the start(track) overload, both dictation paths
  now release the selected device stream before retrying with the
  default microphone instead of holding it open
- Read aloud support no longer requires Web Speech synthesis: the
  Unsloth TTS engine only needs audio playback, so it stays available
  in WebViews without speechSynthesis, with a clear error if the system
  engine is chosen there

Not addressed here: cancelling in flight backend TTS generation on
stop. The route runs generation in a worker thread without a
cancellation path, which is shared pre existing behavior with audio
chat generation and belongs in a backend change.

All suites re-run green: 46 unit, 13 backend contract and 60 browser
matrix assertions across Chromium, Firefox and WebKit, plus probes for
the unlabeled device branch and the double click race.
Release a microphone opened after the component unmounts, and stop Compare
dictation on a permission or security failure instead of silently recording
from the default device, matching the main chat adapter.
…ttings

- Join final dictation chunks with a space so recorded transcripts do not merge words
- Ignore a stale recognizer onend so a quick stop then restart is not torn down
- Use previewingRef so a double click on TTS preview does not orphan the first request
- Keep the read-aloud stop control visible when a new run starts while a message is spoken
- Stop the dictionary remove button from deleting an adjacent entry on a blur then click race
- Only cancel the shared speechSynthesis for a system-voice preview, so stopping
  a Studio preview no longer stops an unrelated chat read-aloud
- Release the Studio preview audio and its WAV data URL on normal completion
- Iterate every finalized result in Compare dictation so batched phrases are kept
- Cap persisted recent dictations to the last 20 on hydration
… audio

- Copy recent dictations via the copyToClipboard helper so the execCommand
  fallback works in Safari and insecure http LAN contexts
- Release the Studio preview audio when play() rejects, not just on ended/error
Add an offline dictation engine that transcribes with a local faster-whisper
model, alongside the existing browser (Web Speech) engine. The browser engine
streams audio to Apple or Google speech services and needs internet; the new
engine runs on the server, works offline, and drives any chat model without
evicting it (it loads in the backend process, separate from the model
subprocess). It also gives Firefox dictation, which has no Web Speech support.

Backend: a lazily-loaded, kept-warm faster-whisper sidecar and three routes
under /api/inference/audio (stt/status, stt/load, transcribe). faster-whisper
is torch-free, so this does not disturb the existing model stack.

Frontend: a Dictation engine setting (browser or local model), a curated model
picker with sizes, and MediaRecorder capture posted to the transcribe route.
The model warms automatically when the engine is selected, with live status.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a standalone speech-to-text (STT) sidecar using faster-whisper to support local, offline dictation. It adds backend routes for transcribing and warming models, alongside frontend updates to allow users to choose between browser-based and local model-based dictation. The review feedback highlights a critical backend issue where lazy evaluation of transcription segments bypasses exception handling, potentially causing unhandled 500 errors, as well as a concurrency race condition. Additionally, a frontend optimization is suggested to use the native FileReader API for more efficient, asynchronous blob-to-base64 conversion.

Important

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 134ca8cc22

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Local dictation showed nothing until you stopped, because the whole clip was
transcribed once on stop. Now the growing recording is re-transcribed on a
fast pass every second and emitted as live interim text, with an accurate
final pass on stop. Partial recordings decode fine, and the model refines
earlier words as more audio arrives.

Adds an interim flag to the transcribe route (beam 1, no VAD) for the fast
preview pass; the final stop uses the accurate path.

@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: 05a7add0f6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread studio/backend/routes/inference.py Resolved
Stopping local dictation waited for a final network transcription before the
session ended, so the stop button did not flip and a second click ended the
session early and dropped the text. Now stop commits the live transcript
immediately, releases the mic at once, and ignores a second stop while
finalizing. Previews run more often so the committed text is current.

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Re-transcribing a growing buffer every second got slower as it grew, flooded
the backend, showed stale words, and could leave the stop button stuck waiting
on a backlog. Record short independent clips instead and transcribe each once,
appending the text as you speak. Work per clip is bounded, so stopping is
prompt (with a hard timeout as a safety net) and long dictations stay smooth.

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

shimmyshimmer and others added 4 commits July 13, 2026 01:54
Local STT dictation streamed by re-transcribing the growing clip, which
was quadratic and saturated the backend (multi-second lag), and stop only
halted the recorder without releasing the mic, so it kept recording. Record
the microphone continuously, release it the instant the user stops, and
transcribe the whole clip once. Stopping is immediate and the transcript
lands in about a second. Also add the tiny model for the fastest option.
…silently

- Compare dictation reports microphone and speech-recognition errors via toast,
  reusing the main chat adapter's describeMediaError and describeSpeechError
- Read-aloud toasts genuine model or synthesis failures while ignoring cancellations
Clicking the mic now drops the composer into a dedicated recording bar
with a live waveform, a discard (X) and a confirm (tick), instead of a
plain stop button. The tick stops recording and transcribes the clip;
the X throws the recording away and keeps whatever text was already in
the composer. The model adapter taps the mic with an analyser to drive
the waveform, and the router tracks the live session so the X can cancel
it without transcribing.
Match ChatGPT's recording layout: the bar now renders in place of the
input with the left plus button kept, the waveform in the middle, and
the discard and confirm buttons together on the right.

Cut the post-confirm delay by transcribing in the background as the user
talks. The audio is split at natural pauses (voice-activity detection off
the same analyser that drives the waveform) and each clip is transcribed
as it is cut, so confirming only has to finish the short final tail. The
model is also warmed when recording starts so the first run never pays a
cold load.

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Make the recording UI read like ChatGPT: the waveform is now a dense row
of round dots that rise into thin centered bars, and while dictating only
the plus button shows, with the mode badge and tool toggles hidden so the
bar is just the waveform and controls.

Speed up transcription: decode greedily (beam_size=1), which is several
times faster on CPU with negligible accuracy loss on short dictation
clips, and cap background segments at 6s so the final tail after confirm
stays short.
…io-stt-dictation

# Conflicts:
#	studio/frontend/src/features/chat/shared-composer.tsx
#	studio/frontend/src/features/settings/tabs/voice-tab.tsx
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: f6dca5608c

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

…ack, split training eviction

- Hide the curated GGUF dictation repos (unslothai/whisper-*-GGUF) from the chat
  model inventory and pickers, backend and frontend. Only their Transformers
  safetensors companions were hidden; the GGUF repos use a different org and a
  -GGUF suffix and carry a raw .bin with no whisper config.json, so they leaked
  into chat pickers.
- Make the GGUF sidecar loaded_model/device accessors lock-free, mirroring the
  Transformers sidecar. transcribe() holds self._lock across the whole inference
  call, so /audio/stt status polls and training admission previously blocked
  behind an in-flight transcription.
- stt_unload resolves through the serving resolver: a "gguf" pick on a host
  without whisper-server is served by the Transformers fallback, so unload must
  target that engine or the resident model is never freed. Unload also attempts
  every engine even if one raises, so a failure freeing one backend no longer
  skips the other.
- free_stt_model_for_training frees the Transformers and GGUF sidecars under
  independent exception boundaries so a failure unloading one no longer skips
  the other before training claims the memory.

Adds tests/test_stt_review_fixes.py covering all four.
@oobabooga

Copy link
Copy Markdown
Member

I smoke-tested the UI on this branch. Curated model download and auto-load, dictation with the recording bar, transcripts landing in the composer, history. All good. I did not get to the Browser engine (I was on another machine and hit the "internet connection required" toast, expected off localhost); worth one re-check there.

Also tested the prebuilts and the PR end to end.

Fixes attached where one is worth proposing.

#7095

Local dictation sends "auto" instead of a resolved language

A real batch of non-English conversational voice notes came back mostly in English with the language setting on Auto. The browser engine already resolves Auto to the UI locale through resolveDictationLanguage; the model adapter sends the raw setting. Aligning them sidesteps the drift. Diffs against studio/frontend/src/features/settings/stores/voice-settings-store.ts (new resolver) and studio/frontend/src/features/chat/adapters/studio-model-dictation-adapter.ts.

  • Clean read speech auto-detects fine (the drift did not reproduce with spoken-article audio), so this is Whisper's language detection getting unreliable on hard audio, not a broken path. No translate step is involved on either engine (whisper-server defaults translate=false, the Transformers sidecar pins task="transcribe").
  • The resolution is guarded: a custom English-only .en checkpoint paired with a non-English locale keeps today's working Auto behavior instead of hard-failing with a 422 (isSttModelLanguageCompatible deliberately accepts Auto for those).
  • Auto also only resolves into Whisper's language set (mirrored from transformers LANGUAGES plus the backend's BCP-47 aliases, the way STT_MODELS is already mirrored), so a UI locale Whisper cannot honor (Irish, Scottish Gaelic) keeps auto-detect instead of 422ing every dictation. An explicitly picked language is never rewritten.

In voice-settings-store.ts, next to resolveDictationLanguage:

+// Whisper's language codes (transformers LANGUAGES, mirrored like STT_MODELS)
+// plus the backend's BCP-47 aliases (stt_sidecar.py), so Auto only resolves
+// to a language the backend accepts; anything else stays on auto-detect.
+const WHISPER_DICTATION_LANGUAGES = new Set([
+  "af", "am", "ar", "as", "az", "ba", "be", "bg", "bn", "bo", "br", "bs",
+  "ca", "cmn", "cs", "cy", "da", "de", "el", "en", "es", "et", "eu", "fa",
+  "fi", "fil", "fo", "fr", "gl", "gu", "ha", "haw", "he", "hi", "hr", "ht",
+  "hu", "hy", "id", "in", "is", "it", "iw", "ja", "ji", "jw", "ka", "kk",
+  "km", "kn", "ko", "la", "lb", "ln", "lo", "lt", "lv", "mg", "mi", "mk",
+  "ml", "mn", "mr", "ms", "mt", "my", "nb", "ne", "nl", "nn", "no", "oc",
+  "pa", "pl", "ps", "pt", "ro", "ru", "sa", "sd", "si", "sk", "sl", "sn",
+  "so", "sq", "sr", "su", "sv", "sw", "ta", "te", "tg", "th", "tk", "tl",
+  "tr", "tt", "uk", "ur", "uz", "vi", "yi", "yo", "yue", "zh",
+]);
+
+/**
+ * Resolve Auto for the model engine, only when the model and Whisper can
+ * honor the resolved locale; otherwise keep the raw setting (auto-detect).
+ * A concrete user-picked language passes through unchanged.
+ */
+export function resolveModelDictationLanguage(
+  model: SttModel,
+  requested: string,
+): string {
+  const resolved = resolveDictationLanguage(requested);
+  const primary = resolved
+    .trim()
+    .replaceAll("_", "-")
+    .toLowerCase()
+    .split("-", 1)[0];
+  return isSttModelLanguageCompatible(model, resolved) &&
+    WHISPER_DICTATION_LANGUAGES.has(primary)
+    ? resolved
+    : requested;
+}

In the adapter:

 import {
   applyDictationDictionary,
   isCuratedSttModel,
   recordRecentDictation,
+  resolveModelDictationLanguage,
   useVoiceSettingsStore,
 } from "@/features/settings/stores/voice-settings-store";
-  const language = options.language ?? settings.dictationLanguage;
+  const language = resolveModelDictationLanguage(
+    model,
+    options.language ?? settings.dictationLanguage,
+  );
-    const { sttModel: sessionModel, dictationLanguage: sessionLanguage } =
+    const { sttModel: sessionModel, dictationLanguage } =
       useVoiceSettingsStore.getState();
+    const sessionLanguage = resolveModelDictationLanguage(
+      sessionModel,
+      dictationLanguage,
+    );

Opus input verified working through the PyAV decode

Browser MediaRecorder output and messaging-app voice notes are Ogg/WebM Opus, which whisper-server rejects raw, so the PyAV decode is what makes the GGUF path work for the most common real input. Verified both containers decode fine through the real _decode_audio_bounded, so nothing to change here.

Double read of self._process in the GGUF status accessors

The lock-free loaded_model/device go through _process_alive(), which reads self._process twice; a concurrent unload() nulls it in between. On a GIL build the two adjacent attribute reads cannot actually interleave, so this is latent, but it is correctness by GIL luck and the fix is free. (studio/backend/core/rag/embed_llama_server.py has the identical shape; worth the same one-liner in a later sweep.)

     def _process_alive(self) -> bool:
-        return self._process is not None and self._process.poll() is None
+        process = self._process
+        return process is not None and process.poll() is None

unslothai/whisper.cpp (prebuilt CI)

The macOS deployment-floor check does not assert

The "Verify arch + deployment floor" step in unsloth-prebuilt-macos.yml asserts the arch but only echoes MINOS, despite its comment saying it asserts; a wrong floor would ship silently. This is how upstream llama.cpp shipped macos-26 binaries stamped minos 26 that refuse to load on older Macs, which is why unslothai/llama.cpp gates it, and it is the guard that matters if you take the macos-26 runner change below. Minimal inline gate below; the fuller option is porting llama.cpp's assert_macho_minos.sh, which also covers the x64 slice's dylibs.

           MINOS="$(otool -l "$BIN" | awk '/LC_BUILD_VERSION|LC_VERSION_MIN_MACOSX/{f=1} f&&/minos|version/{print $2; f=0}' | head -1)"
           echo "minos=$MINOS target=${{ matrix.deploy_target }}"
+          [ -n "$MINOS" ] || { echo "could not read minos from $BIN" >&2; exit 1; }
+          awk -v m="$MINOS" -v t="${{ matrix.deploy_target }}" 'BEGIN {
+            split(m, a, "."); split(t, b, ".")
+            exit (a[1] * 100 + a[2] > b[1] * 100 + b[2]) ? 1 : 0
+          }' || { echo "minos $MINOS exceeds deploy target ${{ matrix.deploy_target }}" >&2; exit 1; }

validate_bundle.py --gpu hangs after a successful inference

With --gpu, run_inference() reads the live server's stdout pipe to EOF, which never comes. Nothing in the current matrix uses --gpu (GPU bundles ship un-run), but it will hang the first self-hosted accelerator job. Reproduced with the CPU bundle, where the same command completes in about 3 s without --gpu and blocks until killed with it. With this patch the --gpu run completes.

-            log = proc.stdout.read() if proc.stdout else ""
+            proc.terminate()
+            try:
+                log = proc.communicate(timeout = 15)[0] or ""
+            except subprocess.TimeoutExpired:
+                proc.kill()
+                log = proc.communicate()[0] or ""

The existing finally cleanup then becomes a harmless no-op.

Stale fingerprint line in the prebuilt README

In .github/workflows/UNSLOTH_PREBUILT_README.md, the "Trust and reproducibility" bullet says the fingerprint is stamped into BUILD_TARGET, which is the llama.cpp mechanism. This repo's own design puts the mark in each bundle's BUILD_INFO.txt, and the shipped bundles confirm it (the binary does not carry the string). The resolve-job paragraph higher up repeats the mistake, crediting the fingerprint to cmake/build-info.cmake, which resolve only stamps with the build number and commit.

 - Every bundle must carry the `Compiled by the Unsloth team` fingerprint
-  (stamped into `BUILD_TARGET`); the orchestrator refuses to publish an
-  unbranded binary.
+  (carried in each bundle's `BUILD_INFO.txt`, written by `package_bundle.py`);
+  the orchestrator refuses to publish an unbranded bundle.
 The `resolve` job dereferences `upstream_tag` to an **immutable commit SHA** and
-records it, then stamps `cmake/build-info.cmake` (build number, commit, and the
-`Compiled by the Unsloth team` fingerprint) and uploads the source tree once.
+records it, then stamps `cmake/build-info.cmake` (build number and commit) and
+uploads the source tree once.

Dead schedule clause in the orchestrator

unsloth-prebuilt.yml is workflow_dispatch-only, so the schedule disjunct on the two publish-gate steps is dead (it reduces to inputs.publish; behavior is unchanged either way). Same change on both steps.

-        if: ${{ (github.event_name == 'schedule' || inputs.publish) && needs.resolve.outputs.exists != 'true' }}
+        if: ${{ inputs.publish && needs.resolve.outputs.exists != 'true' }}

Wrong loader comment in the CPU workflow

The header comment claims the Studio sidecar prepends the binary dir to LD_LIBRARY_PATH/PATH. It does not set any loader env, and it does not need to; the bundles resolve their co-located libs on their own (verified by running the Linux bundle with LD_LIBRARY_PATH unset).

-#     an AVX2/Haswell-2013 floor and SIGILL on older CPUs. The sidecar already
-#     prepends the binary dir to LD_LIBRARY_PATH/PATH for the co-located libs.
+#     an AVX2/Haswell-2013 floor and SIGILL on older CPUs. The co-located libs
+#     resolve through the binary's $ORIGIN rpath (exe-dir search on Windows).

Build the macOS Metal slice on macos-26 (optional)

llama.cpp builds its arm64 Metal slice on macos-26. This is not an M5/A19 fix for whisper. With GGML_METAL_EMBED_LIBRARY=ON the shaders compile at runtime on the user's machine, and v1.9.1 ggml runtime-probes the tensor path with a clean fallback, so a macos-14 build behaves the same on M5/A19. Beyond parity there is one small real gain, the newer SDK compiles in residency-set support, used on macOS 15+.

-            {"build":"arm64","runner":"macos-14",      "expect_arch":"arm64", "deploy_target":"14.0","accel":"metal","backend":"metal","defines":"-DGGML_METAL=ON -DGGML_METAL_EMBED_LIBRARY=ON -DGGML_METAL_USE_BF16=ON","shared":"OFF","static":"true"},
+            {"build":"arm64","runner":"macos-26",      "expect_arch":"arm64", "deploy_target":"14.0","accel":"metal","backend":"metal","defines":"-DGGML_METAL=ON -DGGML_METAL_EMBED_LIBRARY=ON -DGGML_METAL_USE_BF16=ON","shared":"OFF","static":"true"},

Document accepted audio formats (optional)

The prebuilts decode WAV, MP3, FLAC and Ogg Vorbis; Ogg/WebM Opus (browser recordings, WhatsApp/Telegram voice notes) returns HTTP 400. Studio is unaffected since it decodes with PyAV and posts WAV. I would not enable WHISPER_COMMON_FFMPEG (formerly WHISPER_FFMPEG) for this. It drags libav shared libs into the portable bundles, and the server's in-memory read path does not use it anyway (only the file-path overload does). Suggested addition to UNSLOTH_PREBUILT_README.md near the asset docs.

+### Accepted audio formats (`/inference`)
+
+Bundles decode WAV, MP3, FLAC and Ogg Vorbis (miniaudio + stb_vorbis). Ogg/WebM
+Opus (browser `MediaRecorder`, WhatsApp/Telegram voice notes) is not decodable
+and returns HTTP 400; transcode first:
+`ffmpeg -i in.opus -ar 16000 -ac 1 out.wav`.

…apshot process liveness

- The model dictation adapter sent the raw setting (the literal "auto") to the
  backend, while the browser engine resolves Auto via resolveDictationLanguage.
  A batch of non-English voice notes came back mostly English on Auto. Add
  resolveModelDictationLanguage: only the literal "auto" is resolved to a
  concrete locale, gated so it becomes a language the model AND Whisper can
  honor (mirroring the backend's known-whisper-languages set); an explicit
  language, or a locale Whisper cannot honor, stays unchanged/auto-detect. Wire
  it into both adapter call sites.
- GgmlSttSidecar._process_alive() read self._process twice; a concurrent
  unload() nulls it under the lock while loaded_model/device read lock-free, so
  a null between the two reads called None.poll(). Snapshot once. Adds a
  deterministic regression test.
Resolve conflicts with the model picker v2 and settings archived-chats
refactor: keep dictation branching in the composer while adopting the
always-expanded tool row and disableQueue semantics from main, keep the
archived-chats pagination on top of the inline ArchivedChatsView, merge
the hub export list (cancelStagedModelDownload is gone with the v2
runtime), and union the hidden-model matchers (STT repos plus the
dynamic embedder matchers).
@danielhanchen

Copy link
Copy Markdown
Member

Thanks for the thorough pass, this was genuinely useful.

Status of each item:

  • Auto dictation language: applied in 069096e, including the Whisper language-set guard and the .en custom checkpoint carve-out you suggested. Auto now resolves through resolveModelDictationLanguage on both the send path and the session snapshot.
  • _process_alive double read: applied in the same commit (snapshot self._process once). Agreed it is GIL-luck rather than a live bug; embed_llama_server.py gets the same one-liner in a later sweep.
  • Opus via PyAV: matches our testing, nothing to change.
  • whisper.cpp fork CI: the macOS minos gate now asserts (and the same gate rode into the new slim workflow), the validate_bundle.py --gpu hang is fixed with terminate plus communicate(timeout), the README fingerprint wording is corrected to BUILD_INFO.txt, and the accepted-audio-formats section is in. The schedule clause point is now moot in the other direction: the orchestrator gained a real cron schedule, so the schedule disjunct on the publish gates is live rather than dead.
  • One structural update since your review: releases are now slim-only. Each whisper bundle ships just whisper-server plus libwhisper (under 0.7 MB) built against the paired unslothai/llama.cpp release ggml, and the installer hardlinks the llama ggml runtime (plus libomp140.aarch64.dll on Windows ARM) next to the binary. The per-accelerator fat bundles you tested against remain only for pinned pre-slim releases, so the CUDA/Vulkan fat-bundle paths are effectively retired going forward. Validated end to end on all 20 standard GitHub-hosted runner labels plus local GPU runs.

The Browser engine re-check off localhost is still on the list.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 92be236e75

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

…ng paths

Address review findings on the STT dictation feature:

- build_whisper_cpp.sh refuses to delete a whisper.cpp tree under a custom
  Studio home unless it carries the Studio ownership marker, matching the
  setup.sh policy, and marks trees it creates
- _snapshot_is_complete validates every shard of a sharded PyTorch
  (pytorch_model.bin.index.json) checkpoint like the safetensors path, and
  requires tokenizer assets (tokenizer.json or vocab.json + merges.txt)
- custom-repo downloads pin the revision resolved at validation time and
  restrict snapshot_download to the model/tokenizer/config/preprocessor file
  classes Studio loads
- the GGML sidecar holds its port reservation until just before spawning
  whisper-server and only accepts readiness from a responder that both looks
  like whisper.cpp's server and belongs to the still-running managed child,
  probing twice, so mic audio cannot be posted to a foreign local process
- the recording adapter transcribes every non-empty segment; the RMS meter
  only shapes segment boundaries and can no longer discard quiet speech
- Compare-pane dictation can cancel a pending transcription on second click,
  with the button relabeled while finalizing
- localStorage quota recovery halves the dictation history until the save
  fits, so small histories shrink too
- the System default TTS voice resolves to the platform default voice
- new dictation UI imports go through the chat and hub feature barrels

Regression tests cover the build-script gate, sharded PyTorch and tokenizer
completeness, revision pinning and allow patterns, and the whisper-server
readiness probe.
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 8d1a01cfa6

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

@oobabooga

Copy link
Copy Markdown
Member

The following follow-up changes were made in 1bd29b6fe8:

  • Custom Hugging Face speech-to-text models are now resolved to an immutable commit SHA before download. Studio records that revision and reloads the same snapshot after a restart, including in offline mode or after relocating the Hugging Face cache.
  • Download selection now requires a complete supported checkpoint, rejects adapter-only repositories, downloads only the selected safetensors or PyTorch format, and reports progress against the exact files being downloaded.
  • Validation, download, and loading now use the same pinned revision and local snapshot path, avoiding later requests to a moving branch such as main.
  • Mouse-wheel scrolling is handled by one shared hook and now works consistently in both the model combobox and the Voice picker.
  • Voice picker state and lint issues were cleaned up, test isolation was tightened, and the stale thread test stub was corrected.
  • Live testing used an empty cache with openai/whisper-tiny.en, verified the exact pinned SHA and byte count, transcribed the JFK sample correctly, then restarted in fully offline mode and transcribed it again without requesting main.
  • Playwright testing verified real mouse-wheel scrolling in the Voice picker. The focused backend suite passed 172 tests, and frontend type checking, ESLint, i18n validation, and the production build all passed.

@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 053c5988b9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

danielhanchen and others added 2 commits July 23, 2026 01:30
…lim bundles paired to the llama prebuilt (#7294)

* Studio STT: add prebuilt whisper.cpp (whisper-server) installer

New install_whisper_prebuilt.py downloads a per-platform whisper-server
bundle published by the unslothai/whisper.cpp prebuilt CI into the managed
whisper.cpp dir (build/bin/whisper-server) so local dictation needs no
compiler. Mirrors install_node_prebuilt.py / install_llama_prebuilt.py:
host + backend detection, sha256 pins (whisper_prebuilt_pins.json) as the
trust anchor, staging + install lock + atomic swap, traversal-safe extract,
co-located shared libs (RUNPATH=$ORIGIN), an UNSLOTH_WHISPER_PREBUILT_INFO.json
marker with idempotent "already matches", and exit codes 0/1/2/3. Not wired
into setup yet; the pins ship empty so every asset fails closed until the
first fork release is published and its digests are reviewed in.

* Studio STT: install prebuilt whisper.cpp during setup and update

Add a fail-open whisper.cpp block to setup.sh after the llama.cpp section so
`unsloth studio update` (and a fresh install) fetch the prebuilt whisper-server
into the managed whisper.cpp dir the sidecar discovers. It skips a user-set
WHISPER_SERVER_PATH/UNSLOTH_WHISPER_CPP_PATH, honors UNSLOTH_SKIP_WHISPER_INSTALL,
forwards the resolved ROCm gfx, and never aborts setup: a busy install keeps the
existing runtime, and an unavailable prebuilt stays quiet (source build is opt-in
via UNSLOTH_WHISPER_FORCE_COMPILE) since Transformers STT and browser dictation
remain. Register UNSLOTH_WHISPER_PREBUILT_INFO.json as Studio-owned evidence.

* Studio STT: harden whisper-server child env + WSL ROCm detection

- Sidecar spawns whisper-server with a scrubbed child env that prepends the
  binary dir (co-located GPU libs) to the loader path, and on WSL2 ROCm loads
  the system HIP first (HSA_ENABLE_DXG_DETECTION=1) so a bundle's bare-metal HIP
  does not segfault on /dev/dxg. Secret-bearing vars are dropped from the child.
- find_whisper_server_binary now requires an executable, not just a file.
- Installer rocm probe passes HSA_ENABLE_DXG_DETECTION and falls back to
  /opt/rocm/bin/rocminfo so a WSL ROCm host is not misdetected as CPU-only;
  gfx parsing skips the gfx000 CPU agent and generic ISA lines.
- Tests for the child env (secret scrub, lib dir, WSL HIP precedence), the
  executable check, and the WSL rocm detection.

* Studio STT: in-app whisper.cpp prebuilt update stack + ship pins in the wheel

Mirror the llama.cpp update stack for the whisper.cpp prebuilt so Studio can
detect and install a newer whisper-server release from inside the app:
- backend/utils/whisper_cpp_freshness.py: read UNSLOTH_WHISPER_PREBUILT_INFO.json
  and compare the installed release against the newest unslothai/whisper.cpp
  release. Whisper tags are v<upstream>-unsloth.<N>, so is_behind compares a
  (major, minor, patch, serial) key with a strict downgrade guard; 24h cache;
  fail-open.
- backend/utils/whisper_cpp_update.py: run install_whisper_prebuilt.py to fetch
  and atomically swap the newest bundle, unloading the warm GGUF sidecar first.
- backend/routes/whisper.py mounted at /api/whisper (update-status + update).
- pyproject: add whisper_prebuilt_pins.json to studio package-data so the
  installer's trust anchor ships in the wheel (it is a data file, not a .py
  module, so package discovery alone does not include it; node_prebuilt_pins.json
  is listed for the same reason). Without this a pip-installed wheel had no pins
  and the prebuilt install aborted to Transformers STT.
Adds test_whisper_cpp_freshness.py (version parser, is_behind matrix + downgrade
guard, marker layouts, stale decision, fail-open).

* Studio STT: verify whisper prebuilts via the release checksum index, like llama.cpp

Re-align the whisper.cpp prebuilt installer to install_llama_prebuilt.py's trust
model: instead of a committed whisper_prebuilt_pins.json, verify every download
against the release's own whisper-prebuilt-sha256.json checksum index, fetched
from the same GitHub release.

- parse_release_checksums / fetch_release_checksums / expected_sha256_for replace
  the pins layer. The index is validated for schema/component and that its
  release_tag matches the resolved release; an asset absent from it, a release
  that does not publish it, or a manifest sha256 that disagrees with it all fail
  closed to a source build.
- resolve_release_tag now resolves the newest published release at runtime (or an
  explicit --published-release-tag), matching llama and the freshness check;
  removed the pinned-default and the UNSLOTH_WHISPER_ALLOW_UNVERIFIED opt-in.
- Delete studio/whisper_prebuilt_pins.json and drop its pyproject package-data
  entry (nothing to ship now, same as llama which has no committed pins).
- Adds test_install_whisper_prebuilt_checksums.py (index parser, fail-closed on
  uncovered asset, tampered-manifest guard, newest-release resolution).

This is a same-origin checksum (integrity, not authenticity), identical to the
llama.cpp installer; pair releases with GitHub artifact attestations for provenance.

* Resolve whisper prebuilt release via the download host (no GitHub API)

Mirror install_llama_prebuilt.py's fast path: resolve the release tag from
the releases/latest redirect and fetch the manifest + checksum index from
constructed releases/download URLs, so the common install path makes zero
api.github.com calls (unauthenticated api.github.com is capped at 60 req/hour
per IP; the download host is not). Fall back to the GitHub API only on a 404,
malformed asset, or tag mismatch.

* Studio STT: coverage-aware whisper prebuilt selection via a shared core

whisper's select_artifact returned the first os/arch/backend manifest match and
ignored the SM-coverage fields the release manifest already carries, so a
Blackwell B200 (sm_100) was served cuda12-legacy (sms 50-61) -- runnable only via
forward PTX JIT. install_llama_prebuilt.py on the same host correctly picks
cuda13-newer.

Extract the coverage-aware selection into a shared, component-agnostic core under
studio/backend/utils/prebuilt/ (selection + GPU host-capability detection), lifted
from llama's linux_cuda_choice_from_release / _artifact_covers_sms / _sm_range and
generalised over a normalised artifact. whisper's HostInfo now records the GPU
compute caps + driver CUDA version (honoring CUDA_VISIBLE_DEVICES), and
select_artifact routes CUDA/ROCm through the shared selector: every visible SM
must be covered, the tightest-covering profile wins (Blackwell-aware runtime-line
ordering), ROCm matches the gfx target exactly, and an uncovered GPU falls back to
the CPU bundle. CPU/Metal/Vulkan keep first-match. The resolver JSON, exit codes,
and "already matches" contract are unchanged.

On the B200 the installer now resolves cuda13-newer, matching llama.

* Studio STT: gate whisper CUDA selection on the on-disk runtime, like llama

The prebuilt CUDA bundles are dynamically linked and intentionally do NOT ship
libcudart/libcublas -- they load the same runtime the host already has. So the
driver's advertised CUDA version is only an upper bound: a cuda13 bundle still
needs cuda13 runtime libraries present on disk. Port llama's on-disk runtime
scan (detected_linux_runtime_lines / detected_windows_runtime_lines) into the
shared core and intersect it with the driver-compatible lines in
select_cuda_attempts. A host with a cuda13 driver but only cuda12 runtime (e.g.
torch-cuda12) now correctly gets a cuda12 bundle instead of an unloadable cuda13
one; a host with no CUDA runtime at all falls back to CPU.

Fixes a glob bug in the port (any(Path(d).glob(p) for d in dirs) tests generator
truthiness, not a match) that made every major report present; add a real
filesystem test that exercises the scan.

* studio: harden shared prebuilt core to full llama parity

Apply the review findings on the shared coverage-aware prebuilt-consumer
core so whisper.cpp selection is exactly equivalent to the llama.cpp path.

hosts.py: port llama's CUDA_VISIBLE_DEVICES handling. A GPU hidden by an
index/UUID selector now reports has_usable_nvidia False instead of staying
usable, via supports_explicit_visible_device_matching plus the physical /
explicit-match branches, and _select_visible_rows now matches rows the way
llama does (index or UUID, gpu- prefix optional) and skips unmatched tokens
rather than keeping all rows. Adds the Linux /proc/driver/nvidia/gpus
fallback and has_physical_nvidia. Adds parse_macos_version.

runtime_libs.py: the Linux on-disk scan now requires the exact libcudart /
libcublas SONAME (libcudart.so.13), not a libcudart.so.13* glob, so a bare
versioned file without the SONAME symlink no longer counts as loadable.
Hardens the ldconfig parse against an empty left-hand side.

selection.py: fix the Blackwell/torch reordering so it keys on the covering
runtime lines (falls through to the torch preference when the covering lines
were filtered out), matching linux_cuda_choice_from_release. Corrects the
compatible_runtime_lines_for_driver docstring: the bundles do not ship the
CUDA runtime, so the driver version is only an upper bound and the caller
must intersect with the on-disk scan.

install_whisper_prebuilt.py: enforce a macOS artifact's min_os (new
HostInfo.macos_version) so a bundle that cannot load on the host OS version
is dropped. Keep resolver stdout to only the JSON line by leaving logs on
stderr in --resolve-prebuilt mode, and map an unexpected probe failure to
prebuilt_available False instead of a traceback.

Tests: new host-probe suite for the visible-device logic, exact-SONAME
runtime-scan cases, macOS min_os filtering, resolver stdout-only-JSON,
exit-code mapping, and the repo key.

* studio: fix whisper prebuilt selection + launch parity gaps from review

A parallel review surfaced integration defects where the whisper path could
select or launch a bundle that cannot run on a concrete host. Each is fixed to
match install_llama_prebuilt.py.

macOS min_os: the manifest labels macOS requirements as macos-<version>
(e.g. macos-14.0), which the version parser could not read, so the guard was a
no-op and a macOS-13 host would install the macos-14 Metal bundle. Strip the
platform prefix before parsing.

ROCm gfx detection: _detect_rocm_gfx returned the first gfx token and ignored
HIP_VISIBLE_DEVICES / ROCR_VISIBLE_DEVICES / CUDA_VISIBLE_DEVICES. Since exact
ROCm matching treats that token as the active GPU, a mixed APU + dGPU host
(gfx1151 + gfx1100) with HIP_VISIBLE_DEVICES=1 installed the wrong archive. Route
through a shared pick_rocm_gfx_target (lifted from llama) that parses per-GPU
sections and honors the visibility vars (empty / -1 -> no AMD GPU).

--rocm-gfx override: recording the arch without setting has_rocm left the host on
its CUDA/CPU path so the ROCm bundle was never picked. --rocm-gfx now implies
has_rocm and clears NVIDIA state, like llama's _apply_host_overrides.

CUDA launch env: a CUDA bundle ships the ggml CUDA backend but not
libcudart/libcublas, and the sidecar launch env exposed only the bundle dir, so
on a host whose CUDA runtime lives only in the PyTorch wheels the selection would
gate cuda usable but the server could not load it. Add the CUDA-from-PyTorch
runtime dirs to the child loader path for CUDA bundles (bundle dir still first),
mirroring binary_env.

Also normalize a manifest artifact's supported_sms defensively (parity with
llama's parser) and document that blackwell_min_toolkit_for_caps is retained for
the Phase B llama Windows path.

Not changed (verified parity, not defects): Linux/Windows min_os is enforced
nowhere in llama (macOS only); the resolver is optimistic about the checksum
index and the install path verifies.

* studio: tighten prebuilt-core code comments

* studio: lift shared prebuilt installer core out of the whisper installer

* studio: reuse the llama.cpp prebuilt installer machinery for whisper

* studio: unify llama and whisper prebuilt installers on a shared descriptor core

* studio: consolidate prebuilt installer tests into the shared core suite

Grow tests/studio/install/test_prebuilt_core.py from 62 to 164 tests so every
component-agnostic behavior runs against both descriptors: the full seven
profile CUDA release matrix (multi-GPU, on-disk runtime gating, shuffle
stability, missing SM metadata, dotted SM normalization, no-driver fallback
policy), the ROCm gfx family matrix, macOS min_os gating and its helper,
backend resolution incl. cpu-fallback precedence and Intel-mac auto detect,
checksum-index non-object and plain-lookup cases, the tar symlink/hardlink
extraction guards moved from the llama suite, and the compute-cap, visible
device, runtime-line and Blackwell helper value tables moved verbatim from
the llama characterization suites.

Delete only tests whose exact behavior the master now asserts for the same
component: 40 pure-alias helper cases in test_selection_logic.py (replaced by
value-identical master tables plus an alias-identity pin), 6 extraction moves
and the master-absorbed zip-symlink case in the llama logic suite, 3 routing
twins in test_rocm_support.py already pinned byte-for-byte in
test_selection_logic.py, the 2 Blackwell helper tables in the backend resolve
suite, 28 whisper logic tests and 10 whisper checksum tests re-asserted by
the master whisper parameterization. Wrapper wiring pins, the llama release
plan dialect, fingerprints and every llama-only behavior stay untouched.

* studio: dedupe sidecar and update helpers into the backend prebuilt package

* studio: chain whisper.cpp prebuilt updates onto the llama.cpp update flow

* studio: consume paired slim whisper prebuilts via the llama ggml runtime

* studio: serve every whisper backend from slim prebuilts

* studio: drop the whisper fat per-accelerator selection chain

unslothai/whisper.cpp releases are slim-only from v1.9.1-unsloth.2: one
ggml-less bundle per os/arch, paired to the llama.cpp prebuilt that provides
every ggml backend. Delete the whisper-side fat CUDA/ROCm/metal/vulkan
selection glue; keep slim selection + pairing, link_ggml_runtime, and one
legacy shape, the published fat CPU bundle of an explicitly pinned pre-slim
release. Exit 2 now reads as prebuilt unavailable (whisper never source
builds); setup already treats it that way.

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

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

* Wire libomp runtime DLL alongside ggml in slim whisper installs

llama's clang-built windows-arm64 ggml-base.dll imports
libomp140.aarch64.dll, shipped in the llama bundle but not a system DLL.
Without it next to whisper-server.exe the loader fails with
STATUS_DLL_NOT_FOUND before main. MSVC x64 links vcomp140.dll from
System32 and Linux ggml uses system libgomp.so.1, so only windows-arm64
was affected. The empty-runtime guard still requires a real ggml
library; libomp alone is not a pairing.

* studio: drop whisper-side fat-selection support structure

Slim whisper bundles are selected per os/arch only; all accelerator
capability comes from the installed llama.cpp prebuilt, whose installer
already did the coverage-aware selection. Remove the machinery that only
existed to pick among fat per-accelerator whisper bundles:

- prebuilt_core: delete the generic CUDA/ROCm coverage selection
  (select_cuda_artifact, select_rocm_artifact, ArtifactView adapters,
  detected_cuda_runtime_lines, the exact-SONAME linux probe) that no
  shipped component routes through; llama keeps its own selection chain
  and whisper shadows select_artifact with the slim-only version.
  select_artifact is now a plain os/arch/backend first-match.
- install_whisper_prebuilt: drop the HostInfo CUDA fields
  (compute_caps, driver_cuda_version, torch_runtime_line) and the torch
  runtime probe that populated them; nothing reachable reads them, and
  the resolver payload sources runtime_line from the artifact.
- whisper_cpp_update: delete the standalone start_update job worker;
  whisper applies only run as the chained phase of the combined
  llama+whisper update. The status payload keeps its job field (idle).
- routes/whisper: drop the progress logger that could never fire.
- tests: remove tests of the deleted paths and tests duplicating the
  descriptor-parameterized core suite or the llama freshness suite.

Contracts unchanged: resolver JSON keys, exit codes, marker fields,
pairing logs, and the pinned pre-slim fat CPU escape hatch.

* Address review feedback on the whisper prebuilt update and install paths

- Pin the chained whisper phase to the release the freshness check
  offered, so the download-host latest pointer cannot reinstall an
  older build in a loop
- Wire the whisper prebuilt install into setup.ps1 (Windows setup
  previously skipped it entirely)
- Treat a non-executable server or missing wired ggml libraries as a
  broken install instead of reporting already matches
- Keep whisper sidecar reloads out of the job-level reload flag and
  resync chat state after a partial chained update that unloaded llama
- Repoint home and profile vars for the whisper-server subprocess at a
  managed scratch dir and drop credential-store pointers
- Clear the prebuilt marker before the opt-in source build overwrite
- Write the prebuilt marker with explicit utf-8 encoding

* Tighten comments in the whisper prebuilt consumer

* Harden the Windows whisper setup phase and the chained update edges

- setup.ps1: honor WHISPER_SERVER_PATH / UNSLOTH_WHISPER_CPP_PATH /
  UNSLOTH_SKIP_WHISPER_INSTALL, run the custom-home ownership guard
  before the atomic install, and forward the release-tag pin and ROCm
  hints like setup.sh
- sidecar: a cpu-selected install launches whisper-server with --no-gpu
  (slim wiring links every llama backend, so the flag is what keeps a
  deliberate CPU choice off the GPU)
- chained update: leave whisper unpinned on macOS (the llama phase can
  walk back there, and a newest-tag pin could be an impossible pairing
  on every retry) and treat installer exit 2 as kept-existing-runtime
  instead of failing the combined job
- job.to_tag now comes only from the llama phase, so a whisper-only
  round cannot report a llama update that never ran

* Fix slim whisper runtime follow-ups

* Address remaining whisper update reviews

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

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

* Address remaining prebuilt update reviews

* Fix remaining chained update reviews

* Fix remaining whisper runtime review edges

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

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

---------

Co-authored-by: danielhanchen <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: oobabooga <[email protected]>
@danielhanchen
danielhanchen merged commit d5cf96d into main Jul 23, 2026
4 checks passed
@danielhanchen
danielhanchen deleted the studio-stt-dictation branch July 23, 2026 08:39
danielhanchen pushed a commit that referenced this pull request Jul 24, 2026
Reconcile PR #7256 (Windows torch 2.11 + release preservation, installer
comment reduction, torch 2.11 default line) with 77 commits of main install
rewrites. Base is main's newer install semantics; this branch's still-novel
contributions are layered on top.

Key decisions:
- install.ps1: kept main's rollback lifecycle (try/finally Restore-StudioVenvRollback,
  #7342) and the installed-version report (#7265); layered this branch's torch-2.11
  allowance (torch<2.12.0 on the Windows CUDA fresh-install, CPU fallback and flavor
  repairs), the release-preservation port (Get-InstalledTorchVersionRaw / kept-release
  installs / UNSLOTH_KEPT_TORCH handoff / torch-overrides freeze) and the Exit-InstallFailure
  UNSLOTH_KEPT_TORCH clear.
- install.sh: took main's newer AMD/Strix routing (per-arch index reroute #7264/#7300,
  runtime-less gfx inference #7305, KFD detection fix #7314, Radeon 8065S regex #7290,
  signal-restore trap #7342) and the #7365 unsloth pin bump; kept this branch's
  _TORCH_CEILING/_TORCHVISION_CEILING/_TORCHAUDIO_CEILING refactor widening the default
  ceiling to torch<2.12.0.
- studio/install_python_stack.py: deferred all five code conflicts to main's Strix
  inference logic (result is AST-identical to main; only comment reductions remain).
- studio/setup.ps1: took main's comment covering the whisper.cpp dictation markers
  (#7095); the UNSLOTH_KEPT_TORCH consumption handoff auto-merged intact.

Dropped as superseded by main: this branch's stale unsloth>=2026.7.4 pins (main #7365),
the older rocm7.1->rocm7.2 Strix reroute (main #7264/#7300), the narrow Radeon 80[0-9]0S
regex (main #7290), and the pre-inference has_hip_torch gate (main's rocm_torch_ready gate,
Codex P1 #7305). The two review-item fixes (grep -E in test_torch_constraint.sh,
UNSLOTH_KEPT_TORCH clear in Exit-InstallFailure) survive.
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.

3 participants