Skip to content

Commit 74a9cbd

Browse files
committed
Update on "Enable aoti for preprocess"
Land and update torch nightly pin after: pytorch/pytorch#137063 Test Plan: With pytorch/pytorch#137063: ``` pytest -c /dev/null -v -n auto examples/models/llama3_2_vision/preprocess/ ``` [ghstack-poisoned]
2 parents 58fa495 + 5530e28 commit 74a9cbd

File tree

161 files changed

+6167
-825
lines changed

Some content is hidden

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

161 files changed

+6167
-825
lines changed

.github/workflows/_android.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ jobs:
6666
# avoid permission issue
6767
sudo chown -R "${USER}" /opt/android
6868
69+
- name: Download Artifacts
70+
shell: bash
71+
run: |
72+
set -eux
73+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug.apk
74+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug-androidTest.apk
75+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
76+
unzip model.zip
77+
mv *.pte model.pte
78+
6979
- name: Gradle cache
7080
uses: gradle/actions/setup-gradle@v3
7181

.github/workflows/_unittest.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
3838
.ci/scripts/setup-linux.sh cmake
3939
40+
# Install llama3_2_vision dependencies.
41+
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
42+
4043
# Run pytest with coverage
4144
pytest -n auto --cov=./ --cov-report=xml
4245
# Run gtest
@@ -67,6 +70,10 @@ jobs:
6770
${CONDA_RUN} --no-capture-output \
6871
.ci/scripts/setup-macos.sh cmake
6972
73+
# Install llama3_2_vision dependencies.
74+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
75+
./examples/models/llama3_2_vision/install_requirements.sh
76+
7077
# Run pytest with coverage
7178
${CONDA_RUN} pytest -n auto --cov=./ --cov-report=xml
7279
# Run gtest

.github/workflows/ghstack_land.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- 'gh/kimishpatel/[0-9]+/base'
1212
- 'gh/kirklandsign/[0-9]+/base'
1313
- 'gh/larryliu0820/[0-9]+/base'
14+
- 'gh/lucylq/[0-9]+/base'
1415
- 'gh/manuelcandales/[0-9]+/base'
1516
- 'gh/mcr229/[0-9]+/base'
1617
- 'gh/swolchok/[0-9]+/base'

.github/workflows/pull.yml

