Skip to content

[Whisper] patch float type on mps#35295

Merged
ArthurZucker merged 2 commits intohuggingface:mainfrom
eustlb:patch-whisper-mps
Dec 16, 2024
Merged

[Whisper] patch float type on mps#35295
ArthurZucker merged 2 commits intohuggingface:mainfrom
eustlb:patch-whisper-mps

Conversation

@eustlb
Copy link
Copy Markdown
Contributor

@eustlb eustlb commented Dec 16, 2024

What does this PR do?

Fixes Vaibhavs10/insanely-fast-whisper#255

#34537 introduced casting to float64, which is not supported on the MPS backend.

@eustlb eustlb requested a review from ArthurZucker December 16, 2024 15:34
Copy link
Copy Markdown
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you including in the patch!

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

ArthurZucker pushed a commit that referenced this pull request Dec 16, 2024
* fix float type on mps

* make
hnshah added a commit to hnshah/insanely-fast-whisper that referenced this pull request Mar 26, 2026
…4.48.0

Fixes Vaibhavs10#255

Problem:
Mac users with Apple Silicon (M1/M2/M3) encounter TypeError when
transformers tries to use float64 dtype, which MPS backend doesn't support:

  TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS
  framework doesn't support float64. Please use float32 instead.

Root cause:
Older versions of transformers (<4.48.0) didn't have MPS-aware dtype
selection in Whisper's timestamp generation code.

Solution:
1. Added FAQ entry documenting the fix and upgrade path
2. Pinned transformers>=4.48.0 to prevent users from hitting this issue

The upstream fix was merged in huggingface/transformers#35295 (Dec 2024),
which added device-aware dtype selection:

  torch.float32 if device.type == "mps" else torch.float64

This ensures Mac users automatically get float32 timestamps while other
platforms continue using float64 for precision.

Impact:
- Unblocks all Mac M1/M2/M3 users
- Prevents new users from encountering the bug
- Documents upgrade path for existing users
- Standard dependency management practice
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.

Mac M1 - multiple issues preventing transcription

3 participants