Skip to content
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

Add LLaMA end-to-end benchmarking #19985

Merged
merged 18 commits into from
Mar 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add local directory option for loading Hugging Face models
  • Loading branch information
kunal-vaishnavi committed Mar 21, 2024
commit 30a5973c319c20e2260ebd3a6bd3b43f2c7bce53
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
def get_model(args):
if args.benchmark_type in {"pt-eager", "pt-compile"}:
model = AutoModelForCausalLM.from_pretrained(
args.model_name,
args.hf_dir_path if args.hf_dir_path != "" else args.model_name,
cache_dir=args.cache_dir,
torch_dtype=args.torch_dtype,
use_auth_token=args.auth,
Expand Down Expand Up @@ -156,7 +156,7 @@ def get_args():
"-m",
"--model-name",
type=str,
required=True,
required=False,
help="Hugging Face name of model (e.g. 'meta-llama/Llama-2-7b-hf')",
)

Expand All @@ -176,6 +176,13 @@ def get_args():
help="Path to directory containing all Hugging Face files (e.g. config, tokenizer, PyTorch model)",
)

parser.add_argument(
"--hf-dir-path",
type=str,
default="",
help="Path to directory containing all Hugging Face files (e.g. tokenizer, PyTorch model)",
)

parser.add_argument(
"-o",
"--onnx-model-path",
Expand Down Expand Up @@ -296,8 +303,16 @@ def main():
size_to_prompt = json.load(f, object_hook=lambda d: {int(k): v for k, v in d.items()})

# Get config, tokenizer, and model
config = AutoConfig.from_pretrained(args.model_name, cache_dir=args.cache_dir, use_auth_token=args.auth)
tokenizer = AutoTokenizer.from_pretrained(args.model_name, cache_dir=args.cache_dir, use_auth_token=args.auth)
config = AutoConfig.from_pretrained(
args.hf_dir_path if args.hf_dir_path != "" else args.model_name,
cache_dir=args.cache_dir,
use_auth_token=args.auth,
)
tokenizer = AutoTokenizer.from_pretrained(
args.hf_dir_path if args.hf_dir_path != "" else args.model_name,
cache_dir=args.cache_dir,
use_auth_token=args.auth,
)
model = get_model(args)

all_csv_metrics = []
Expand Down
Loading