Lines changed: 17 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ jobs:
3535
name: test-setup-linux-gcc
3636
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
3737
strategy:
38-
matrix:
39-
include:
40-
- build-tool: cmake
4138
fail-fast: false
4239
with:
4340
runner: linux.2xlarge
@@ -50,7 +47,7 @@ jobs:
5047
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
5148
conda activate "${CONDA_ENV}"
5249
53-
BUILD_TOOL=${{ matrix.build-tool }}
50+
BUILD_TOOL="cmake"
5451
5552
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
5653
# Build and test ExecuTorch with the add model on portable backend.
@@ -89,20 +86,11 @@ jobs:
8986
strategy:
9087
matrix:
9188
dtype: [fp32]
92-
build-tool: [buck2, cmake]
9389
mode: [portable, xnnpack+custom, xnnpack+custom+qe]
9490
include:
9591
- dtype: bf16
96-
build-tool: cmake
9792
mode: portable
9893
- dtype: bf16
99-
build-tool: buck2
100-
mode: portable
101-
- dtype: bf16
102-
build-tool: cmake
103-
mode: custom
104-
- dtype: bf16
105-
build-tool: buck2
10694
mode: custom
10795
fail-fast: false
10896
with:
@@ -111,29 +99,30 @@ jobs:
11199
submodules: 'true'
112100
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
113101
timeout: 900
102+
upload-artifact: android-models
103+
upload-artifact-to-s3: true
114104
script: |
115105
# The generic Linux job chooses to use base env, not the one setup by the image
116106
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
117107
conda activate "${CONDA_ENV}"
118108
119109
DTYPE=${{ matrix.dtype }}
120-
BUILD_TOOL=${{ matrix.build-tool }}
110+
BUILD_TOOL="cmake"
121111
MODE=${{ matrix.mode }}
112+
ARTIFACTS_DIR_NAME="artifacts-to-be-uploaded/${DTYPE}-${MODE}"
113+
ARTIFACTS_DIR_NAME="${ARTIFACTS_DIR_NAME/+/-}"
122114
123115
# Setup executorch
124-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
116+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
125117
# Install requirements for export_llama
126118
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
127119
# Test llama2
128-
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
120+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}" "${ARTIFACTS_DIR_NAME}"
129121
130122
test-llama-runner-linux-android:
131123
name: test-llama-runner-linux-android
132124
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
133125
strategy:
134-
matrix:
135-
include:
136-
- build-tool: cmake
137126
fail-fast: false
138127
with:
139128
runner: linux.2xlarge
@@ -146,18 +135,14 @@ jobs:
146135
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
147136
conda activate "${CONDA_ENV}"
148137
149-
BUILD_TOOL=${{ matrix.build-tool }}
138+
BUILD_TOOL="cmake"
150139
PYTHON_EXECUTABLE=python \
151140
bash .ci/scripts/build_llama_android.sh "${BUILD_TOOL}"
152141
153142
test-custom-ops-linux:
154143
name: test-custom-ops-linux
155144
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
156145
strategy:
157-
matrix:
158-
include:
159-
- build-tool: buck2
160-
- build-tool: cmake
161146
fail-fast: false
162147
with:
163148
runner: linux.2xlarge
@@ -170,7 +155,7 @@ jobs:
170155
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
171156
conda activate "${CONDA_ENV}"
172157
173-
BUILD_TOOL=${{ matrix.build-tool }}
158+
BUILD_TOOL="cmake"
174159
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
175160
# Test custom ops
176161
PYTHON_EXECUTABLE=python bash examples/portable/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
@@ -179,10 +164,6 @@ jobs:
179164
name: test-selective-build-linux
180165
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
181166
strategy:
182-
matrix:
183-
include:
184-
- build-tool: buck2
185-
- build-tool: cmake
186167
fail-fast: false
187168
with:
188169
runner: linux.2xlarge
@@ -195,7 +176,7 @@ jobs:
195176
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
196177
conda activate "${CONDA_ENV}"
197178
198-
BUILD_TOOL=${{ matrix.build-tool }}
179+
BUILD_TOOL="cmake"
199180
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
200181
# Test selective build
201182
PYTHON_EXECUTABLE=python bash examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"
@@ -231,41 +212,10 @@ jobs:
231212
# run e2e (export, tokenizer and runner)
232213
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llava.sh
233214
234-
test-preprocess-linux:
235-
name: test-preprocess-linux
236-
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
237-
strategy:
238-
fail-fast: false
239-
with:
240-
runner: linux.24xlarge
241-
docker-image: executorch-ubuntu-22.04-clang12
242-
submodules: 'true'
243-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
244-
timeout: 90
245-
script: |
246-
# The generic Linux job chooses to use base env, not the one setup by the image
247-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
248-
conda activate "${CONDA_ENV}"
249-
250-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
251-
252-
# install pybind
253-
bash install_requirements.sh --pybind xnnpack
254-
255-
# install preprocess requirements
256-
bash examples/models/llama3_2_vision/install_requirements.sh
257-
258-
# run python unittest
259-
python -m unittest examples.models.llama3_2_vision.preprocess.test_preprocess
260-
261-
262215
test-quantized-aot-lib-linux:
263216
name: test-quantized-aot-lib-linux
264217
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
265218
strategy:
266-
matrix:
267-
include:
268-
- build-tool: cmake
269219
fail-fast: false
270220
with:
271221
runner: linux.2xlarge
@@ -278,17 +228,14 @@ jobs:
278228
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
279229
conda activate "${CONDA_ENV}"
280230
281-
BUILD_TOOL=${{ matrix.build-tool }}
231+
BUILD_TOOL="cmake"
282232
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
283233
PYTHON_EXECUTABLE=python bash examples/xnnpack/quantization/test_quantize.sh "${BUILD_TOOL}" mv2
284234
285235
test-pybind-build-linux:
286236
name: test-pybind-build-linux
287237
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
288238
strategy:
289-
matrix:
290-
include:
291-
- build-tool: cmake
292239
fail-fast: false
293240
with:
294241
runner: linux.2xlarge
@@ -302,7 +249,7 @@ jobs:
302249
conda activate "${CONDA_ENV}"
303250
304251
# build module for executorch.extension.pybindings.portable_lib
305-
BUILD_TOOL=${{ matrix.build-tool }}
252+
BUILD_TOOL="cmake"
306253
PYTHON_EXECUTABLE=python \
307254
EXECUTORCH_BUILD_XNNPACK=ON \
308255
EXECUTORCH_BUILD_PYBIND=ON \
@@ -377,6 +324,7 @@ jobs:
377324
378325
android:
379326
uses: ./.github/workflows/_android.yml
327+
needs: test-llama-runner-linux
380328

