Skip to content

Commit cb99857

Browse files
committed
Update on "[ExecuTorch][Weight Sharing] Track Named Data Store in EdgeProgramManager"
We enable Backends to return Named Data by adding NamedDataStoreOutput to the preprocess result. This is a completely BC change, as no backends with an implemented preprocess will see any change if nothing is explicitly implemented. For backend developers to leverage the new NamedDataStore, they can initialize a new NamedDataStore() within preprocess, add_named_data to the data store, and return the NamedDataStore.get_named_data_store_output() in the preprocess result like such: ``` def preprocess(ExportedProgram, List[CompileSpecs]) -> PreprocessResult: named_data_store = NamedDataStore() for node in exported_program.graph.nodes: named_data_store.add_named_data("name", bytes) return PreprocessResult( processed_bytes=bytes, debug_handle_map={}, data_store_output= named_data_store.get_named_data_store_output() ) ``` Under the hood, the data store output is embedded in the loweredbackendmodule, (serializing loweredbackendmodule by itself with the a named_data_store_output is still a todo). But via the EdgeProgramManager path, we add the named_data_store_outputs to the edge_program_manger's named data store to keep track of all the named data returned by backends. Differential Revision: [D70451660](https://our.internmc.facebook.com/intern/diff/D70451660/) [ghstack-poisoned]
2 parents 005ddb9 + bae20c0 commit cb99857

File tree

126 files changed

+2138
-1276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2138
-1276
lines changed

.ci/docker/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ case "${IMAGE_NAME}" in
2929
LINTRUNNER=""
3030
CLANG_VERSION=12
3131
;;
32+
executorch-ubuntu-22.04-gcc11-aarch64)
33+
LINTRUNNER=""
34+
GCC_VERSION=11
35+
;;
3236
executorch-ubuntu-22.04-linter)
3337
LINTRUNNER=yes
3438
CLANG_VERSION=12

