Skip to content

Commit fb15d5c

Browse files
authored
Merge branch 'main' into jz/cache-log
2 parents ac58f3d + de41eaa commit fb15d5c

File tree

234 files changed

+6961
-2680
lines changed

Some content is hidden

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

234 files changed

+6961
-2680
lines changed

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
27e35de6c288bffad1b4d18b393579c1d1a95547
1+
08434df1f2f88c9770e59246caa2ff9c6f613270

.ci/docker/common/install_java.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
apt-get update
11+
12+
apt-get install -y --no-install-recommends openjdk-17-jdk

.ci/docker/ubuntu/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ ARG BUCK2_VERSION
3030
COPY ./common/install_buck.sh install_buck.sh
3131
RUN bash ./install_buck.sh && rm install_buck.sh
3232

33+
# Install java
34+
COPY ./common/install_java.sh install_java.sh
35+
RUN bash ./install_java.sh && rm install_java.sh
36+
3337
# Setup user
3438
COPY ./common/install_user.sh install_user.sh
3539
RUN bash ./install_user.sh && rm install_user.sh

.ci/scripts/build_llama_android.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ install_executorch_and_backend_lib() {
4242

4343
build_llama_runner() {
4444
echo "Building llama runner for Android..."
45+
pushd extension/llm/tokenizers
46+
echo "Updating tokenizers submodule"
47+
git submodule update --init
48+
popd
4549
ANDROID_ABI=arm64-v8a
4650
cmake -DBUCK2="${BUCK2}" \
4751
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK"/build/cmake/android.toolchain.cmake \

.ci/scripts/gather_test_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"dl3": "linux.4xlarge.memory",
3131
"emformer_join": "linux.4xlarge.memory",
3232
"emformer_predict": "linux.4xlarge.memory",
33+
"phi-4-mini": "linux.4xlarge.memory",
3334
}
3435
}
3536

.ci/scripts/test_ane_static_llama.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Copyright (c) Qualcomm Innovation Center, Inc.
3+
# All rights reserved
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -exu
9+
10+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
11+
12+
export EXECUTORCH_ROOT="$(dirname "${BASH_SOURCE[0]}")/../.."
13+
14+
if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
15+
PYTHON_EXECUTABLE=python3
16+
fi
17+
18+
which "${PYTHON_EXECUTABLE}"
19+
20+
# Update tokenizers submodule
21+
pushd $EXECUTORCH_ROOT/extension/llm/tokenizers
22+
echo "Update tokenizers submodule"
23+
git submodule update --init
24+
popd
25+
26+
pushd $EXECUTORCH_ROOT/examples/apple/coreml/llama
27+
28+
# Download stories llama110m artifacts
29+
download_stories_model_artifacts
30+
31+
python export.py -n model.pte -p params.json -c stories110M.pt --seq_length 32 --max_seq_length 64 --dtype fp16 --coreml-quantize c4w
32+
33+
popd

