Skip to content

Commit dac062f

Browse files
angelayipytorchmergebot
authored andcommitted
Add aoti to mps benchmarks (pytorch#160741)
Pull Request resolved: pytorch#160741 Approved by: https://github.com/malfet, https://github.com/huydhn
1 parent 2a70d98 commit dac062f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.ci/pytorch/macos-test.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,47 @@ test_torchbench_smoketest() {
302302
fi
303303

304304
done
305+
echo "Pytorch benchmark on mps device completed"
306+
}
307+
308+
test_aoti_torchbench_smoketest() {
309+
print_cmake_info
310+
311+
echo "Launching AOTInductor torchbench setup"
312+
pip_benchmark_deps
313+
# shellcheck disable=SC2119,SC2120
314+
torchbench_setup_macos
315+
316+
TEST_REPORTS_DIR=$(pwd)/test/test-reports
317+
mkdir -p "$TEST_REPORTS_DIR"
318+
319+
local device=mps
320+
local dtypes=(undefined float16 bfloat16 notset)
321+
local dtype=${dtypes[$1]}
322+
local models=(hf_T5 llama BERT_pytorch dcgan hf_GPT2 yolov3 resnet152 sam sam_fast pytorch_unet stable_diffusion_text_encoder speech_transformer Super_SloMo doctr_det_predictor doctr_reco_predictor timm_resnet timm_vovnet vgg16)
323+
324+
echo "Launching torchbench inference performance run for AOT Inductor and dtype ${dtype}"
325+
local dtype_arg="--${dtype}"
326+
if [ "$dtype" == notset ]; then
327+
dtype_arg="--float32"
328+
fi
329+
touch "$TEST_REPORTS_DIR/aot_inductor_torchbench_${dtype}_inference_${device}_performance.csv"
330+
for model in "${models[@]}"; do
331+
PYTHONPATH="$(pwd)"/torchbench python benchmarks/dynamo/torchbench.py \
332+
--performance --only "$model" --export-aot-inductor --inference --devices "$device" "$dtype_arg" \
333+
--output "$TEST_REPORTS_DIR/aot_inductor_torchbench_${dtype}_inference_${device}_performance.csv" || true
334+
PYTHONPATH="$(pwd)"/torchbench python benchmarks/dynamo/torchbench.py \
335+
--accuracy --only "$model" --export-aot-inductor --inference --devices "$device" "$dtype_arg" \
336+
--output "$TEST_REPORTS_DIR/aot_inductor_torchbench_${dtype}_inference_${device}_accuracy.csv" || true
337+
done
338+
339+
echo "Launching HuggingFace inference performance run for AOT Inductor and dtype ${dtype}"
340+
PYTHONPATH="$(pwd)"/torchbench python benchmarks/dynamo/huggingface.py \
341+
--performance --export-aot-inductor --inference --devices "$device" "$dtype_arg" \
342+
--output "$TEST_REPORTS_DIR/aot_inductor_huggingface_${dtype}_inference_${device}_performance.csv" || true
343+
PYTHONPATH="$(pwd)"/torchbench python benchmarks/dynamo/huggingface.py \
344+
--accuracy --export-aot-inductor --inference --devices "$device" "$dtype_arg" \
345+
--output "$TEST_REPORTS_DIR/aot_inductor_huggingface_${dtype}_inference_${device}_accuracy.csv" || true
305346

306347
echo "Pytorch benchmark on mps device completed"
307348
}
@@ -350,6 +391,8 @@ elif [[ $TEST_CONFIG == *"perf_timm"* ]]; then
350391
test_timm_perf
351392
elif [[ $TEST_CONFIG == *"perf_smoketest"* ]]; then
352393
test_torchbench_smoketest "${SHARD_NUMBER}"
394+
elif [[ $TEST_CONFIG == *"aot_inductor_perf_smoketest"* ]]; then
395+
test_aoti_torchbench_smoketest "${SHARD_NUMBER}"
353396
elif [[ $TEST_CONFIG == *"mps"* ]]; then
354397
test_python_mps
355398
elif [[ $NUM_TEST_SHARDS -gt 1 ]]; then

.github/workflows/inductor-perf-test-nightly-macos.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
{ config: "perf_smoketest", shard: 1, num_shards: 3, runner: "macos-m2-15" },
4949
{ config: "perf_smoketest", shard: 2, num_shards: 3, runner: "macos-m2-15" },
5050
{ config: "perf_smoketest", shard: 3, num_shards: 3, runner: "macos-m2-15" },
51+
{ config: "aot_inductor_perf_smoketest", shard: 1, num_shards: 3, runner: "macos-m2-15" },
52+
{ config: "aot_inductor_perf_smoketest", shard: 2, num_shards: 3, runner: "macos-m2-15" },
53+
{ config: "aot_inductor_perf_smoketest", shard: 3, num_shards: 3, runner: "macos-m2-15" },
5154
]}
5255
secrets: inherit
5356

0 commit comments

Comments
 (0)