381329
unittest:
382330
uses: ./.github/workflows/_unittest.yml
@@ -385,10 +333,6 @@ jobs:
385333

386334
unittest-arm:
387335
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
388-
strategy:
389-
matrix:
390-
include:
391-
- build-tool: buck2
392336
with:
393337
runner: linux.2xlarge
394338
docker-image: executorch-ubuntu-22.04-arm-sdk
@@ -402,7 +346,7 @@ jobs:
402346
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
403347
conda activate "${CONDA_ENV}"
404348
405-
BUILD_TOOL=${{ matrix.build-tool }}
349+
BUILD_TOOL="cmake"
406350
407351
# Setup MacOS dependencies as there is no Docker support on MacOS atm
408352
PYTHON_EXECUTABLE=python \
@@ -424,7 +368,6 @@ jobs:
424368
strategy:
425369
matrix:
426370
dtype: [fp32]
427-
build-tool: [cmake]
428371
mode: [qnn]
429372
fail-fast: false
430373
with:
@@ -439,14 +382,14 @@ jobs:
439382
conda activate "${CONDA_ENV}"
440383
441384
DTYPE=${{ matrix.dtype }}
442-
BUILD_TOOL=${{ matrix.build-tool }}
385+
BUILD_TOOL="cmake"
443386
MODE=${{ matrix.mode }}
444387
445388
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
446389
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
447390
448391
# Setup executorch
449-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
392+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
450393
# Install requirements for export_llama
451394
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
452395
# Test llama2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ tools.
9292
├── runtime # Core C++ runtime.
9393
| ├── backend # Backend delegate runtime APIs.
9494
| ├── core # Core structures used across all levels of the runtime.
95-
| ├── executor # Model loading, initalization, and execution.
95+
| ├── executor # Model loading, initialization, and execution.
9696
| ├── kernel # Kernel registration and management.
9797
| ├── platform # Layer between architecture specific code and portable C++.
9898
├── schema # ExecuTorch PTE file format flatbuffer

backends/apple/coreml/compiler/coreml_preprocess.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,15 @@ def preprocess(
425425
CoreMLBackend.op_linear_quantizer_config_from_compile_specs(compile_specs)
426426
)
427427

428+
# Load the model if MODEL_TYPE is 'COMPILED_MODEL'. This step is necessary because
429+
# get_compiled_model_path() requires a loaded model.
430+
skip_model_load = model_type != CoreMLBackend.MODEL_TYPE.COMPILED_MODEL
428431
mlmodel = ct.convert(
429432
model=edge_program,
430433
source="pytorch",
431434
convert_to="mlprogram",
432435
pass_pipeline=ct.PassPipeline.DEFAULT,
433-
skip_model_load=True,
436+
skip_model_load=skip_model_load,
434437
compute_precision=model_compute_precision,
435438
minimum_deployment_target=minimum_deployment_target,
436439
compute_units=compute_units,

backends/apple/coreml/runtime/delegate/backend_delegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BackendDelegate {
2828
// Max models cache size in bytes.
2929
size_t max_models_cache_size = 10 * size_t(1024) * size_t(1024) * size_t(1024);
3030
// If set to `true`, delegate pre-warms the most recently used asset.
31-
bool should_prewarm_asset = true;
31+
bool should_prewarm_asset = false;
3232
// If set to `true`, delegate pre-warms the model in `init`.
3333
bool should_prewarm_model = true;
3434
};

backends/apple/coreml/runtime/delegate/com.apple.executorchcoreml_config.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>shouldPrewarmAsset</key>
6-
<true/>
6+
<false/>
77
<key>shouldPrewarmModel</key>
88
<true/>
99
<key>maxAssetsSizeInBytes</key>

backends/apple/coreml/runtime/test/CoreMLBackendDelegateTests.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ - (void)testStateProgramExecute {
209209
}
210210
#endif
211211

212+
- (void)testAddMulCompiledProgramExecute {
213+
NSURL *modelURL = [[self class] bundledResourceWithName:@"add_mul_compiled_coreml_all" extension:@"pte"];
214+
XCTAssertNotNil(modelURL);
215+
[self executeModelAtURL:modelURL nLoads:1 nExecutions:2];
216+
}
217+
212218
- (void)executeMultipleModelsConcurrently:(NSArray<NSURL *> *)modelURLs
213219
nLoads:(NSUInteger)nLoads
214220
nExecutions:(NSUInteger)nExecutions

backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
8307EB8A2C9262060011AE6D /* state_coreml_all.pte in Resources */ = {isa = PBXBuildFile; fileRef = 8307EB892C9262060011AE6D /* state_coreml_all.pte */; };
11+
838CA6872CD1965700462190 /* add_mul_compiled_coreml_all.pte in Resources */ = {isa = PBXBuildFile; fileRef = 838CA6862CD1965700462190 /* add_mul_compiled_coreml_all.pte */; };
1112
83BB78A02C65DA7300274ED7 /* ETCoreMLModelDebugInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BB789F2C65DA7300274ED7 /* ETCoreMLModelDebugInfo.mm */; };
1213
83BB78BF2C66AAAE00274ED7 /* add_mul_coreml_all.bin in Resources */ = {isa = PBXBuildFile; fileRef = 83BB78BD2C66AAAE00274ED7 /* add_mul_coreml_all.bin */; };
1314
83BB78C02C66AAAE00274ED7 /* add_mul_coreml_all.pte in Resources */ = {isa = PBXBuildFile; fileRef = 83BB78BE2C66AAAE00274ED7 /* add_mul_coreml_all.pte */; };
@@ -122,6 +123,7 @@
122123

