Skip to content

Commit

Permalink
Update on "[executorch] Migrate extension/runner_util to new namespace"
Browse files Browse the repository at this point in the history
Migrate these headers to the new `::executorch::extension` namespace. Add temporary aliases from the old `::torch::executor` namespace so we can migrate users incrementally.

Differential Revision: [D60938933](https://our.internmc.facebook.com/intern/diff/D60938933/)

[ghstack-poisoned]
  • Loading branch information
dbort committed Aug 14, 2024
2 parents c944083 + af1888d commit eea9e18
Show file tree
Hide file tree
Showing 243 changed files with 6,668 additions and 2,407 deletions.
4 changes: 2 additions & 2 deletions .ci/scripts/test_llama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ cleanup_files() {
prepare_artifacts_upload() {
if [ -n "$UPLOAD_DIR" ]; then
echo "Preparing for uploading generated artifacs"
zip -j model.zip "${EXPORTED_MODEL_NAME}" tokenizer.bin
mkdir -p "${UPLOAD_DIR}"
zip -j "model.zip" "${MODEL_NAME}" tokenizer.bin
cp "model.zip" "${UPLOAD_DIR}"
mv model.zip "${UPLOAD_DIR}"
fi
}

Expand Down
Empty file added .github/ghstack_direct
Empty file.
57 changes: 53 additions & 4 deletions .github/workflows/android-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,47 @@ on:
description: The list of configs used the benchmark
required: false
type: string
test_spec:
description: The test spec to drive the test on AWS devices
required: false
type: string
default: https://ossci-android.s3.amazonaws.com/executorch/android-llm-device-farm-test-spec.yml
workflow_call:
inputs:
models:
description: Models to be benchmarked
required: false
type: string
default: stories110M
devices:
description: Target devices to run benchmark
required: false
type: string
default: samsung_galaxy_s2x
delegates:
description: Backend delegates
required: false
type: string
default: xnnpack
threadpool:
description: Run with threadpool?
required: false
type: boolean
default: false
benchmark_configs:
description: The list of configs used the benchmark
required: false
type: string
test_spec:
description: The test spec to drive the test on AWS devices
required: false
type: string
default: https://ossci-android.s3.amazonaws.com/executorch/android-llm-device-farm-test-spec.yml

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true

permissions: read-all

jobs:
set-parameters:
runs-on: linux.2xlarge
Expand All @@ -48,11 +82,27 @@ jobs:
- name: Set parameters
id: set-parameters
shell: bash
env:
# Separate default values from the workflow dispatch. To ensure defaults are accessible
# during scheduled runs and to provide flexibility for different defaults between
# on-demand and periodic benchmarking.
CRON_DEFAULT_MODELS: "stories110M"
CRON_DEFAULT_DEVICES: "samsung_galaxy_s2x"
CRON_DEFAULT_DELEGATES: "xnnpack"
run: |
set -ex
MODELS="${{ inputs.models }}"
if [ -z "$MODELS" ]; then
MODELS="$CRON_DEFAULT_MODELS"
fi
DEVICES="${{ inputs.devices }}"
if [ -z "$DEVICES" ]; then
DEVICES="$CRON_DEFAULT_DEVICES"
fi
DELEGATES="${{ inputs.delegates }}"
if [ -z "$DELEGATES" ]; then
DELEGATES="$CRON_DEFAULT_DELEGATES"
fi
# Mapping devices to their corresponding device-pool-arn
declare -A DEVICE_POOL_ARNS
Expand Down Expand Up @@ -218,7 +268,6 @@ jobs:
# TODO: Hard code llm_demo_bpe for now in this job.
android-app-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/llm_demo_bpe/app-debug.apk
android-test-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/llm_demo_bpe/app-debug-androidTest.apk
# The test spec can be downloaded from https://ossci-assets.s3.amazonaws.com/android-llama2-device-farm-test-spec.yml
test-spec: arn:aws:devicefarm:us-west-2:308535385114:upload:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/abd86868-fa63-467e-a5c7-218194665a77
test-spec: ${{ inputs.test_spec }}
# Uploaded to S3 from the previous job
extra-data: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/${{ matrix.model }}_${{ matrix.delegate }}/model.zip
3 changes: 1 addition & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ jobs:
# Uploaded to S3 from the previous job, the name of the app comes from the project itself
android-app-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/llm_demo_${{ matrix.tokenizer }}/app-debug.apk
android-test-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/llm_demo_${{ matrix.tokenizer }}/app-debug-androidTest.apk
# The test spec can be downloaded from https://ossci-assets.s3.amazonaws.com/android-llama2-device-farm-test-spec.yml
test-spec: arn:aws:devicefarm:us-west-2:308535385114:upload:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/abd86868-fa63-467e-a5c7-218194665a77
test-spec: https://ossci-android.s3.amazonaws.com/executorch/android-llm-device-farm-test-spec.yml
# Among the input, this is the biggest file, so it is cached on AWS to make the test faster. Note that the file is deleted by AWS after 30
# days and the job will automatically re-upload the file when that happens.
extra-data: https://ossci-assets.s3.amazonaws.com/executorch-android-llama2-7b-0717.zip
22 changes: 4 additions & 18 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,27 +205,13 @@ jobs:
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
# install pybind
bash install_requirements.sh --pybind xnnpack
# install Llava requirements
bash examples/models/llama2/install_requirements.sh
bash examples/models/llava/install_requirements.sh
# run export_llava.sh
python examples/models/llava/export_llava.py --use-sdpa-with-kv-cache --pte-name llava_custom_sdpa.pte
# verify file exists
if [ ! -f "llava_custom_sdpa.pte" ]; then
echo "llava_custom_sdpa.pte not found!"
exit 1
fi
python examples/models/llava/export_llava.py --no-use-sdpa-with-kv-cache --pte-name llava.pte
# verify file exists
if [ ! -f "llava.pte" ]; then
echo "llava.pte not found!"
exit 1
fi
# run python unittest
python -m unittest examples.models.llava.test.test_llava
Expand Down Expand Up @@ -337,7 +323,7 @@ jobs:
size=${arr[4]}
# threshold=48120 on devserver with gcc11.4
# todo(lfq): update once binary size is below 50kb.
threshold="51768"
threshold="51784"
if [[ "$size" -le "$threshold" ]]; then
echo "Success $size <= $threshold"
else
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/upload-test-specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Upload AWS Device Farm test specs

on:
pull_request:
paths:
- .github/workflows/upload-test-specs.yml
- examples/demo-apps/android/LlamaDemo/android-llm-device-farm-test-spec.yml
push:
branches:
- main
paths:
- .github/workflows/upload-test-specs.yml
- examples/demo-apps/android/LlamaDemo/android-llm-device-farm-test-spec.yml

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true

jobs:
upload-android-test-spec-for-validation:
runs-on: linux.2xlarge
steps:
- uses: actions/checkout@v3

- name: Upload the spec as a GitHub artifact for validation
uses: seemethere/upload-artifact-s3@v5
with:
s3-bucket: gha-artifacts
s3-prefix: |
${{ github.repository }}/${{ github.run_id }}/artifact
retention-days: 1
if-no-files-found: error
path: examples/demo-apps/android/LlamaDemo/android-llm-device-farm-test-spec.yml

validate-android-test-spec:
needs: upload-android-test-spec-for-validation
uses: ./.github/workflows/android-perf.yml
permissions:
id-token: write
contents: read
with:
# Just use a small model here with a minimal amount of configuration to test the spec
models: stories110M
devices: samsung_galaxy_s2x
delegates: xnnpack
test_spec: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/android-llm-device-farm-test-spec.yml

upload-android-test-spec:
needs: validate-android-test-spec
runs-on: ubuntu-22.04
timeout-minutes: 15
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: pip

- name: configure aws credentials
uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-android
aws-region: us-east-1

- name: Only push to S3 when running the workflow manually from main branch
if: ${{ github.ref == 'refs/heads/main' }}
shell: bash
run: |
set -eux
echo "UPLOAD_ON_MAIN=1" >> "${GITHUB_ENV}"
- name: Upload the spec to S3 ossci-android bucket
shell: bash
working-directory: examples/demo-apps/android/LlamaDemo/
env:
SPEC_FILE: android-llm-device-farm-test-spec.yml
run: |
set -eux
pip install awscli==1.32.18
AWS_CMD="aws s3 cp --dryrun"
if [[ "${UPLOAD_ON_MAIN:-0}" == "1" ]]; then
AWS_CMD="aws s3 cp"
fi
shasum -a 256 "${SPEC_FILE}"
${AWS_CMD} "${SPEC_FILE}" s3://ossci-android/executorch/ --acl public-read
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
[submodule "backends/xnnpack/third-party/pthreadpool"]
path = backends/xnnpack/third-party/pthreadpool
url = https://github.com/Maratyszcza/pthreadpool.git
[submodule "examples/third-party/LLaVA"]
path = examples/third-party/LLaVA
url = https://github.com/haotian-liu/LLaVA.git
[submodule "examples/third-party/fbjni"]
path = examples/third-party/fbjni
url = https://github.com/facebookincubator/fbjni.git
Expand Down
2 changes: 1 addition & 1 deletion backends/apple/coreml/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ xcode-select --install

```bash
cd executorch
./build/build_apple_frameworks.sh --Release --coreml
./build/build_apple_frameworks.sh --coreml
```
5. Open the project in Xcode, and drag `executorch.xcframework` and `coreml_backend.xcframework` frameworks generated from Step 2 to Frameworks.

Expand Down
4 changes: 2 additions & 2 deletions backends/apple/mps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ add_library(mpsdelegate ${_mps_backend__srcs})
find_library(FOUNDATION_FRAMEWORK Foundation)
find_library(METAL_FRAMEWORK Metal)
find_library(MPS_FRAMEWORK MetalPerformanceShaders)
find_library(MPS_GRAPG_FRAMEWORK MetalPerformanceShadersGraph)
find_library(MPS_GRAPH_FRAMEWORK MetalPerformanceShadersGraph)

target_link_libraries(
mpsdelegate
Expand All @@ -79,7 +79,7 @@ target_link_libraries(
${FOUNDATION_FRAMEWORK}
${METAL_FRAMEWORK}
${MPS_FRAMEWORK}
${MPS_GRAPG_FRAMEWORK}
${MPS_GRAPH_FRAMEWORK}
)

target_link_options_shared_lib(mpsdelegate)
Expand Down
Loading

0 comments on commit eea9e18

Please sign in to comment.