Skip to content

Demo: Fix hardcoded CUDA references to support Apple Silicon MPS and fix input_sample_rate#30

Open
kainoj wants to merge 2 commits into
Liquid4All:mainfrom
kainoj:demo-on-apple-silicon
Open

Demo: Fix hardcoded CUDA references to support Apple Silicon MPS and fix input_sample_rate#30
kainoj wants to merge 2 commits into
Liquid4All:mainfrom
kainoj:demo-on-apple-silicon

Conversation

@kainoj
Copy link
Copy Markdown

@kainoj kainoj commented Jun 3, 2026

Summary

  • Auto-detect available device (cuda → mps → cpu) in the demo instead of assuming CUDA
  • Pass the detected device through to all from_pretrained calls and the Mimi warmup loop
  • Work around safetensors not supporting MPS as a direct load target by falling back to CPU load when
    the device is neither cpu nor cuda
  • Replace hardcoded .cuda() on the audio detokenizer with .to(self.device)
  • Fix input_sample_rate from 24_000 to 48_000 to match Chrome's native WebRTC rate — avoids a lossy
    48→24→16kHz double resample before the conformer encoder (which expects 16kHz).
    • This subjectively improved the experience. Before the change the model was replying "sorry i couldn't hear you clearly, could you repeat" etc

Test plan

  • Run liquid-audio-demo on Apple Silicon Mac — should load and run on MPS without errors

kainoj and others added 2 commits June 3, 2026 22:29
Auto-detect available device (cuda → mps → cpu) in the demo and pass it
through to model/processor loading. Work around safetensors not supporting
MPS as a direct load target by loading Mimi weights to CPU first when the
target device is neither cpu nor cuda.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Chrome sends audio at 48kHz over WebRTC. Setting input_sample_rate=24_000
caused a needless 48->24->16kHz double resample before the conformer encoder.
Using 48_000 lets torchaudio resample directly to 16kHz in one step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kainoj kainoj marked this pull request as ready for review June 3, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant