Skip to content

Commit 31cf557

Browse files
huydhnfacebook-github-bot
authored andcommitted
Switch Apple benchmark workflow to use the generic ET benchmark iOS app (#5212)
Summary: This requires shoumikhin change in #5208, so I will rebase and test it out again after #5208 lands ### Testing https://github.com/pytorch/executorch/actions/runs/10787058020 Reviewed By: shoumikhin, guangy10 Differential Revision: D62415898 Pulled By: huydhn
1 parent f9da675 commit 31cf557

File tree

5 files changed

+67
-54
lines changed

5 files changed

+67
-54
lines changed

.github/workflows/apple-perf.yml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,19 @@ jobs:
204204
if-no-files-found: ignore
205205
path: ${{ runner.temp }}/artifacts/
206206

207-
build-llm-demo:
208-
name: build-llm-demo
207+
build-benchmark-app:
208+
name: build-benchmark-app
209209
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
210210
needs:
211211
- set-parameters
212212
secrets: inherit
213-
strategy:
214-
matrix:
215-
tokenizer: [bpe]
216213
with:
217214
runner: macos-latest-xlarge
218215
python-version: '3.11'
219216
submodules: 'true'
220217
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
221218
upload-artifact: ios-apps
222-
secrets-env: BUILD_CERTIFICATE_BASE64 BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
219+
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
223220
timeout: 90
224221
script: |
225222
set -eux
@@ -234,7 +231,7 @@ jobs:
234231
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
235232
236233
# Setup Apple certificate for iOS development
237-
BUILD_PROVISION_PROFILE_BASE64="${SECRET_BUILD_PROVISION_PROFILE_BASE64}" \
234+
BUILD_PROVISION_PROFILE_BASE64="${SECRET_EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64}" \
238235
BUILD_CERTIFICATE_BASE64="${SECRET_BUILD_CERTIFICATE_BASE64}" \
239236
KEYCHAIN_PASSWORD="${SECRET_KEYCHAIN_PASSWORD}" \
240237
.ci/scripts/setup-ios.sh
@@ -248,11 +245,38 @@ jobs:
248245
backends/apple/mps/install_requirements.sh
249246
echo "::endgroup::"
250247
248+
echo "::group::Build ExecuTorch iOS frameworks"
249+
FRAMEWORKS=(
250+
"executorch"
251+
"backend_coreml"
252+
"backend_mps"
253+
"backend_xnnpack"
254+
"kernels_custom"
255+
"kernels_optimized"
256+
"kernels_portable"
257+
"kernels_quantized"
258+
)
259+
260+
# Build Release iOS Frameworks
261+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
262+
build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
263+
264+
mkdir -p extension/apple/Benchmark/Frameworks
265+
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
266+
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/apple/Benchmark/Frameworks/
267+
) done
268+
echo "::endgroup::"
269+
270+
# NB: Although exported models can be copied to this directory and bundled together with the
271+
# app, we don't use this in CI and rely on AWS extra data parameter to make the model and the
272+
# tokenizer available to the benchmark. This decouples the app and the model. We just need to
273+
# create the directory here to pass the build
274+
mkdir -p extension/apple/Benchmark/Models
251275
${CONDA_RUN} --no-capture-output \
252-
build/build_apple_llm_demo.sh ${{ matrix.tokenizer }} ${ARTIFACTS_DIR_NAME}
276+
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
253277
254-
upload-ios-apps:
255-
needs: build-llm-demo
278+
upload-benchmark-app:
279+
needs: build-benchmark-app
256280
runs-on: linux.2xlarge
257281
steps:
258282
- name: Download the apps from GitHub
@@ -281,7 +305,7 @@ jobs:
281305
benchmark-on-device:
282306
needs:
283307
- set-parameters
284-
- upload-ios-apps
308+
- upload-benchmark-app
285309
- upload-models
286310
permissions:
287311
id-token: write
@@ -302,7 +326,7 @@ jobs:
302326
project-arn: arn:aws:devicefarm:us-west-2:308535385114:project:02a2cf0f-6d9b-45ee-ba1a-a086587469e6
303327
device-pool-arn: ${{ matrix.device }}
304328
# Uploaded to S3 from the previous job
305-
ios-ipa-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/LLaMAPerfBenchmark.ipa
306-
ios-xctestrun-zip: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/LLaMAPerfBenchmark.xctestrun.zip
329+
ios-ipa-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/Benchmark.ipa
330+
ios-xctestrun-zip: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/Benchmark.xctestrun.zip
307331
test-spec: ${{ inputs.test_spec || 'https://ossci-ios.s3.amazonaws.com/executorch/default-ios-device-farm-appium-test-spec.yml' }}
308332
extra-data: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/${{ matrix.model }}_${{ matrix.delegate }}/model.zip

