You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Qwen TTS generation fails 100% with Stream(gpu, 1) not in current thread on Apple Silicon (v0.5.0) #699
The UI stays on "Loading model..." but the SQLite row in voicebox.db is already status=failed. No Python traceback is written to the server log — only the message is captured in the generations.error column.
Reproduction (100% repeatable)
After a clean app start (Ready logged, model loaded), call the API directly:
Polling /generate/{id}/status flips to failed within ~1 second, every time. Confirmed across multiple profiles, languages (zh/en), and short/long inputs.
Likely root cause
mlx_audio/stt/generate.py:224 (and almost certainly similar code on the TTS path):
The stream is created on the main/import thread, but inference runs in a uvicorn worker thread (run_in_executor / asyncio.to_thread). MLX streams are thread-local, so the worker thread sees no Stream(gpu, 1) and raises.
Fix direction: either recreate the stream inside the worker thread, or use mlx.core.new_thread_local_stream (added in MLX 0.31).
Suggested follow-ups
Move mx.new_stream into the worker that actually runs inference, or switch to new_thread_local_stream.
Let the exception traceback through to the server log on generation failure — currently the message is silently captured in SQLite only, which makes the issue look like "model still loading" in the UI.
The backend_variant: cpu while backend_type: mlx and gpu_type: MPS reported by /health looks inconsistent and is worth a sanity check.
Workaround
None found from the user side — backend cannot be switched away from MLX in the bundled build, and the error is raised before any inference happens.
Reproduced 100% on a different chip + newer macOS, which rules out a couple of variables.
Environment
Voicebox v0.5.0 (macOS .app bundle, PyInstaller — same build as the OP, so presumably mlx==0.31.2 / mlx_audio==0.4.1 / qwen_tts==0.1.1; the frozen bundle doesn't expose dist-info to confirm)
curl -s -X POST http://127.0.0.1:17493/generate \
-H 'Content-Type: application/json' \
-d '{"profile_id":"<existing>","text":"hello world","language":"en","engine":"qwen","model_size":"1.7B"}'# POST returns status:"generating", then within ~1s:# GET /generate/{id}/status →# data: {"id":"...","status":"failed","duration":0.0,# "error":"There is no Stream(gpu, 1) in current thread.","source":"manual"}
Cmd-Q + relaunch did not clear it for the generation path (unlike the recoverable dictation banner in #675) — every /generate fails immediately. The thread-local-stream root cause in the OP matches what we see.
Assuming MLX is active: this crash is a thread-affinity issue. mlx_backend.py runs every model load/generate/transcribe call through asyncio.to_thread(), which uses the event loop's default thread pool — nothing guarantees two calls land on the same worker thread. MLX's Metal command encoder/stream is thread-local (bound to whichever thread first touched the GPU device), so if model load and a later generate() end up on different pool threads, MLX raises exactly There is no Stream(gpu, N) in current thread.
Opened #886 with a fix: pins every MLX call to a single dedicated worker thread instead of the shared pool, plus the missing mlx-lm/mlx-audio install step for #823 (and a /health reporting fix while I was in there — backend_variant never had an mlx branch so it always said "cpu"). Verified on M4 hardware: repeated generations with no crash, and Qwen CustomVoice loads/generates successfully post-fix.
Confirming this on Voicebox 0.5.0 (macOS 26.5.1, Apple Silicon / arm64). Same RuntimeError: There is no Stream(gpu, 1) in current thread. — for us it surfaces in dictation refinement, i.e. the Qwen3 LLM backend, not only TTS:
backend/routes/captures.py refine_capture_endpoint
→ backend/services/refinement.py refine_transcript
→ backend/backends/qwen_llm_backend.py _generate_sync (runs via asyncio.to_thread)
→ mlx_lm/generate.py stream_generate → wired_limit → mx.synchronize(s)
RuntimeError: There is no Stream(gpu, 1) in current thread.
Model loads fine (reproduced with mlx-community/Qwen3-4B-4bit) and only fails once generation starts. #909 looks like the targeted fix for this LLM-backend path (it extends #886 to qwen_llm_backend.py). +1 on getting that merged.
Activity
wutijin2 commentedon May 25, 2026
我可能也遇到了类似的情况,模型下载了,也创建好声音了,结果生成不了,我说Windows
davidstrouk commentedon Jun 23, 2026
Reproduced 100% on a different chip + newer macOS, which rules out a couple of variables.
Environment
mlx==0.31.2/mlx_audio==0.4.1/qwen_tts==0.1.1; the frozen bundle doesn't expose dist-info to confirm)Qwen3-TTS-12Hz-1.7B,model_loaded: trueWhat this adds
Repro (identical to OP, 100% repeatable)
Corroborating the OP's follow-up #3
/healthhere shows the same inconsistency —backend_type: mlx+gpu_type: MPS (Apple Silicon)butbackend_variant: cpu:{"status":"healthy","model_loaded":true,"model_downloaded":true,"model_size":"1.7B", "gpu_available":true,"gpu_type":"MPS (Apple Silicon)","vram_used_mb":null, "backend_type":"mlx","backend_variant":"cpu","gpu_compatibility_warning":null}Cmd-Q + relaunch did not clear it for the generation path (unlike the recoverable dictation banner in #675) — every
/generatefails immediately. The thread-local-stream root cause in the OP matches what we see.AlexStephenLytton commentedon Jul 12, 2026
Ran into this exact error on a fresh Apple Silicon (M4) setup and tracked it down. Two things going on:
just setup-pythondoesn't actually installmlx-audio/mlx-lmon Apple Silicon (separate bug, filed as just setup-python doesn't install mlx-audio/mlx-lm — MLX backend fails on fresh Apple Silicon dev setup #823) — worth checking/health'sbackend_typefirst; if it says"pytorch"instead of"mlx", that's why, and this specific crash won't apply to you (you're not on the MLX path at all).Assuming MLX is active: this crash is a thread-affinity issue.
mlx_backend.pyruns every model load/generate/transcribe call throughasyncio.to_thread(), which uses the event loop's default thread pool — nothing guarantees two calls land on the same worker thread. MLX's Metal command encoder/stream is thread-local (bound to whichever thread first touched the GPU device), so if model load and a latergenerate()end up on different pool threads, MLX raises exactlyThere is no Stream(gpu, N) in current thread.Opened #886 with a fix: pins every MLX call to a single dedicated worker thread instead of the shared pool, plus the missing
mlx-lm/mlx-audioinstall step for #823 (and a/healthreporting fix while I was in there —backend_variantnever had anmlxbranch so it always said"cpu"). Verified on M4 hardware: repeated generations with no crash, and Qwen CustomVoice loads/generates successfully post-fix.leighton-tidwell commentedon Jul 19, 2026
Confirming this on Voicebox 0.5.0 (macOS 26.5.1, Apple Silicon / arm64). Same
RuntimeError: There is no Stream(gpu, 1) in current thread.— for us it surfaces in dictation refinement, i.e. the Qwen3 LLM backend, not only TTS:Model loads fine (reproduced with
mlx-community/Qwen3-4B-4bit) and only fails once generation starts. #909 looks like the targeted fix for this LLM-backend path (it extends #886 toqwen_llm_backend.py). +1 on getting that merged.fix(backends): run MLX load and inference on one thread