.ci/docker/common/install_conda.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1313
install_miniconda() {
1414
BASE_URL="https://repo.anaconda.com/miniconda"
1515
CONDA_FILE="Miniconda3-py${PYTHON_VERSION//./}_${MINICONDA_VERSION}-Linux-x86_64.sh"
16+
if [[ $(uname -m) == "aarch64" ]]; then
17+
CONDA_FILE="Miniconda3-py${PYTHON_VERSION//./}_${MINICONDA_VERSION}-Linux-aarch64.sh"
18+
fi
1619

1720
mkdir -p /opt/conda
1821
chown ci-user:ci-user /opt/conda
@@ -36,7 +39,7 @@ install_python() {
3639

3740
# From https://github.com/pytorch/pytorch/blob/main/.ci/docker/common/install_conda.sh
3841
if [[ $(uname -m) == "aarch64" ]]; then
39-
conda_install "openblas==0.3.28=*openmp*"
42+
conda_install "openblas==0.3.29=*openmp*" -c conda-forge
4043
else
4144
conda_install mkl=2022.1.0 mkl-include=2022.1.0
4245
fi

.ci/scripts/gather_test_models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# This source code is licensed under the BSD-style license found in the
66
# LICENSE file in the root directory of this source tree.
77

8+
# WARNING: The CI runner logic should directly be in the corresponding yml files
9+
# This file will be deleted once the reference in periodic.yml is deleted.
10+
811
import itertools
912
import json
1013
import os

.ci/scripts/unittest-buck2.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ buck2 query "//backends/apple/... + //backends/example/... + \
1919

2020
UNBUILDABLE_OPTIMIZED_OPS_REGEX="gelu|fft_r2c|log_softmax"
2121
BUILDABLE_OPTIMIZED_OPS=$(buck2 query //kernels/optimized/cpu/... | grep -E -v $UNBUILDABLE_OPTIMIZED_OPS_REGEX)
22+
23+
BUILDABLE_KERNELS_PRIM_OPS_TARGETS=$(buck2 query //kernels/prim_ops/... | grep -v prim_ops_test_py)
2224
# TODO: expand the covered scope of Buck targets.
2325
# //runtime/kernel/... is failing because //third-party:torchgen_files's shell script can't find python on PATH.
2426
# //runtime/test/... requires Python torch, which we don't have in our OSS buck setup.
25-
buck2 test $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... //runtime/backend/... //runtime/core/... \
27+
buck2 test $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... \
28+
$BUILDABLE_KERNELS_PRIM_OPS_TARGETS //runtime/backend/... //runtime/core/... \
2629
//runtime/executor: //runtime/kernel/... //runtime/platform/...

.github/workflows/apple-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ jobs:
353353
with:
354354
runner: macos-latest-xlarge
355355
python-version: '3.11'
356-
submodules: 'true'
356+
submodules: 'recursive'
357357
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
358358
upload-artifact: ios-apps
359359
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD

.github/workflows/apple.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
with:
5050
runner: macos-latest-xlarge
5151
python-version: '3.11'
52-
submodules: 'true'
52+
submodules: 'recursive'
5353
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
5454
timeout: 90
5555
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_DEMO_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
@@ -136,7 +136,7 @@ jobs:
136136
with:
137137
runner: macos-latest-xlarge
138138
python-version: '3.11'
139-
submodules: 'true'
139+
submodules: 'recursive'
140140
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
141141
upload-artifact: executorch-frameworks-ios
142142
timeout: 90
@@ -279,7 +279,7 @@ jobs:
279279
with:
280280
runner: macos-latest-xlarge
281281
python-version: '3.11'
282-
submodules: 'true'
282+
submodules: 'recursive'
283283
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
284284
upload-artifact: ios-benchmark-app
285285
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD

.github/workflows/build-wheels-m1.yml renamed to .github/workflows/build-wheels-macos.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# From https://github.com/pytorch/test-infra/wiki/Using-Nova-Reusable-Build-Workflows
2-
name: Build M1 Wheels
2+
name: Build macOS Wheels
33

44
on:
55
pull_request:
66
paths:
77
- build/packaging/**
8-
- .github/workflows/build-wheels-m1.yml
8+
- .github/workflows/build-wheels-macos.yml
99
push:
1010
branches:
1111
- nightly
@@ -56,7 +56,7 @@ jobs:
5656
# files to look at.
5757
submodules: true
5858
delocate-wheel: false
59-
env-var-script: build/packaging/env_var_script_m1.sh
59+
env-var-script: build/packaging/env_var_script_macos.sh
6060
pre-script: ${{ matrix.pre-script }}
6161
post-script: ${{ matrix.post-script }}
6262
package-name: ${{ matrix.package-name }}

.github/workflows/docker-builds.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@ env:
2727

2828
jobs:
2929
docker-build:
30-
runs-on: [self-hosted, linux.2xlarge]
3130
timeout-minutes: 240
3231
strategy:
3332
fail-fast: false
3433
matrix:
34+
runner: [linux.2xlarge]
35+
docker-image-name: [
36+
executorch-ubuntu-22.04-gcc9,
37+
executorch-ubuntu-22.04-clang12,
38+
executorch-ubuntu-22.04-linter,
39+
executorch-ubuntu-22.04-arm-sdk,
40+
executorch-ubuntu-22.04-qnn-sdk,
41+
executorch-ubuntu-22.04-mediatek-sdk,
42+
executorch-ubuntu-22.04-clang12-android
43+
]
3544
include:
36-
- docker-image-name: executorch-ubuntu-22.04-gcc9
37-
- docker-image-name: executorch-ubuntu-22.04-clang12
38-
- docker-image-name: executorch-ubuntu-22.04-linter
39-
- docker-image-name: executorch-ubuntu-22.04-arm-sdk
40-
- docker-image-name: executorch-ubuntu-22.04-qnn-sdk
41-
- docker-image-name: executorch-ubuntu-22.04-mediatek-sdk
42-
- docker-image-name: executorch-ubuntu-22.04-clang12-android
45+
- docker-image-name: executorch-ubuntu-22.04-gcc11-aarch64
46+
runner: linux.arm64.2xlarge
47+
48+
runs-on: [self-hosted, "${{ matrix.runner }}"]
4349
env:
4450
DOCKER_IMAGE: 308535385114.dkr.ecr.us-east-1.amazonaws.com/executorch/${{ matrix.docker-image-name }}
4551
steps:

.github/workflows/pull.yml

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,6 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16-
gather-models:
17-
runs-on: ubuntu-22.04
18-
outputs:
19-
models: ${{ steps.gather-models.outputs.models }}
20-
steps:
21-
- uses: actions/checkout@v3
22-
with:
23-
submodules: 'false'
24-
- uses: actions/setup-python@v4
25-
with:
26-
python-version: '3.10'
27-
- name: Extract the list of models to test
28-
id: gather-models
29-
run: |
30-
set -eux
31-
32-
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --event "${GITHUB_EVENT_NAME}"
33-
3416
test-setup-linux-gcc:
3517
name: test-setup-linux-gcc
3618
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
@@ -56,35 +38,90 @@ jobs:
5638
# Build and test ExecuTorch with the add model on portable backend.
5739
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "add" "${BUILD_TOOL}" "portable"
5840
41+
test-models-linux-basic:
42+
name: test-models-linux-basic
43+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
44+
permissions:
45+
id-token: write
46+
contents: read
47+
strategy:
48+
matrix:
49+
model: [mv3, vit]
50+
backend: [portable, xnnpack-quantization-delegation]
51+
build-tool: [cmake, buck2]
52+
runner: [linux.2xlarge]
53+
fail-fast: false
54+
with:
55+
runner: ${{ matrix.runner }}
56+
docker-image: executorch-ubuntu-22.04-clang12
57+
submodules: 'true'
58+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
59+
timeout: 90
60+
script: |
61+
# The generic Linux job chooses to use base env, not the one setup by the image
62+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
63+
conda activate "${CONDA_ENV}"
64+
65+
MODEL_NAME=${{ matrix.model }}
66+
BUILD_TOOL=${{ matrix.build-tool }}
67+
BACKEND=${{ matrix.backend }}
68+
69+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "${BUILD_TOOL}"
70+
# Build and test ExecuTorch
71+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
72+
5973
test-models-linux:
6074
name: test-models-linux
6175
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
6276
permissions:
6377
id-token: write
6478
contents: read
65-
needs: gather-models
6679
strategy:
67-
matrix: ${{ fromJSON(needs.gather-models.outputs.models) }}
80+
matrix:
81+
model: [linear, add, add_mul, ic3, mv2, resnet18, resnet50, mobilebert, emformer_transcribe]
82+
backend: [portable, xnnpack-quantization-delegation]
83+
runner: [linux.2xlarge]
84+
include:
85+
- model: ic4
86+
backend: portable
87+
runner: linux.4xlarge.memory
88+
- model: ic4
89+
backend: xnnpack-quantization-delegation
90+
runner: linux.4xlarge.memory
91+
- model: emformer_join
92+
backend: portable
93+
runner: linux.4xlarge.memory
94+
- model: emformer_join
95+
backend: xnnpack-quantization-delegation
96+
runner: linux.4xlarge.memory
97+
- model: phi-4-mini
98+
backend: portable
99+
runner: linux.4xlarge.memory
100+
- model: llama3_2_vision_encoder
101+
backend: portable
102+
runner: linux.4xlarge.memory
103+
- model: w2l
104+
backend: portable
105+
runner: linux.4xlarge.memory
68106
fail-fast: false
69107
with:
70108
runner: ${{ matrix.runner }}
71109
docker-image: executorch-ubuntu-22.04-clang12
72110
submodules: 'true'
73111
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
74-
timeout: ${{ matrix.timeout }}
112+
timeout: 90
75113
script: |
76114
# The generic Linux job chooses to use base env, not the one setup by the image
77115
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
78116
conda activate "${CONDA_ENV}"
79117
80118
MODEL_NAME=${{ matrix.model }}
81-
BUILD_TOOL=${{ matrix.build-tool }}
119+
BUILD_TOOL=cmake
82120
BACKEND=${{ matrix.backend }}
83-
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
84121
85122
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "${BUILD_TOOL}"
86123
# Build and test ExecuTorch
87-
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
124+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
88125
89126
test-llama-runner-linux:
90127
name: test-llama-runner-linux

.github/workflows/trunk.yml

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,40 @@ concurrency:
1818
cancel-in-progress: true
1919

2020
jobs:
21-
gather-models:
22-
runs-on: ubuntu-22.04
23-
outputs:
24-
models: ${{ steps.gather-models.outputs.models }}
25-
steps:
26-
- uses: actions/checkout@v3
27-
with:
28-
submodules: 'false'
29-
- uses: actions/setup-python@v4
30-
with:
31-
python-version: '3.10'
32-
- name: Extract the list of models to test
33-
id: gather-models
34-
run: |
35-
set -eux
36-
37-
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --target-os macos --event "${GITHUB_EVENT_NAME}"
38-
3921
test-models-macos:
4022
name: test-models-macos
4123
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
42-
needs: gather-models
4324
strategy:
44-
matrix: ${{ fromJSON(needs.gather-models.outputs.models) }}
25+
matrix:
26+
model: [add, add_mul, emformer_join, emformer_transcribe, ic3, ic4, linear, llama2, mobilebert, mv2, mv3, resnet18, resnet50, vit, w2l]
27+
backend: [portable, xnnpack-quantization-delegation]
28+
include:
29+
- model: efficient_sam
30+
backend: portable
31+
- model: llama
32+
backend: portable
33+
- model: llama3_2_vision_encoder
34+
backend: portable
35+
- model: lstm
36+
backend: portable
37+
- model: mul
38+
backend: portable
39+
- model: phi-4-mini
40+
backend: portable
41+
- model: qwen2_5
42+
backend: portable
43+
- model: softmax
44+
backend: portable
4545
fail-fast: false
4646
with:
47-
runner: ${{ matrix.runner }}
47+
runner: macos-m1-stable
4848
python-version: '3.11'
4949
submodules: 'true'
5050
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
51-
timeout: ${{ matrix.timeout }}
51+
timeout: 90
5252
script: |
5353
MODEL_NAME=${{ matrix.model }}
54-
BUILD_TOOL=${{ matrix.build-tool }}
54+
BUILD_TOOL=cmake
5555
BACKEND=${{ matrix.backend }}
5656
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
5757
@@ -61,6 +61,37 @@ jobs:
6161
# Build and test executorch
6262
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
6363
64+
test-models-linux-aarch64:
65+
name: test-models-linux-aarch64
66+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
67+
permissions:
68+
id-token: write
69+
contents: read
70+
strategy:
71+
matrix:
72+
model: [linear, add, add_mul, ic3, ic4, mv2, mv3, resnet18, resnet50, vit, w2l, mobilebert, emformer_join, emformer_transcribe]
73+
backend: [portable, xnnpack-quantization-delegation]
74+
runner: [linux.arm64.2xlarge]
75+
fail-fast: false
76+
with:
77+
runner: ${{ matrix.runner }}
78+
docker-image: executorch-ubuntu-22.04-gcc11-aarch64
79+
submodules: 'true'
80+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
81+
timeout: 90
82+
script: |
83+
# The generic Linux job chooses to use base env, not the one setup by the image
84+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
85+
conda activate "${CONDA_ENV}"
86+
87+
MODEL_NAME=${{ matrix.model }}
88+
BUILD_TOOL="cmake"
89+
BACKEND=${{ matrix.backend }}
90+
91+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "${BUILD_TOOL}"
92+
# Build and test ExecuTorch
93+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
94+
6495
test-custom-ops-macos:
6596
name: test-custom-ops-macos
6697
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -243,13 +274,13 @@ jobs:
243274
eval "$(conda shell.bash hook)"
244275
245276
# Install requirements
246-
sh install_requirements.sh
247-
sh backends/apple/coreml/scripts/install_requirements.sh
248-
python install_executorch.py --pybind coreml
249-
sh examples/models/llama/install_requirements.sh
277+
${CONDA_RUN} sh install_requirements.sh
278+
${CONDA_RUN} sh backends/apple/coreml/scripts/install_requirements.sh
279+
${CONDA_RUN} python install_executorch.py --pybind coreml
280+
${CONDA_RUN} sh examples/models/llama/install_requirements.sh
250281
251282
# Test ANE llama
252-
sh .ci/scripts/test_ane_static_llama.sh
283+
${CONDA_RUN} sh .ci/scripts/test_ane_static_llama.sh
253284
254285
test-llama-runner-macos:
255286
name: test-llama-runner-mac

0 commit comments

Comments
 (0)