Skip to content

[fix] inkling: mps + cuda mel spec extraction - #47432

Merged
ArthurZucker merged 3 commits into
mainfrom
fix-mps-cuda-feature-ex-inklink
Sep 1, 2026
Merged

ArthurZucker merged 3 commits into
mainfrom
fix-mps-cuda-feature-ex-inklink

Conversation

@eustlb

@eustlb eustlb commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

CI

What does this PR do?

fixes

  1. cast to correct device when device="cuda"
  2. fix float64 incompatibility on MPS via just moving to float32

verified via running dMel extraction on:

Test set Clips dMel bins compared Differences
AMI (test) 12,643 50,409,440 0
LibriSpeech (test.clean) 2,620 31,219,840 0
FLEURS en_us (test) 647 10,241,680 0
FLEURS fr_fr (test) 676 11,259,120 0
FLEURS de_de (test) 862 18,187,680 0
FLEURS hi_in (test) 418 7,744,960 0
Total 17,866 129,062,720 0

closes #47392

Co-authored-by: alwaysprince05 <218506877+alwaysprince05@users.noreply.github.com>
@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.

@eustlb
eustlb marked this pull request as ready for review July 21, 2026 12:20
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: inkling

Comment on lines +274 to +275
for device in ["cpu", torch_device]:
processor_kwargs = {} if device == "cpu" else {"audio_kwargs": {"device": device}}

@eustlb eustlb Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

testing both cpu and gpu mel spectrogram extraction, runners' values have been updated for A10G, and ran manually to check

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am a bit lost on the conditional definition/ why "device" = cpu would not work in the cpu case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it would work, it's more that default is CPU by convention

@eustlb

eustlb commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

run-slow: inkling

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/inkling"]
quantizations: []

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 29831320513:1
Result: success | Jobs: 3 | Tests: 92 | Failures: 0 | Duration: 2m 10s

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 2c5f0299 workflow commit (merge commit)
PR 3cf8b0dc branch commit (from PR)
main 504a5fa5 base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

@eustlb
eustlb requested a review from molbap July 22, 2026 14:19
@eustlb eustlb added the for patch Tag issues / labels that should be included in the next patch label Jul 22, 2026

@molbap molbap left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, 2 quick questions!

self.mel_filters = torch.from_numpy(np.ascontiguousarray(mel_filters.T, dtype=np.float32))

def _torch_extract_fbank_features(self, waveform: torch.Tensor, device: str = "cpu") -> torch.Tensor:
waveform = waveform.to(device)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no way to create it on correct device?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

nope, audio input can be numpy and torch tensor directly (numpy most of the time) so lives on CPU anyway and .from_numpy cannot create on device directly...

Comment on lines +274 to +275
for device in ["cpu", torch_device]:
processor_kwargs = {} if device == "cpu" else {"audio_kwargs": {"device": device}}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am a bit lost on the conditional definition/ why "device" = cpu would not work in the cpu case?

@ArthurZucker
ArthurZucker added this pull request to the merge queue Sep 1, 2026
Merged via the queue into main with commit dce3921 Sep 1, 2026
32 checks passed
@ArthurZucker
ArthurZucker deleted the fix-mps-cuda-feature-ex-inklink branch September 1, 2026 09:01
sbucaille pushed a commit to sbucaille/transformers that referenced this pull request Sep 16, 2026
* fix

Co-authored-by: alwaysprince05 <218506877+alwaysprince05@users.noreply.github.com>

* add test

* remove redundant

---------

Co-authored-by: alwaysprince05 <218506877+alwaysprince05@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for patch Tag issues / labels that should be included in the next patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants