Skip to content

Commit

Permalink
added phi2.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaanavD committed Jan 16, 2024
1 parent 6a8b941 commit c5f6a2a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
17 changes: 17 additions & 0 deletions torchbenchmark/canary_models/phi_2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from torchbenchmark.tasks import NLP
from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel

class Model(HuggingFaceModel):
task = NLP.LANGUAGE_MODELING
# DEFAULT_TRAIN_BSIZE not specified since we're not implementing a train test
# DEFAULT_TRAIN_BSIZE = 1
DEFAULT_EVAL_BSIZE = 1

def __init__(self, test, device, batch_size=None, extra_args=[]):
super().__init__(name="phi_2", test=test, device=device, batch_size=batch_size, extra_args=extra_args)

def train(self):
return NotImplementedError("Not implemented")

def eval(self):
super().eval()
13 changes: 13 additions & 0 deletions torchbenchmark/canary_models/phi_2/install.py
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, trust_remote_code=True)
10 changes: 10 additions & 0 deletions torchbenchmark/canary_models/phi_2/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
devices:
NVIDIA A100-SXM4-40GB:
eval_batch_size: 1
eval_benchmark: false
eval_deterministic: false
eval_nograd: true
train_benchmark: false
train_deterministic: false
not_implemented:
- device: NVIDIA A10G
2 changes: 2 additions & 0 deletions torchbenchmark/canary_models/phi_2/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
einops
flash_attn
1 change: 1 addition & 0 deletions torchbenchmark/util/framework/huggingface/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'llama_v2_13b' : (512,512, 'AutoConfig.from_pretrained("meta-llama/Llama-2-13b-hf")', 'AutoModelForCausalLM'),
'llama_v2_70b' : (512, 512, 'AutoConfig.from_pretrained("meta-llama/Llama-2-70b-hf")', 'AutoModelForMaskedLM'),
'phi_1_5' : (512, 512, 'AutoConfig.from_pretrained("microsoft/phi-1_5", trust_remote_code=True)', 'AutoModelForCausalLM'),
'phi_2' : (512, 512, 'AutoConfig.from_pretrained("microsoft/phi-2", trust_remote_code=True)', 'AutoModelForCausalLM'),
# as per this page https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1 trust_remote_code=True is not required
'mistral_7b_instruct' : (128, 128, 'AutoConfig.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1")', 'AutoModelForCausalLM'),
'hf_Yi' : (512, 512, 'AutoConfig.from_pretrained("01-ai/Yi-6B", trust_remote_code=True)', 'AutoModelForCausalLM'),
Expand Down

0 comments on commit c5f6a2a

Please sign in to comment.