Skip to content

Move benchmark apps to extension/benchmark dir #5971

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/android-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,78 @@ jobs:
test-spec: ${{ inputs.test_spec || 'https://ossci-android.s3.amazonaws.com/executorch/android-llm-device-farm-test-spec.yml' }}
# Uploaded to S3 from the previous job
extra-data: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/model.zip

upload-benchmark-results:
needs:
- benchmark-on-device
if: always()
runs-on: linux.2xlarge
environment: upload-benchmark-results
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
with:
submodules: false

- name: Authenticate with AWS
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::308535385114:role/gha_workflow_upload-benchmark-results
# The max duration enforced by the server side
role-duration-seconds: 18000
aws-region: us-east-1

- name: Setup conda
uses: pytorch/test-infra/.github/actions/setup-miniconda@main
with:
python-version: '3.10'

- name: Download the list of artifacts from S3
env:
ARTIFACTS_S3_DIR: s3://gha-artifacts/device_farm/${{ github.run_id }}/${{ github.run_attempt }}/artifacts/
shell: bash
run: |
set -eux
${CONDA_RUN} python -mpip install awscli==1.32.18

mkdir -p artifacts
pushd artifacts
${CONDA_RUN} aws s3 sync "${ARTIFACTS_S3_DIR}" .
popd

ls -lah artifacts

- name: Extract the benchmark results JSON
shell: bash
run: |
set -eux

mkdir -p benchmark-results

