fix: avoid local STT crash on Apple Silicon - #28624
Conversation
austinpickett
left a comment
There was a problem hiding this comment.
use PULL_REQUEST_TEMPLATE.md
There was a problem hiding this comment.
Pull request overview
This PR mitigates hard-crash failures in the gateway’s local STT (faster-whisper / ctranslate2) path on macOS Apple Silicon—especially when running under Rosetta—by avoiding native device="auto" autodetection and working around Intel OpenMP duplicate-runtime aborts.
Changes:
- Add macOS/Rosetta detection and force faster-whisper to load on CPU with
compute_type="int8"on affected hosts. - Set
KMP_DUPLICATE_LIB_OKprior to importingfaster_whisperon the affected path to reduce import-time abort risk. - Adjust the
voiceextra’s NumPy requirement from a strict NumPy 2.x pin tonumpy<2, and add targeted regression tests around the new CPU-forcing behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/transcription_tools.py | Adds Apple Silicon/Rosetta detection and forces CPU/int8 model loading; sets KMP_DUPLICATE_LIB_OK before importing faster-whisper on the affected path. |
| tests/tools/test_transcription_tools.py | Adds regression tests for the CPU-forcing behavior and Rosetta detection; updates existing CUDA fallback tests to explicitly disable the new force-CPU path. |
| pyproject.toml | Relaxes voice extra NumPy constraint to numpy<2 to avoid NumPy 2.x compatibility warnings with the STT stack. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def test_apple_silicon_forces_cpu_without_auto_probe(self, tmp_path): | ||
| """Apple Silicon/Rosetta should skip device='auto' to avoid SIGABRT.""" | ||
| audio = tmp_path / "test.ogg" | ||
| audio.write_bytes(b"fake") | ||
|
|
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused fix. The premise still holds on current main: tools/transcription_tools.py:1101-1103 imports faster_whisper and calls WhisperModel(..., device="auto", compute_type="auto"), which matches the crash path described in #28622.
Problems
- The dependency-pin change is incomplete for Hermes' actual install paths. pyproject.toml's voice extra is one path, but local STT is also lazy-installed via tools/lazy_deps.py:110-114, and that still pins numpy==2.4.3 on current main.
- The pyproject.toml hunk is stale against current main:
gh pr diff 28624 --patch | git apply --check --verbose -fails only for pyproject.toml, while the transcription code and tests apply with offsets.
Suggested changes
- Update tools/lazy_deps.py:110-114 to match the NumPy constraint chosen for the voice extra, so gateway lazy installs get the same fix.
- Resolve the pyproject.toml optional-dependency conflict against current main's voice block at pyproject.toml:148-154, and update lock metadata if maintainers require uv.lock to track optional-dependency specifiers.
Automated hermes-sweeper review.
| "numpy==2.4.3", | ||
| "numpy<2", | ||
| ] | ||
| pty = [ |
There was a problem hiding this comment.
This relaxes the voice extra, but local STT is also installed through the lazy dependency table on current main (tools/lazy_deps.py:110-114), which still pins numpy==2.4.3. Please update that sibling install path too so gateway lazy installs receive the same compatibility fix.
|
Thanks for the focused Apple Silicon/Rosetta mitigation. The premise remains present on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
|
Merged into main via consolidated salvage PR #73510 (merge Your contribution is credited to you in git history. Thank you! Closing this PR as merged-via-salvage. |
Force CPU (int8) for faster-whisper on Apple Silicon / Rosetta, where ctranslate2's device=auto path can hard-abort in native code. Salvaged from PR NousResearch#28624 without the numpy pin change (main already moved on). (cherry picked from commit 7edf2d5, pyproject.toml hunk dropped)
Summary
faster-whisperdevice="auto"crashesKMP_DUPLICATE_LIB_OKbefore importingfaster_whisperfor the affected path because the crash can happen during import via duplicate Intel OpenMP runtimes<2because the current NumPy 2.x pin emits compatibility warnings with the installed torch/ctranslate2 stackFixes #28622
Test Plan
python -m pytest tests/tools/test_transcription_tools.py -q -o 'addopts='force_cpu True{'success': True, 'transcript': 'Hello, one, two, three. Can you hear me?', 'provider': 'local'}