-
Notifications
You must be signed in to change notification settings - Fork 226
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 benchmarking scripts #1030
Draft
Jack-Khuu
wants to merge
20
commits into
main
Choose a base branch
from
benchmarking_script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add benchmarking scripts #1030
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
eab209f
Add benchmarking scripts
Jack-Khuu 3888de3
Merge branch 'main' into benchmarking_script
Jack-Khuu 91e9909
Merge branch 'main' into benchmarking_script
Jack-Khuu 6c7374e
Merge branch 'main' into benchmarking_script
Jack-Khuu f4820c6
Merge branch 'main' into benchmarking_script
Jack-Khuu e19ccf9
Merge branch 'main' into benchmarking_script
Jack-Khuu e071cca
Merge branch 'main' into benchmarking_script
Jack-Khuu 4dffb51
Merge branch 'main' into benchmarking_script
Jack-Khuu 0f21304
Merge branch 'main' into benchmarking_script
Jack-Khuu 6798c81
update
Jack-Khuu f7ac0ea
push
Jack-Khuu 80d2c6d
update mac
Jack-Khuu b7fc9c7
Merge branch 'main' into benchmarking_script
Jack-Khuu fe839df
Merge branch 'main' into benchmarking_script
Jack-Khuu 992dcd2
56be609
Jack-Khuu a039ab1
Merge branch 'main' into benchmarking_script
Jack-Khuu bea750d
fd1857a
Jack-Khuu d53f7a5
Merge branch 'main' into benchmarking_script
Jack-Khuu b9de90b
Merge branch 'main' into benchmarking_script
Jack-Khuu ad5c82a
Merge branch 'main' into benchmarking_script
Jack-Khuu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,190 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd drop benchmarking from the file names since they are already in a folder named benchmarking |
||
RUN_CUDA_EAGER=true | ||
RUN_CUDA_COMPILE=false | ||
RUN_CUDA_AOTI=false | ||
|
||
RUN_CPU_EAGER=true | ||
RUN_CPU_COMPILE=false | ||
RUN_CPU_AOTI=false | ||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Check and Set Up Args (model, out_directory) | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
if [ $# -ne 2 ]; then | ||
echo "Please provide (1) model and (2) directory as positional arguments" | ||
exit 1 | ||
fi | ||
|
||
model=$1 | ||
dir=$2 | ||
|
||
mkdir -p $dir | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Helpers | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
# Function for printing and writing to files | ||
function formatted_export_and_generate { | ||
local file="$dir/$1" | ||
local generate_cmd="$2" | ||
local compile_cmd="$3" | ||
|
||
# Write Commands to the top of the output file | ||
echo $compile_cmd > $file | ||
echo $generate_cmd >> $file | ||
|
||
echo "Writing to: ${file}" | ||
|
||
# Export the Model | ||
if [ ! -z "$compile_cmd" ]; then | ||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $file | ||
echo "$compile_cmd" | tee -a $file | ||
eval $compile_cmd &>> $file | ||
fi | ||
|
||
# Generate using the Model | ||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $file | ||
echo $generate_cmd | tee -a $file | ||
eval $generate_cmd &>> $file | ||
echo | ||
} | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Cuda eager | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
if [ "$RUN_CUDA_EAGER" = "true" ]; then | ||
echo "Cuda eager b16" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --prompt \"Once upon a time,\" --max-new-tokens 200 --num-samples 3" | ||
file="cuda_eager_b16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "Cuda eager int8" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --prompt \"Once upon a time,\" --max-new-tokens 200 --num-samples 3" | ||
file="cuda_eager_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "Cuda eager int4" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --prompt \"Once upon a time,\" --max-new-tokens 200 --num-samples 3" | ||
file="cuda_eager_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
fi | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Cuda compile | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
if [ "$RUN_CUDA_COMPILE" = "true" ]; then | ||
echo "Cuda compile b16" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --prompt \"Once upon a time,\" --max-new-tokens 200 --compile --num-samples 3" | ||
file="cuda_compile_b16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "Cuda compile int8" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --prompt \"Once upon a time,\" --max-new-tokens 200 --compile --num-samples 3" | ||
file="cuda_compile_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "Cuda compile int4" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --prompt \"Once upon a time,\" --max-new-tokens 200 --compile --num-samples 3" | ||
file="cuda_compile_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
fi | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# CPU eager | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
if [ "$RUN_CPU_EAGER" = "true" ]; then | ||
echo "CPU eager b16" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="cpu_eager_b16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "CPU eager int8" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="cpu_eager_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "CPU eager int4" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="cpu_eager_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
fi | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# CPU compile | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
if [ "$RUN_CPU_COMPILE" = "true" ]; then | ||
echo "CPU compile b16" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --compile --num-samples 3" | ||
file="cpu_compile_b16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "CPU compile int8" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --compile --num-samples 3" | ||
file="cpu_compile_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "CPU compile int4" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --compile --num-samples 3" | ||
file="cpu_compile_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
fi | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Cuda AOTI | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
if [ "$RUN_CUDA_AOTI" = "true" ]; then | ||
echo "Cuda aoti b16" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --output-dso-path /tmp/model16.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model16.so --prompt \"Once upon a time,\" --max-new-tokens 200 --device cuda --num-samples 3" | ||
file="cuda_aoti_b16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
|
||
echo "Cuda aoti int8" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --output-dso-path /tmp/model8.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model8.so --prompt \"Once upon a time,\" --max-new-tokens 200 --device cuda --num-samples 3" | ||
file="cuda_aoti_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
|
||
echo "Cuda aoti int4" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cuda\"}}' --output-dso-path /tmp/model34.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model34.so --prompt \"Once upon a time,\" --max-new-tokens 200 --device cuda --num-samples 3" | ||
file="cuda_aoti_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
fi | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# CPU AOTI | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
if [ "$RUN_CPU_AOTI" = "true" ]; then | ||
echo "CPU aoti b16" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --output-dso-path /tmp/model16.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model16.so --prompt \"Once upon a time,\" --max-new-tokens 256 --device cpu --num-samples 3" | ||
file="cpu_aoti_b16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
|
||
echo "CPU aoti int8" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --output-dso-path /tmp/model8.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model8.so --prompt \"Once upon a time,\" --max-new-tokens 256 --device cpu --num-samples 3" | ||
file="cpu_aoti_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
|
||
echo "CPU aoti int4" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"bfloat16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --output-dso-path /tmp/model34.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model34.so --prompt \"Once upon a time,\" --max-new-tokens 256 --device cpu --num-samples 3" | ||
file="cpu_aoti_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
fi |
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,138 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add license header at the top |
||
RUN_MPS_EAGER=false | ||
|
||
RUN_CPU_EAGER=true | ||
RUN_CPU_COMPILE=false | ||
RUN_CPU_AOTI=false | ||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Check and Set Up Args (model, out_directory) | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
if [ $# -ne 2 ]; then | ||
echo "Please provide (1) model and (2) directory as positional arguments" | ||
exit 1 | ||
fi | ||
|
||
model=$1 | ||
dir=$2 | ||
|
||
mkdir -p $dir | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Helpers | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
# Function for printing and writing to files | ||
function formatted_export_and_generate { | ||
local file="$dir/$1" | ||
local generate_cmd="$2" | ||
local compile_cmd="$3" | ||
|
||
# Write Commands to the top of the output file | ||
echo $compile_cmd > $file | ||
echo $generate_cmd >> $file | ||
|
||
echo "Writing to: ${file}" | ||
|
||
# Export the Model | ||
if [ ! -z "$compile_cmd" ]; then | ||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $file | ||
echo "$compile_cmd" | tee -a $file | ||
eval $compile_cmd >> $file 2>&1 | ||
fi | ||
|
||
# Generate using the Model | ||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $file | ||
echo $generate_cmd | tee -a $file | ||
eval $generate_cmd >> $file 2>&1 | ||
echo | ||
} | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# MPS Eager | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
if [ "$RUN_MPS_EAGER" = "true" ]; then | ||
echo "MPS Eager 16" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"mps\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="mps_eager_16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "MPS Eager int8" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"mps\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="mps_eager_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "MPS Eager int4" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"mps\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="mps_eager_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
fi | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# CPU Eager | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
if [ "$RUN_CPU_EAGER" = "true" ]; then | ||
echo "CPU Eager 16" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="cpu_eager_16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "CPU Eager int8" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="cpu_eager_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "CPU Eager int4" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --num-samples 3" | ||
file="cpu_eager_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
fi | ||
|
||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# CPU compile | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
if [ "$RUN_CPU_COMPILE" = "true" ]; then | ||
echo "CPU compile b16" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --compile --num-samples 3" | ||
file="cpu_compile_b16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "CPU compile int8" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --compile --num-samples 3" | ||
file="cpu_compile_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
|
||
echo "CPU compile int4" | ||
generate_cmd="python3 torchchat.py generate $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --prompt \"Once upon a time,\" --max-new-tokens 256 --compile --num-samples 3" | ||
file="cpu_compile_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" | ||
fi | ||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# CPU AOTI | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
if [ "$RUN_CPU_AOTI" = "true" ]; then | ||
echo "CPU aoti b16" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --output-dso-path /tmp/model16.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model16.so --prompt \"Once upon a time,\" --max-new-tokens 256 --device cpu --num-samples 3" | ||
file="cpu_aoti_b16.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
|
||
echo "CPU aoti int8" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"linear:int8\": {\"groupsize\": 0}, \"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --output-dso-path /tmp/model8.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model8.so --prompt \"Once upon a time,\" --max-new-tokens 256 --device cpu --num-samples 3" | ||
file="cpu_aoti_8.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
|
||
echo "CPU aoti int4" | ||
compile_cmd="python3 torchchat.py export $model --quantize '{\"linear:int4\": {\"groupsize\": 256}, \"precision\": {\"dtype\":\"float16\"}, \"executor\":{\"accelerator\":\"cpu\"}}' --output-dso-path /tmp/model34.so" | ||
generate_cmd="python3 torchchat.py generate $model --dso-path /tmp/model34.so --prompt \"Once upon a time,\" --max-new-tokens 256 --device cpu --num-samples 3" | ||
file="cpu_aoti_4.txt" | ||
formatted_export_and_generate "$file" "$generate_cmd" "$compile_cmd" | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the license header at the top