for ARTIFACTS_BY_JOB in artifacts/*.json; do
[ -f "${ARTIFACTS_BY_JOB}" ] || break
echo "${ARTIFACTS_BY_JOB}"
${CONDA_RUN} python .github/scripts/extract_benchmark_results.py \
--artifacts "${ARTIFACTS_BY_JOB}" \
--output-dir benchmark-results \
--repo ${{ github.repository }} \
--head-branch ${{ github.head_ref || github.ref_name }} \
--workflow-name "${{ github.workflow }}" \
--workflow-run-id ${{ github.run_id }} \
--workflow-run-attempt ${{ github.run_attempt }}
done

ls -lah benchmark-results

for BENCHMARK_RESULTS in benchmark-results/*.json; do
cat "${BENCHMARK_RESULTS}"
echo
done

- name: Upload the benchmark results
uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main
with:
benchmark-results-dir: 'benchmark-results'
dry-run: false
1 change: 1 addition & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- install_requirements.sh
- examples/demo-apps/android/**
- extension/android/**
- extension/benchmark/android/**
- extension/module/**
workflow_dispatch:

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/apple-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,17 @@ jobs:
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack

mkdir -p extension/apple/Benchmark/Frameworks
mkdir -p extension/benchmark/apple/Benchmark/Frameworks
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/apple/Benchmark/Frameworks/
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/benchmark/apple/Benchmark/Frameworks/
) done
echo "::endgroup::"

# NB: Although exported models can be copied to this directory and bundled together with the
# app, we don't use this in CI and rely on AWS extra data parameter to make the model and the
# tokenizer available to the benchmark. This decouples the app and the model. We just need to
# create the directory here to pass the build
mkdir -p extension/apple/Benchmark/Models
mkdir -p extension/benchmark/apple/Benchmark/Models
${CONDA_RUN} --no-capture-output \
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}

Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- build/test_ios_ci.sh
- examples/demo-apps/apple_ios/**
- extension/apple/**
- extension/benchmark/apple/**
- extension/module/**
workflow_dispatch:

Expand Down Expand Up @@ -215,3 +216,70 @@ jobs:
shasum -a 256 "${FILENAME}"
${AWS_CMD} "${FILENAME}" s3://ossci-ios/executorch/ --acl public-read
done

build-benchmark-app:
name: build-benchmark-app
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
secrets: inherit
with:
runner: macos-latest-xlarge
python-version: '3.11'
submodules: 'true'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
upload-artifact: ios-apps
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
timeout: 90
script: |
set -eux

echo "::group::Setting up CI environment"
.ci/scripts/setup-conda.sh

BUILD_TOOL=cmake
# Setup MacOS dependencies as there is no Docker support on MacOS atm
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded

# Setup Apple certificate for iOS development
BUILD_PROVISION_PROFILE_BASE64="${SECRET_EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64}" \
BUILD_CERTIFICATE_BASE64="${SECRET_BUILD_CERTIFICATE_BASE64}" \
KEYCHAIN_PASSWORD="${SECRET_KEYCHAIN_PASSWORD}" \
.ci/scripts/setup-ios.sh

# Install CoreML Backend Requirements
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
backends/apple/coreml/scripts/install_requirements.sh

# Install MPS Backend Requirements
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
backends/apple/mps/install_requirements.sh
echo "::endgroup::"

echo "::group::Build ExecuTorch iOS frameworks"
FRAMEWORKS=(
"executorch"
"backend_coreml"
"backend_mps"
"backend_xnnpack"
"kernels_custom"
"kernels_optimized"
"kernels_portable"
"kernels_quantized"
)

# Build Release iOS Frameworks
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack

mkdir -p extension/benchmark/apple/Benchmark/Frameworks
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/benchmark/apple/Benchmark/Frameworks/
) done
echo "::endgroup::"

echo "::group::Build ExecuTorch benchmark app"
mkdir -p extension/benchmark/apple/Benchmark/Models
${CONDA_RUN} --no-capture-output \
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
echo "::endgroup::"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
FILES_NEEDS_FORMAT=$(/opt/google-java-format -n extension/android/src/main/java/org/pytorch/executorch/*.java \
examples/demo-apps/android/ExecuTorchDemo/app/src/main/java/com/example/executorchdemo/*.java \
examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/*.java \
extension/android/benchmark/app/src/main/java/org/pytorch/minibench/*.java)
extension/benchmark/android/benchmark/app/src/main/java/org/pytorch/minibench/*.java)
if [ -n "$FILES_NEEDS_FORMAT" ]; then
echo "Warning: The following files need formatting. Please use google-java-format."
echo "Use a binary from https://github.com/google/google-java-format/releases/"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/upload-android-test-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
pull_request:
paths:
- .github/workflows/upload-android-test-specs.yml
- extension/android/benchmark/android-llm-device-farm-test-spec.yml
- extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
push:
branches:
- main
paths:
- .github/workflows/upload-android-test-specs.yml
- extension/android/benchmark/android-llm-device-farm-test-spec.yml
- extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml

concurrency:
# NB: This concurency group needs to be different than the one used in android-perf, otherwise
Expand All @@ -32,7 +32,7 @@ jobs:
${{ github.repository }}/${{ github.run_id }}/artifacts
retention-days: 1
if-no-files-found: error
path: extension/android/benchmark/android-llm-device-farm-test-spec.yml
path: extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml

validate-android-test-spec:
needs: upload-android-test-spec-for-validation
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:

- name: Upload the spec to S3 ossci-android bucket
shell: bash
working-directory: extension/android/benchmark/
working-directory: extension/benchmark/android/benchmark/
env:
SPEC_FILE: android-llm-device-farm-test-spec.yml
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/upload-apple-test-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
pull_request:
paths:
- .github/workflows/upload-apple-test-specs.yml
- examples/demo-apps/apple_ios/default-ios-device-farm-appium-test-spec.yml
- extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
push:
branches:
- main
paths:
- .github/workflows/upload-apple-test-specs.yml
- examples/demo-apps/apple_ios/default-ios-device-farm-appium-test-spec.yml
- extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml

concurrency:
# NB: This concurency group needs to be different than the one used in apple-perf, otherwise
Expand All @@ -32,7 +32,7 @@ jobs:
${{ github.repository }}/${{ github.run_id }}/artifacts
retention-days: 1
if-no-files-found: error
path: examples/demo-apps/apple_ios/default-ios-device-farm-appium-test-spec.yml
path: extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml

validate-apple-test-spec:
needs: upload-apple-test-spec-for-validation
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:

- name: Upload the spec to S3 ossci-ios bucket
shell: bash
working-directory: examples/demo-apps/apple_ios
working-directory: extension/benchmark/apple/Benchmark/
env:
SPEC_FILE: default-ios-device-farm-appium-test-spec.yml
run: |
Expand Down
10 changes: 5 additions & 5 deletions build/build_android_llm_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ build_android_demo_apps() {
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew build assembleAndroidTest
popd

mkdir -p extension/android/benchmark/app/libs
cp ${BUILD_AAR_DIR}/executorch.aar extension/android/benchmark/app/libs
pushd extension/android/benchmark
mkdir -p extension/benchmark/android/benchmark/app/libs
cp ${BUILD_AAR_DIR}/executorch.aar extension/benchmark/android/benchmark/app/libs
pushd extension/benchmark/android/benchmark
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew build assembleAndroidTest
popd
}
Expand All @@ -135,8 +135,8 @@ collect_artifacts_to_be_uploaded() {
# Collect MiniBench APK
MINIBENCH_APP_DIR="${ARTIFACTS_DIR_NAME}/minibench"
mkdir -p "${MINIBENCH_APP_DIR}"
cp extension/android/benchmark/app/build/outputs/apk/debug/*.apk "${MINIBENCH_APP_DIR}"
cp extension/android/benchmark/app/build/outputs/apk/androidTest/debug/*.apk "${MINIBENCH_APP_DIR}"
cp extension/benchmark/android/benchmark/app/build/outputs/apk/debug/*.apk "${MINIBENCH_APP_DIR}"
cp extension/benchmark/android/benchmark/app/build/outputs/apk/androidTest/debug/*.apk "${MINIBENCH_APP_DIR}"
}

BUILD_AAR_DIR="$(mktemp -d)"
Expand Down
2 changes: 1 addition & 1 deletion build/build_apple_llm_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
set -euo pipefail

ARTIFACTS_DIR_NAME="$1"
APP_PATH="extension/apple/Benchmark/Benchmark"
APP_PATH="extension/benchmark/apple/Benchmark/Benchmark"

xcodebuild build-for-testing \
-project "${APP_PATH}.xcodeproj" \
Expand Down
45 changes: 45 additions & 0 deletions extension/benchmark/apple/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
AccessModifierOffset: -1
AlignEscapedNewlinesLeft: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Attach
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 80
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: true
IndentCaseLabels: false
IndentFunctionDeclarationAfterType: false
IndentWidth: 2
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 10
PenaltyBreakComment: 60
PenaltyBreakFirstLessLess: 20
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...
Loading
Loading