-
Notifications
You must be signed in to change notification settings - Fork 278
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
Added Whisper from Huggingface. #1769
Closed
Closed
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
89f4497
Added huggingface Whisper.
MaanavD ba57c50
Updated requirements, batch size.
MaanavD bb3f331
Updated to remove training.
MaanavD 116df9c
Removed default train size. No training implemented.
MaanavD c77ad90
fix tests
msaroufim c7ef8a3
Merge branch 'main' into adding_whisper_hf
msaroufim f232aac
fix eval test
msaroufim c3d5d10
push
msaroufim 9bca12c
add support for half()
msaroufim 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 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel | ||
from torchbenchmark.tasks import SPEECH | ||
import torch | ||
|
||
class Model(HuggingFaceModel): | ||
task = SPEECH.RECOGNITION | ||
# https://cdn.openai.com/papers/whisper.pdf Says for large-v2 they trained on 1024 batch sizes, with 16 GPUs | ||
DEFAULT_EVAL_BSIZE = 64 | ||
|
||
def __init__(self, test, device, jit=False, batch_size=None, extra_args=[]): | ||
super().__init__(name="hf_Whisper", test=test, device=device, jit=jit, batch_size=batch_size, extra_args=extra_args) | ||
self.feature_size = 80 | ||
self.sequence_length = 3000 | ||
input_features = torch.randn(size=(self.batch_size, self.feature_size, self.sequence_length),device=self.device).half() | ||
self.example_inputs = {"input_features": input_features.to(self.device)} | ||
self.model.to(self.device) | ||
|
||
def get_module(self): | ||
return self.model, (self.example_inputs) | ||
|
||
xuzhao9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def train(self): | ||
raise NotImplementedError("Training is not implemented.") |
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import subprocess | ||
import sys | ||
import os | ||
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model | ||
|
||
def pip_install_requirements(): | ||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) | ||
|
||
if __name__ == '__main__': | ||
pip_install_requirements() | ||
patch_transformers() | ||
model_name = os.path.basename(os.path.dirname(os.path.abspath(__file__))) | ||
cache_model(model_name) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
devices: | ||
NVIDIA A100-SXM4-40GB: | ||
eval_batch_size: 8 | ||
eval_benchmark: false | ||
eval_deterministic: false | ||
eval_nograd: true | ||
not_implemented: | ||
- jit: true | ||
- device: cpu | ||
test: eval | ||
train_benchmark: false | ||
train_deterministic: false |
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
numba |
This file contains 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 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
Oops, something went wrong.
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.
Since we are wrapping the model in a different way, we need to implement customized
get_module()
here, similar to the upstream code: https://github.com/MaanavD/benchmark/blob/116df9cb937b6921d16eba34fc504776bb40a6ee/torchbenchmark/util/framework/huggingface/model_factory.py#L110The reason we need
get_module()
is because this API is being used by our downstream benchmarking script: https://github.com/pytorch/pytorch/blob/main/benchmarks/dynamo/torchbench.py#L358and it requires
model(*example_input)
runs successfully.