Skip to content

Commit c2ae85b

Browse files
authored
Merge pull request #22 from audiohacking/copilot/fix-decoding-audio-failure-another-one
Fix MPS audio decoding failure with explicit dtype preservation
2 parents c176603 + f148354 commit c2ae85b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

backend/app/services/music_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,9 @@ def _pad_audio_token(token):
804804
progress = int((i + 1) / max_audio_frames * 100)
805805
callback(progress, f"Generating audio... {i + 1}/{max_audio_frames} frames")
806806

807-
frames = torch.stack(frames).permute(1, 2, 0).squeeze(0).cpu() # Move to CPU immediately
807+
# Stack frames and explicitly preserve torch.long dtype (critical for MPS compatibility)
808+
# Explicitly ensure torch.long dtype is preserved (defensive fix for potential MPS backend issues)
809+
frames = torch.stack(frames).permute(1, 2, 0).squeeze(0).to(dtype=torch.long).cpu()
808810

809811
# Sequential offload: Move HeartMuLa to CPU before loading HeartCodec
810812
# This allows fitting on smaller GPUs (12GB) by never having both models in VRAM

0 commit comments

Comments
 (0)