.ci/scripts/test_llama.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ cmake_install_executorch_libraries() {
173173

174174
cmake_build_llama_runner() {
175175
echo "Building llama runner"
176+
pushd extension/llm/tokenizers
177+
echo "Updating tokenizers submodule"
178+
git submodule update --init
179+
popd
176180
dir="examples/models/llama"
177181
retry cmake \
178182
-DCMAKE_INSTALL_PREFIX=cmake-out \

.ci/scripts/test_model.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ test_model() {
100100
rm "./${MODEL_NAME}.pte"
101101
return # Skip running with portable executor runnner since portable doesn't support Qwen's biased linears.
102102
fi
103+
if [[ "${MODEL_NAME}" == "phi-4-mini" ]]; then
104+
# Install requirements for export_llama
105+
bash examples/models/llama/install_requirements.sh
106+
# Test export_llama script: python3 -m examples.models.llama.export_llama.
107+
"${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama --model "${MODEL_NAME}" -c examples/models/llama/params/demo_rand_params.pth -p examples/models/phi-4-mini/config.json
108+
run_portable_executor_runner
109+
rm "./${MODEL_NAME}.pte"
110+
return
111+
fi
103112

104113
# Export a basic .pte and run the model.
105114
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}" "${STRICT}"
@@ -164,6 +173,7 @@ test_model_with_qnn() {
164173
export LD_LIBRARY_PATH=$QNN_SDK_ROOT/lib/x86_64-linux-clang/
165174
export PYTHONPATH=$EXECUTORCH_ROOT/..
166175

176+
EXTRA_FLAGS=""
167177
if [[ "${MODEL_NAME}" == "dl3" ]]; then
168178
EXPORT_SCRIPT=deeplab_v3
169179
elif [[ "${MODEL_NAME}" == "mv3" ]]; then
@@ -176,6 +186,12 @@ test_model_with_qnn() {
176186
EXPORT_SCRIPT=inception_v3
177187
elif [[ "${MODEL_NAME}" == "vit" ]]; then
178188
EXPORT_SCRIPT=torchvision_vit
189+
elif [[ "${MODEL_NAME}" == "mb" ]]; then
190+
EXPORT_SCRIPT=mobilebert_fine_tune
191+
EXTRA_FLAGS="--num_epochs 1"
192+
pip install scikit-learn
193+
elif [[ "${MODEL_NAME}" == "w2l" ]]; then
194+
EXPORT_SCRIPT=wav2letter
179195
elif [[ "${MODEL_NAME}" == "edsr" ]]; then
180196
EXPORT_SCRIPT=edsr
181197
# Additional deps for edsr
@@ -189,7 +205,7 @@ test_model_with_qnn() {
189205
# TODO(guangyang): Make QNN chipset matches the target device
190206
QNN_CHIPSET=SM8450
191207

192-
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} --compile_only
208+
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} --compile_only $EXTRA_FLAGS
193209
EXPORTED_MODEL=$(find "./${EXPORT_SCRIPT}" -type f -name "${MODEL_NAME}*.pte" -print -quit)
194210
}
195211

.ci/scripts/unittest-buck2.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ buck2 query "//backends/apple/... + //backends/example/... + \
1414
//runtime/... + //schema/... + //test/... + //util/..."
1515

1616
# TODO: expand the covered scope of Buck targets.
17-
buck2 build //runtime/core/portable_type/...
18-
buck2 test //runtime/core/portable_type/...
17+
# //runtime/kernel/... is failing because //third-party:torchgen_files's shell script can't find python on PATH.
18+
# //runtime/test/... requires Python torch, which we don't have in our OSS buck setup.
19+
buck2 build //runtime/backend/... //runtime/core/... //runtime/executor: //runtime/kernel/... //runtime/platform/...
20+
buck2 test //runtime/backend/... //runtime/core/... //runtime/executor: //runtime/kernel/... //runtime/platform/...

.github/workflows/android-perf.yml

Lines changed: 57 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,63 @@ jobs:
9696
9797
PYTHONPATH="${PWD}" python .ci/scripts/gather_benchmark_configs.py $ARGS
9898
99+
prepare-test-specs:
100+
runs-on: linux.2xlarge
101+
needs: set-parameters
102+
strategy:
103+
matrix: ${{ fromJson(needs.set-parameters.outputs.benchmark_configs) }}
104+
fail-fast: false
105+
steps:
106+
- uses: actions/checkout@v3
107+
108+
- name: Prepare the spec
109+
id: prepare
110+
shell: bash
111+
env:
112+
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
113+
working-directory: extension/benchmark/android/benchmark
114+
run: |
115+
set -eux
116+
117+
# The model will be exported in the next step to this S3 path
118+
MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}/model.zip"
119+
# We could write a script to properly use jinja here, but there is only one variable,
120+
# so let's just sed it
121+
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' android-llm-device-farm-test-spec.yml.j2
122+
123+
BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
124+
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
125+
# later by the upload script
126+
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' android-llm-device-farm-test-spec.yml.j2
127+
128+
cp android-llm-device-farm-test-spec.yml.j2 android-llm-device-farm-test-spec.yml
129+
# Just print the test spec for debugging
130+
cat android-llm-device-farm-test-spec.yml
131+
132+
# Save the benchmark configs so that we can use it later in the dashboard
133+
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
134+
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT
135+
136+
- name: Upload the spec
137+
uses: seemethere/upload-artifact-s3@v5
138+
with:
139+
s3-bucket: gha-artifacts
140+
s3-prefix: |
141+
${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}
142+
retention-days: 1
143+
if-no-files-found: error
144+
path: extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
145+
146+
- name: Update the benchmark configs
147+
uses: seemethere/upload-artifact-s3@v5
148+
with:
149+
s3-bucket: gha-artifacts
150+
s3-prefix: |
151+
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
152+
retention-days: 1
153+
if-no-files-found: error
154+
path: extension/benchmark/android/benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json
155+
99156
export-models:
100157
name: export-models
101158
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
@@ -278,69 +335,6 @@ jobs:
278335
fi
279336
echo "::endgroup::"
280337
281-
prepare-test-specs:
282-
runs-on: linux.2xlarge
283-
needs:
284-
- set-parameters
285-
- export-models
286-
strategy:
287-
matrix: ${{ fromJson(needs.set-parameters.outputs.benchmark_configs) }}
288-
fail-fast: false
289-
steps:
290-
- uses: actions/checkout@v3
291-
292-
- name: Prepare the spec
293-
id: prepare
294-
shell: bash
295-
env:
296-
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
297-
working-directory: extension/benchmark/android/benchmark
298-
run: |
299-
set -eux
300-
301-
# The model will be exported in the next step to this S3 path
302-
MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}/model.zip"
303-
304-
# Check if the model artifact exists, fail this step skip generating test-spec.
305-
curl -s --head -f ${MODEL_PATH}
306-
307-
# We could write a script to properly use jinja here, but there is only one variable,
308-
# so let's just sed it
309-
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' android-llm-device-farm-test-spec.yml.j2
310-
311-
BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
312-
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
313-
# later by the upload script
314-
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' android-llm-device-farm-test-spec.yml.j2
315-
316-
cp android-llm-device-farm-test-spec.yml.j2 android-llm-device-farm-test-spec.yml
317-
# Just print the test spec for debugging
318-
cat android-llm-device-farm-test-spec.yml
319-
320-
# Save the benchmark configs so that we can use it later in the dashboard
321-
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
322-
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT
323-
324-
- name: Upload the spec
325-
uses: seemethere/upload-artifact-s3@v5
326-
with:
327-
s3-bucket: gha-artifacts
328-
s3-prefix: |
329-
${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}
330-
retention-days: 1
331-
if-no-files-found: error
332-
path: extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
333-
334-
- name: Update the benchmark configs
335-
uses: seemethere/upload-artifact-s3@v5
336-
with:
337-
s3-bucket: gha-artifacts
338-
s3-prefix: |
339-
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
340-
retention-days: 1
341-
if-no-files-found: error
342-
path: extension/benchmark/android/benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json
343-
344338
build-benchmark-app:
345339
name: build-benchmark-app
346340
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main

0 commit comments

Comments
 (0)