Skip to content

Commit 7cfa6b8

Browse files
fix: enable MPS for the PyTorch Qwen3-TTS/CustomVoice engines on Apple Silicon
get_torch_device() already supports allow_mps, and other engines (luxtts_backend.py, qwen_llm_backend.py) already pass allow_mps=True — but PyTorchTTSBackend, PyTorchSTTBackend, and QwenCustomVoiceBackend never did, so any Apple Silicon install that ends up on the PyTorch backend (e.g. MLX unavailable, or before this PR's justfile fix) silently ran these three on plain CPU instead of falling back to PyTorch+MPS. This turned out to matter more than expected: benchmarking on M4 hardware, PyTorch+MPS generation (RTF ~1.7x) was faster than this same PR's MLX thread-fix (RTF ~3.4-4.3x) for the same qwen engine and model size, and faster than a CUDA RTX 2080 Ti (RTF ~2.3-3.1x) too. I'm not proposing changing the default backend selection here — one engine, one model size, one machine is not enough data for that, and MLX-Whisper is reportedly faster than PyTorch-CPU for STT — but MPS should clearly be an option rather than silently absent. Verified on M4: PyTorchTTSBackend()._get_device() and QwenCustomVoiceBackend()._get_device() both now return "mps" (were "cpu").
1 parent c82185f commit 7cfa6b8

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

backend/backends/pytorch_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, model_size: str = "1.7B"):
3434

3535
def _get_device(self) -> str:
3636
"""Get the best available device."""
37-
return get_torch_device(allow_xpu=True, allow_directml=True)
37+
return get_torch_device(allow_xpu=True, allow_directml=True, allow_mps=True)
3838

3939
def is_loaded(self) -> bool:
4040
"""Check if model is loaded."""
@@ -256,7 +256,7 @@ def __init__(self, model_size: str = "base"):
256256

257257
def _get_device(self) -> str:
258258
"""Get the best available device."""
259-
return get_torch_device(allow_xpu=True, allow_directml=True)
259+
return get_torch_device(allow_xpu=True, allow_directml=True, allow_mps=True)
260260

261261
def is_loaded(self) -> bool:
262262
"""Check if model is loaded."""

backend/backends/qwen_custom_voice_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, model_size: str = "1.7B"):
6565
self._current_model_size: Optional[str] = None
6666

6767
def _get_device(self) -> str:
68-
return get_torch_device(allow_xpu=True, allow_directml=True)
68+
return get_torch_device(allow_xpu=True, allow_directml=True, allow_mps=True)
6969

7070
def is_loaded(self) -> bool:
7171
return self.model is not None

0 commit comments

Comments
 (0)