123124
/* Begin PBXFileReference section */
124125
8307EB892C9262060011AE6D /* state_coreml_all.pte */ = {isa = PBXFileReference; lastKnownFileType = file; name = state_coreml_all.pte; path = ../test/models/state_coreml_all.pte; sourceTree = "<group>"; };
126+
838CA6862CD1965700462190 /* add_mul_compiled_coreml_all.pte */ = {isa = PBXFileReference; lastKnownFileType = file; name = add_mul_compiled_coreml_all.pte; path = ../test/models/add_mul_compiled_coreml_all.pte; sourceTree = "<group>"; };
125127
83BB789E2C65DA7300274ED7 /* ETCoreMLModelDebugInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ETCoreMLModelDebugInfo.h; path = ../sdk/ETCoreMLModelDebugInfo.h; sourceTree = "<group>"; };
126128
83BB789F2C65DA7300274ED7 /* ETCoreMLModelDebugInfo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = ETCoreMLModelDebugInfo.mm; path = ../sdk/ETCoreMLModelDebugInfo.mm; sourceTree = "<group>"; };
127129
83BB78BD2C66AAAE00274ED7 /* add_mul_coreml_all.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = add_mul_coreml_all.bin; path = ../test/models/add_mul_coreml_all.bin; sourceTree = "<group>"; };
@@ -606,6 +608,7 @@
606608
C98551992AD2542D009143F9 /* mul_coreml_all.bin */,
607609
C985519C2AD2542D009143F9 /* mul_coreml_all.pte */,
608610
C985519B2AD2542D009143F9 /* mv3_coreml_all.bin */,
611+
838CA6862CD1965700462190 /* add_mul_compiled_coreml_all.pte */,
609612
C98551982AD2542D009143F9 /* mv3_coreml_all.pte */,
610613
83BB78BD2C66AAAE00274ED7 /* add_mul_coreml_all.bin */,
611614
83BB78BE2C66AAAE00274ED7 /* add_mul_coreml_all.pte */,
@@ -680,6 +683,7 @@
680683
C985519E2AD2542D009143F9 /* mv3_coreml_all.pte in Resources */,
681684
C98551A02AD2542D009143F9 /* add_coreml_all.bin in Resources */,
682685
C98551A22AD2542D009143F9 /* mul_coreml_all.pte in Resources */,
686+
838CA6872CD1965700462190 /* add_mul_compiled_coreml_all.pte in Resources */,
683687
8307EB8A2C9262060011AE6D /* state_coreml_all.pte in Resources */,
684688
C98551A32AD2542D009143F9 /* add_coreml_all.pte in Resources */,
685689
);

0 commit comments

Comments
 (0)