-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Benchmarks - Add LLaMA-2 Models (#668)
Added llama benchmark - training and inference in accordance with the existing pytorch models implementation like gpt2, lstm etc. - added llama fp8 unit test for better code coverage, to reduce memory required - updated transformers version >= 4.28.0 for LLamaConfig - set tokenizers version <= 0.20.3 to avoid 0.20.4 version [issues](huggingface/tokenizers#1691) with py3.8 - added llama2 to tensorrt - llama2 tests not added to test_tensorrt_inference_performance.py due to large memory requirement for worker gpu. tests validated separately on gh200 --------- Co-authored-by: dpatlolla <[email protected]>
- Loading branch information
Showing
9 changed files
with
408 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
"""Model benchmark example for Llama2-7b (32-layer, 4096-hidden, 32-heads, 7B parameters). | ||
Commands to run: | ||
python3 examples/benchmarks/pytorch_llama2.py (Single GPU) | ||
python3 -m torch.distributed.launch --use_env --nproc_per_node=8 examples/benchmarks/pytorch_llama2.py \ | ||
--distributed (Distributed) | ||
""" | ||
|
||
import argparse | ||
|
||
from superbench.benchmarks import Platform, Framework, BenchmarkRegistry | ||
from superbench.common.utils import logger | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'--distributed', action='store_true', default=False, help='Whether to enable distributed training.' | ||
) | ||
args = parser.parse_args() | ||
|
||
# Specify the model name and benchmark parameters. | ||
model_name = 'llama2-7b' | ||
parameters = '--batch_size 1 --duration 120 --seq_len 512 --precision float16' | ||
if args.distributed: | ||
parameters += ' --distributed_impl ddp --distributed_backend nccl' | ||
|
||
# Create context for Llama2 benchmark and run it for 120 seconds. | ||
context = BenchmarkRegistry.create_benchmark_context( | ||
model_name, platform=Platform.CUDA, parameters=parameters, framework=Framework.PYTORCH | ||
) | ||
|
||
benchmark = BenchmarkRegistry.launch_benchmark(context) | ||
if benchmark: | ||
logger.info( | ||
'benchmark: {}, return code: {}, result: {}'.format( | ||
benchmark.name, benchmark.return_code, benchmark.result | ||
) | ||
) |
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
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.