Fix voice model GPU detection and acceleration selection
Summary
Fix voice model runtime so GPU detection works reliably and the model uses GPU acceleration when available.
Problem
Voice model is failing to detect GPU, causing fallback to slower/non-accelerated execution.
Scope
- Audit GPU detection logic and runtime capability checks.
- Validate platform/device-specific detection paths.
- Improve logs for GPU discovery, fallback reason, and selected execution mode.
- Ensure safe fallback to CPU with clear diagnostics when GPU is unavailable.
Acceptance Criteria
- GPU is detected on supported systems and used by voice model.
- Fallback to CPU is explicit, correct, and logged with reason.
- No crashes/regressions across supported platforms.
- Tests/verification steps included for GPU-present and GPU-absent cases.
Refined Scope & Root Cause Analysis
Root Cause
Two compounding issues prevent GPU acceleration for the voice model:
-
whisper-rshas no GPU features enabled —Cargo.tomldeclareswhisper-rs = "0.16"with no features. The crate's internal_gpuflag is never set, soWhisperContextParameters::default()setsuse_gpu: false. On macOS, Metal acceleration is not compiled in. -
GPU detection is disconnected from whisper initialization —
device.rsdetects Apple Silicon (Metal) and populatesDeviceProfile.has_gpu, but this field is only used for model tier recommendation. It is never passed toWhisperContextParametersinwhisper_engine.rs. Even if GPU were detected, the engine wouldn't use it.
Additionally, non-Apple platforms (Windows/Linux) get no GPU detection at all — detect_gpu() returns (false, None) unconditionally.
Refined Scope
Phase 1 (this issue): Focus on a single model with proper GPU detection and acceleration selection:
- Enable
metalfeature for macOS builds (compile whisper.cpp with Metal support) - Thread
DeviceProfileto whisper engine initialization souse_gpu/flash_attnare set based on detected hardware - Expand GPU detection to cover Windows NVIDIA via lightweight
nvidia-smiprobe - Add diagnostic logging for GPU discovery, selected backend, and fallback reason
- Ensure safe CPU fallback with clear diagnostics when GPU is unavailable
Deferred: Multi-model selection UI, CUDA compile-time feature flag, Vulkan support.
Files to Change
| File | What Changes |
|---|---|
Cargo.toml |
Add metal feature for whisper-rs on macOS target |
src/openhuman/local_ai/device.rs |
Expand detect_gpu() — Windows NVIDIA probe, better logging |
src/openhuman/local_ai/service/whisper_engine.rs |
Accept DeviceProfile, configure use_gpu/flash_attn explicitly |
src/openhuman/local_ai/service/bootstrap.rs |
Pass DeviceProfile to whisper engine load |
src/openhuman/local_ai/service/speech.rs |
Pass DeviceProfile through lazy load path |