-
Notifications
You must be signed in to change notification settings - Fork 30.9k
[Wav2Vec2 Conformer] Fix inference float16 #25985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sanchit-gandhi
merged 4 commits into
huggingface:main
from
sanchit-gandhi:w2v2-conformer
Sep 5, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -901,6 +901,26 @@ def test_speech_to_text_leveraged(self): | |
| output = speech_recognizer(filename) | ||
| self.assertEqual(output, {"text": "a man said to the universe sir i exist"}) | ||
|
|
||
| @slow | ||
| @require_torch_gpu | ||
| def test_wav2vec2_conformer_float16(self): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the error repro that was failing before @Vaibhavs10 - added a slow integration test to make sure this works after the fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect! Thanks <3 |
||
| speech_recognizer = pipeline( | ||
| task="automatic-speech-recognition", | ||
| model="facebook/wav2vec2-conformer-rope-large-960h-ft", | ||
| device="cuda:0", | ||
| torch_dtype=torch.float16, | ||
| framework="pt", | ||
| ) | ||
|
|
||
| dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation") | ||
| sample = dataset[0]["audio"] | ||
|
|
||
| output = speech_recognizer(sample) | ||
| self.assertEqual( | ||
| output, | ||
| {"text": "MISTER QUILTER IS THE APOSTLE OF THE MIDDLE CLASSES AND WE ARE GLAD TO WELCOME HIS GOSPEL"}, | ||
| ) | ||
|
|
||
| @require_torch | ||
| def test_chunking_fast(self): | ||
| speech_recognizer = pipeline( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/facebookresearch/fairseq/blob/4db264940f281a6f47558d17387b1455d4abd8d9/fairseq/modules/rotary_positional_embedding.py#L30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now looks a lot like:
Wondering if we can add copied from and use this / wondering if the dynamic scaling could also work for audio models?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't use
# Copied fromon the whole module since theWav2Vec2ConformerRotaryPositionalEmbeddingaccepts theconfigas an argument, butLlamaRotaryEmbeddinguses various ad-hoc arguments. But we could do a similar dynamic slicing - will add this in a follow-up PR so as not to block @Vaibhavs10