Benchmark performance of **any model** deployed on **Amazon SageMaker** or available on **Amazon Bedrock** or deployed by you on an AWS service of choice (such as Amazon EKS or Amazon EC2) a.k.a **Bring your own endpoint**.
Project description
Foundation Model benchmarking tool (FMBench)
Benchmark any Foundation Model (FM) on any AWS service [Amazon SageMaker, Amazon Bedrock, Amazon EKS, Bring your own endpoint etc.]
Amazon SageMaker | Amazon Bedrock
A key challenge with FMs is the ability to benchmark their performance in terms of inference latency, throughput and cost so as to determine which model running with what combination of the hardware and serving stack provides the best price-performance combination for a given workload.
Stated as business problem, the ask is “What is the dollar cost per transaction for a given generative AI workload that serves a given number of users while keeping the response time under a target threshold?”
But to really answer this question, we need to answer an engineering question (an optimization problem, actually) corresponding to this business problem: “What is the minimum number of instances N, of most cost optimal instance type T, that are needed to serve a workload W while keeping the average transaction latency under L seconds?”
W: = {R transactions per-minute, average prompt token length P, average generation token length G}
This foundation model benchmarking tool (a.k.a. FMBench
) is a tool to answer the above engineering question and thus answer the original business question about how to get the best price performance for a given workload. Here is one of the plots generated by FMBench
to help answer the above question (This foundation model benchmarking tool (a.k.a. FMBench
) is a tool to answer the above engineering question and thus answer the original business question about how to get the best price performance for a given workload. Here is one of the plots generated by FMBench
to help answer the above question (the instance types in the legend have been blurred out on purpose, you can find them in the actual plot generated on running FMBench
).
Models benchmarked
Configuration files are available in the configs folder for the following models in this repo.
Model | SageMaker g4dn/g5/p3 | SageMaker Inf2 | SageMaker P4 | SageMaker P5 | Bedrock On-demand throughput | Bedrock provisioned throughput |
---|---|---|---|---|---|---|
Anthropic Claude-3 Sonnet | ✅ | ✅ | ||||
Anthropic Claude-3 Haiku | ✅ | |||||
Mistral-7b-instruct | ✅ | ✅ | ✅ | ✅ | ||
Mistral-7b-AWQ | ✅ | |||||
Mixtral-8x7b-instruct | ✅ | |||||
Llama3-8b instruct | ✅ | ✅ | ✅ | ✅ | ||
Llama3-70b instruct | ✅ | ✅ | ✅ | ✅ | ||
Llama2-13b chat | ✅ | ✅ | ✅ | ✅ | ||
Llama2-70b chat | ✅ | ✅ | ✅ | ✅ | ||
Amazon Titan text lite | ✅ | |||||
Amazon Titan text express | ✅ | |||||
Cohere Command text | ✅ | |||||
Cohere Command light text | ✅ | |||||
AI21 J2 Mid | ✅ | |||||
AI21 J2 Ultra | ✅ | |||||
distilbert-base-uncased | ✅ |
New in this release
v1.0.37
g5
/p4d
/p5
/inf2
/trn1
specific config files forLlama3-8b-Instruct
.p4d
config file for bothvllm
andlmi-dist
.
v1.0.36
- Fix bug at higher concurrency levels (20 and above).
- Support for instance count > 1.
v1.0.35
- Support for Open-Orca dataset and corresponding prompts for Llama3, Llama2 and Mistral.
v1.0.34
- Don't delete endpoints for the bring your own endpoint case.
- Fix bug with business summary chart.
v1.0.32
-
Report enhancements: New business summary chart, config file embedded in the report, version numbering and others.
-
Additional config files: Meta Llama3 on Inf2, Mistral instruct with
lmi-dist
onp4d
andp5
instances.
v1.0.31
- Meta Llama3 benchmarking on Amazon SageMaker.
v1.0.29
- Support for Amazon Bedrock. Benchmark models available on Bedrock, both on-demand throughput and provisioned throughput.
v1.0.28
-
Support for HuggingFace datasets as well as bring your own datasets, more here.
-
Support for external endpoints. No longer limited to Amazon SageMaker endpoints, more here.
-
Bring your own
Amazon SageMaker
endpoints. If you have an already deployed SageMaker endpoint you can now test it withFMBench
. -
Added config files for
Mistral-7B-Instruct
,Mistral-7B-Instruct-v0.2-AWQ
,huggingface-tc-distilbert-base-uncased
(from SageMaker JumpStart),meta-textgenerationneuron-llama-2-70b-f
(on AWS Inferentia2).
Key Features
-
Benchmark any model on any serving stack as long as it can be deployed on Amazon SageMaker.
-
Bring your own script for model deployment if the model is not natively available via Amazon SageMaker JumpStart.
-
Bring your own tokenizer for your model, configure any inference container parameters you need.
-
Auto-generated reports comparing and contrasting different serving options.
Installation
-
Launch the AWS CloudFormation template included in this repository using one of the buttons from the table below. The CloudFormation template creates the following resources within your AWS account: Amazon S3 buckets, Amazon IAM role and an Amazon SageMaker Notebook with this repository cloned. A read S3 bucket is created which contains all the files (configuration files, datasets) required to run
FMBench
and a write S3 bucket is created which will hold the metrics and reports generated byFMBench
. The CloudFormation stack takes about 5-minutes to create.AWS Region Link us-east-1 (N. Virginia) -
Once the CloudFormation stack is created, navigate to SageMaker Notebooks and open the
fmbench-notebook
. -
On the
fmbench-notebook
open a Terminal and run the following commands.conda create --name fmbench_python311 -y python=3.11 ipykernel source activate fmbench_python311; pip install -U fmbench
Steps to run
-
Now you are ready to
fmbench
with the following command line. We will use a sample config file placed in the S3 bucket by the CloudFormation stack for a quick first run.-
We benchmark performance for the
Llama2-7b
model on aml.g5.xlarge
and aml.g5.2xlarge
instance type, using thehuggingface-pytorch-tgi-inference
inference container. This test would take about 30 minutes to complete and cost about $0.20. -
It uses a simple relationship of 750 words equals 1000 tokens, to get a more accurate representation of token counts use the
Llama2 tokenizer
(instructions are provided in the next section). It is strongly recommended that for more accurate results on token throughput you use a tokenizer specific to the model you are testing rather than the default tokenizer. See instructions provided later in this document on how to use a custom tokenizer.account=`aws sts get-caller-identity | jq .Account | tr -d '"'` fmbench --config-file s3://sagemaker-fmbench-read-${account}/configs/llama2/7b/config-llama2-7b-g5-quick.yml
-
-
The generated reports and metrics are available in the
sagemaker-fmbench-write-<replace_w_your_aws_account_id>
bucket. The metrics and report files are also downloaded locally and in theresults
directory (created byFMBench
) and the benchmarking report is available as a markdown file calledreport.md
in theresults
directory. You can view the rendered Markdown report in the SageMaker notebook itself or download the metrics and report files to your machine for offline analysis.
License
Documentation
The official documentation is available in the GitHub repo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.