-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Should work! Added distil whisper to torchbench. Local time is within normal CI requirements. ![image](https://github.com/pytorch/benchmark/assets/24942306/0f7e7cae-ae90-44e6-bbff-4eede4a4f730) Pull Request resolved: #2074 Reviewed By: aaronenyeshi Differential Revision: D52053930 Pulled By: xuzhao9 fbshipit-source-id: f0d20a821c5de916ca174b0033d9d79b5d6cafa0
- Loading branch information
1 parent
075f804
commit d61b74a
Showing
5 changed files
with
56 additions
and
0 deletions.
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,30 @@ | ||
from torchbenchmark.tasks import SPEECH | ||
from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel | ||
import torch | ||
|
||
class Model(HuggingFaceModel): | ||
task = SPEECH.RECOGNITION | ||
DEFAULT_TRAIN_BSIZE = 8 | ||
DEFAULT_EVAL_BSIZE = 1 | ||
|
||
def __init__(self, test, device, batch_size=None, extra_args=[]): | ||
if test == "train": | ||
raise NotImplementedError("Training is not implemented.") | ||
super().__init__(name="hf_distil_whisper", test=test, device=device, batch_size=batch_size, extra_args=extra_args) | ||
self.feature_size = 80 | ||
self.sequence_length = 3000 | ||
self.input_features = torch.randn(size=(self.batch_size, self.feature_size, self.sequence_length),device=self.device) | ||
self.example_inputs = {"input_features": self.input_features.to(self.device), "input_ids" : self.input_features.to(self.device)} | ||
self.model.to(self.device) | ||
|
||
def train(self): | ||
raise NotImplementedError("Training is not implemented.") | ||
|
||
def eval(self): | ||
self.model.eval() | ||
with torch.no_grad(): | ||
self.model(self.example_inputs["input_ids"]) | ||
|
||
def enable_fp16(self): | ||
self.model.half() | ||
self.example_inputs = {"input_features": self.input_features.half().to(self.device), "input_ids" : self.input_features.half().to(self.device)} |
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,14 @@ | ||
|
||
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,8 @@ | ||
devices: | ||
NVIDIA A100-SXM4-40GB: | ||
eval_batch_size: 16 | ||
eval_benchmark: false | ||
eval_deterministic: false | ||
eval_nograd: true | ||
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,2 @@ | ||
sentencepiece | ||
datasets |
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