.github/workflows/apple.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
- build/build_apple_frameworks.sh
1616
- build/create_frameworks.sh
1717
- build/test_ios_ci.sh
18-
- examples/demo-apps/apple/**
18+
- examples/demo-apps/apple_ios/**
1919
- extension/apple/**
2020
- extension/module/**
2121
workflow_dispatch:
@@ -35,7 +35,7 @@ concurrency:
3535

3636
jobs:
3737
build-demo-ios:
38-
name: test-demo-ios
38+
name: build-demo-ios
3939
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
4040
secrets: inherit
4141
with:

build/build_apple_llm_demo.sh

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,33 @@
77

88
set -euo pipefail
99

10-
TOKENIZER="${1:-bpe}"
11-
ARTIFACTS_DIR_NAME="$2"
12-
13-
APP_PATH="examples/demo-apps/apple_ios/LLaMA/LLaMA"
14-
15-
if [[ "${TOKENIZER}" = "bpe" ]]; then
16-
xcodebuild build-for-testing \
17-
-project "${APP_PATH}.xcodeproj" \
18-
-scheme LLaMAPerfBenchmark \
19-
-destination platform="iOS" \
20-
-allowProvisioningUpdates \
21-
DEVELOPMENT_TEAM=78E7V7QP35 \
22-
CODE_SIGN_STYLE=Manual \
23-
PROVISIONING_PROFILE_SPECIFIER=iLLaMA \
24-
CODE_SIGN_IDENTITY="iPhone Distribution" \
25-
CODE_SIGNING_REQUIRED=No \
26-
CODE_SIGNING_ALLOWED=No \
27-
GCC_PREPROCESSOR_DEFINITIONS="DEBUG=1 ET_USE_TIKTOKEN=0"
28-
else
29-
xcodebuild build-for-testing \
30-
-project "${APP_PATH}.xcodeproj" \
31-
-scheme LLaMAPerfBenchmark \
32-
-destination platform="iOS" \
33-
-allowProvisioningUpdates \
34-
DEVELOPMENT_TEAM=78E7V7QP35 \
35-
CODE_SIGN_STYLE=Manual \
36-
PROVISIONING_PROFILE_SPECIFIER=iLLaMA \
37-
CODE_SIGN_IDENTITY="iPhone Distribution" \
38-
CODE_SIGNING_REQUIRED=No \
39-
CODE_SIGNING_ALLOWED=No
40-
fi
10+
ARTIFACTS_DIR_NAME="$1"
11+
APP_PATH="extension/apple/Benchmark/Benchmark"
12+
13+
xcodebuild build-for-testing \
14+
-project "${APP_PATH}.xcodeproj" \
15+
-scheme Benchmark \
16+
-destination "platform=iOS" \
17+
-sdk iphoneos \
18+
-allowProvisioningUpdates \
19+
DEVELOPMENT_TEAM=78E7V7QP35 \
20+
CODE_SIGN_STYLE=Manual \
21+
PROVISIONING_PROFILE_SPECIFIER="ExecuTorch Benchmark" \
22+
CODE_SIGN_IDENTITY="iPhone Distribution" \
23+
CODE_SIGNING_REQUIRED=No \
24+
CODE_SIGNING_ALLOWED=No
4125

4226
# The hack to figure out where the xctest package locates
4327
BUILD_DIR=$(xcodebuild -showBuildSettings -project "$APP_PATH.xcodeproj" -json | jq -r ".[0].buildSettings.BUILD_DIR")
4428

4529
# Prepare the demo app, debug mode here is the default from xcodebuild and match
4630
# with what we have in the test spec
47-
# TODO (huydhn): See if we can switch to release mode here
48-
MODE="Debug"
31+
MODE="Release"
4932
PLATFORM="iphoneos"
5033
pushd "${BUILD_DIR}/${MODE}-${PLATFORM}"
5134

5235
rm -rf Payload && mkdir Payload
53-
APP_NAME=LLaMAPerfBenchmark
36+
APP_NAME=Benchmark
5437

5538
ls -lah
5639
cp -r "${APP_NAME}.app" Payload && zip -vr "${APP_NAME}.ipa" Payload

examples/demo-apps/apple_ios/default-ios-device-farm-appium-test-spec.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ phases:
1111
pre_test:
1212
commands:
1313
- mkdir $DEVICEFARM_TEST_PACKAGE_PATH/Debug-iphoneos
14+
- mkdir $DEVICEFARM_TEST_PACKAGE_PATH/Release-iphoneos
1415
- unzip $DEVICEFARM_APP_PATH -d /tmp
15-
- mv /tmp/Payload/*.app $DEVICEFARM_TEST_PACKAGE_PATH/Debug-iphoneos/
16+
- cp -r /tmp/Payload/*.app $DEVICEFARM_TEST_PACKAGE_PATH/Debug-iphoneos/
17+
- cp -r /tmp/Payload/*.app $DEVICEFARM_TEST_PACKAGE_PATH/Release-iphoneos/
1618

1719
# The test phase includes commands that run your test suite execution.
1820
test:

extension/apple/Benchmark/Benchmark.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@
411411
PRODUCT_BUNDLE_IDENTIFIER = org.pytorch.executorch.Benchmark;
412412
PRODUCT_NAME = Benchmark;
413413
SDKROOT = auto;
414-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
414+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
415+
SUPPORTS_MACCATALYST = NO;
415416
SWIFT_EMIT_LOC_STRINGS = YES;
416417
SWIFT_VERSION = 5.0;
417418
TARGETED_DEVICE_FAMILY = "1,2";
@@ -444,7 +445,8 @@
444445
PRODUCT_BUNDLE_IDENTIFIER = org.pytorch.executorch.Benchmark;
445446
PRODUCT_NAME = Benchmark;
446447
SDKROOT = auto;
447-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
448+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
449+
SUPPORTS_MACCATALYST = NO;
448450
SWIFT_EMIT_LOC_STRINGS = YES;
449451
SWIFT_VERSION = 5.0;
450452
TARGETED_DEVICE_FAMILY = "1,2";
@@ -467,7 +469,8 @@
467469
PRODUCT_BUNDLE_IDENTIFIER = org.pytorch.executorch.BenchmarkTests;
468470
PRODUCT_NAME = "$(TARGET_NAME)";
469471
SDKROOT = auto;
470-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
472+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
473+
SUPPORTS_MACCATALYST = NO;
471474
SWIFT_EMIT_LOC_STRINGS = NO;
472475
SWIFT_VERSION = 5.0;
473476
TARGETED_DEVICE_FAMILY = "1,2";
@@ -491,7 +494,8 @@
491494
PRODUCT_BUNDLE_IDENTIFIER = org.pytorch.executorch.BenchmarkTests;
492495
PRODUCT_NAME = "$(TARGET_NAME)";
493496
SDKROOT = auto;
494-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
497+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
498+
SUPPORTS_MACCATALYST = NO;
495499
SWIFT_EMIT_LOC_STRINGS = NO;
496500
SWIFT_VERSION = 5.0;
497501
TARGETED_DEVICE_FAMILY = "1,2";

0 commit comments

Comments
 (0)