From 707046237c42fe6c3c6b10c03c261321d8229105 Mon Sep 17 00:00:00 2001 From: James Pine Date: Wed, 18 Mar 2026 17:01:12 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20complete=20Intel=20XPU=20support=20?= =?UTF-8?q?=E2=80=94=20device-aware=20seeding,=20GPU=20status=20reporting,?= =?UTF-8?q?=20and=20setup=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address CodeRabbit review feedback and user-reported GPU acceleration failure: - Use shared manual_seed() in chatterbox, chatterbox_turbo, and luxtts backends so XPU (and future accelerators) get proper device seeding - Add XPU branch to _get_gpu_status() so startup log reports Intel Arc GPUs instead of 'None (CPU only)' - Add XPU VRAM reporting and correct backend_variant fallback in the /health endpoint - Switch justfile GPU detection from Get-WmiObject to Get-CimInstance, simplify the Arc regex to match 'Arc' (not 'Intel.*Arc'), log detected GPUs, and print manual install instructions on miss Resolves the root cause where IPEX was silently not installed due to WMI detection failure, causing CPU-only fallback on Intel Arc systems. --- backend/app.py | 14 ++++++++++++++ backend/backends/chatterbox_backend.py | 3 ++- backend/backends/chatterbox_turbo_backend.py | 3 ++- backend/backends/luxtts_backend.py | 7 ++----- backend/routes/health.py | 10 +++++++++- justfile | 11 +++++++++-- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/backend/app.py b/backend/app.py index f652d149..1293460a 100644 --- a/backend/app.py +++ b/backend/app.py @@ -155,6 +155,20 @@ def _get_gpu_status() -> str: return "MPS (Apple Silicon)" elif backend_type == "mlx": return "Metal (Apple Silicon via MLX)" + + # Intel XPU (Arc / Data Center) via IPEX + try: + import intel_extension_for_pytorch # noqa: F401 + + if hasattr(torch, "xpu") and torch.xpu.is_available(): + try: + xpu_name = torch.xpu.get_device_name(0) + except Exception: + xpu_name = "Intel GPU" + return f"XPU ({xpu_name})" + except ImportError: + pass + return "None (CPU only)" diff --git a/backend/backends/chatterbox_backend.py b/backend/backends/chatterbox_backend.py index 9b061bb1..e7a025b3 100644 --- a/backend/backends/chatterbox_backend.py +++ b/backend/backends/chatterbox_backend.py @@ -19,6 +19,7 @@ from .base import ( is_model_cached, get_torch_device, empty_device_cache, + manual_seed, combine_voice_prompts as _combine_voice_prompts, model_load_progress, patch_chatterbox_f32, @@ -198,7 +199,7 @@ class ChatterboxTTSBackend: import torch if seed is not None: - torch.manual_seed(seed) + manual_seed(seed, self._device) logger.info(f"[Chatterbox] Generating: lang={language}") diff --git a/backend/backends/chatterbox_turbo_backend.py b/backend/backends/chatterbox_turbo_backend.py index fcdbf39e..6f7d6b94 100644 --- a/backend/backends/chatterbox_turbo_backend.py +++ b/backend/backends/chatterbox_turbo_backend.py @@ -19,6 +19,7 @@ from .base import ( is_model_cached, get_torch_device, empty_device_cache, + manual_seed, combine_voice_prompts as _combine_voice_prompts, model_load_progress, patch_chatterbox_f32, @@ -179,7 +180,7 @@ class ChatterboxTurboTTSBackend: import torch if seed is not None: - torch.manual_seed(seed) + manual_seed(seed, self._device) logger.info("[Chatterbox Turbo] Generating (English)") diff --git a/backend/backends/luxtts_backend.py b/backend/backends/luxtts_backend.py index 6f88fa3e..7f15686a 100644 --- a/backend/backends/luxtts_backend.py +++ b/backend/backends/luxtts_backend.py @@ -16,6 +16,7 @@ from .base import ( is_model_cached, get_torch_device, empty_device_cache, + manual_seed, combine_voice_prompts as _combine_voice_prompts, model_load_progress, ) @@ -163,12 +164,8 @@ class LuxTTSBackend: await self.load_model() def _generate_sync(): - import torch - if seed is not None: - torch.manual_seed(seed) - if torch.cuda.is_available(): - torch.cuda.manual_seed(seed) + manual_seed(seed, self.device) wav = self.model.generate_speech( text=text, diff --git a/backend/routes/health.py b/backend/routes/health.py index f138e336..66cc9b62 100644 --- a/backend/routes/health.py +++ b/backend/routes/health.py @@ -110,6 +110,11 @@ async def health(): vram_used = None if has_cuda: vram_used = torch.cuda.memory_allocated() / 1024 / 1024 + elif has_xpu: + try: + vram_used = torch.xpu.memory_allocated() / 1024 / 1024 + except Exception: + pass # memory_allocated() may not be available on all IPEX versions model_loaded = False model_size = None @@ -162,7 +167,10 @@ async def health(): gpu_type=gpu_type, vram_used_mb=vram_used, backend_type=backend_type, - backend_variant=os.environ.get("VOICEBOX_BACKEND_VARIANT", "cuda" if torch.cuda.is_available() else "cpu"), + backend_variant=os.environ.get( + "VOICEBOX_BACKEND_VARIANT", + "cuda" if torch.cuda.is_available() else ("xpu" if has_xpu else "cpu"), + ), ) diff --git a/justfile b/justfile index 1bddbf69..b17243fb 100644 --- a/justfile +++ b/justfile @@ -69,8 +69,10 @@ setup-python: } Write-Host "Installing Python dependencies..." & "{{ python }}" -m pip install --upgrade pip -q - $hasNvidia = $null -ne (Get-WmiObject Win32_VideoController | Where-Object { $_.Name -match 'NVIDIA' }) - $hasIntelArc = $null -ne (Get-WmiObject Win32_VideoController | Where-Object { $_.Name -match 'Intel.*Arc' }) + $gpus = Get-CimInstance Win32_VideoController | Select-Object -ExpandProperty Name + Write-Host "Detected GPUs: $($gpus -join ', ')" + $hasNvidia = ($gpus | Where-Object { $_ -match 'NVIDIA' }).Count -gt 0 + $hasIntelArc = ($gpus | Where-Object { $_ -match 'Arc' }).Count -gt 0 if ($hasNvidia) { \ Write-Host "NVIDIA GPU detected — installing PyTorch with CUDA support..."; \ & "{{ pip }}" install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128; \ @@ -78,6 +80,11 @@ setup-python: Write-Host "Intel Arc GPU detected — installing PyTorch with XPU support..."; \ & "{{ pip }}" install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu; \ & "{{ pip }}" install intel-extension-for-pytorch --index-url https://download.pytorch.org/whl/xpu; \ + } else { \ + Write-Host "No NVIDIA or Intel Arc GPU detected — using CPU-only PyTorch."; \ + Write-Host "If you have an Intel Arc GPU, install XPU support manually:"; \ + Write-Host " pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu"; \ + Write-Host " pip install intel-extension-for-pytorch --index-url https://download.pytorch.org/whl/xpu"; \ } & "{{ pip }}" install -r {{ backend_dir }}/requirements.txt & "{{ pip }}" install --no-deps chatterbox-tts