Skip to content

Commit ca69e88

Browse files
committed
Merge branch 'wasm-bindings-js' into wasm-bindings-demo
2 parents e37ead6 + f3ba749 commit ca69e88

File tree

108 files changed

+3103
-635
lines changed

Some content is hidden

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

108 files changed

+3103
-635
lines changed

.ci/scripts/build-qnn-sdk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ set_up_aot() {
3333
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
3434
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3535
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
36+
-DEXECUTORCH_BUILD_EXTENSION_EXTENSION_LLM=ON \
37+
-DEXECUTORCH_BUILD_EXTENSION_EXTENSION_LLM_RUNNER=ON \
3638
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3739
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3840
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \

.ci/scripts/test_llama.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ cmake_install_executorch_libraries() {
150150
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
151151
rm -rf cmake-out
152152
retry cmake --preset llm \
153+
-DBUILD_TESTING=OFF \
153154
-DCMAKE_INSTALL_PREFIX=cmake-out \
154155
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
155156
-DEXECUTORCH_BUILD_QNN="$QNN" \

.ci/scripts/test_llama_torchao_lowbit.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ cmake -DPYTHON_EXECUTABLE=python \
2929
-DEXECUTORCH_ENABLE_LOGGING=1 \
3030
-DCMAKE_BUILD_TYPE=Release \
3131
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
32+
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON \
33+
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON \
3234
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3335
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3436
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \

.ci/scripts/test_llava.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ EXECUTORCH_COMMON_CMAKE_ARGS=" \
3838
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3939
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
4040
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
41+
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON \
42+
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON \
4143
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
4244
-DEXECUTORCH_BUILD_KERNELS_LLM=ON \
4345
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \

.ci/scripts/test_model.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,24 @@ test_model_with_qnn() {
232232
# @param should_test If true, build and test the model using the coreml_executor_runner.
233233
test_model_with_coreml() {
234234
local should_test="$1"
235+
local test_with_pybindings="$2"
236+
local dtype="$3"
235237

236238
if [[ "${BUILD_TOOL}" != "cmake" ]]; then
237239
echo "coreml only supports cmake."
238240
exit 1
239241
fi
240242

241-
DTYPE=float16
243+
RUN_WITH_PYBINDINGS=""
244+
if [[ "${test_with_pybindings}" == true ]]; then
245+
echo \"Running with pybindings\"
246+
export RUN_WITH_PYBINDINGS="--run_with_pybindings"
247+
fi
242248

243-
"${PYTHON_EXECUTABLE}" -m examples.apple.coreml.scripts.export --model_name="${MODEL_NAME}" --compute_precision "${DTYPE}" --use_partitioner
249+
"${PYTHON_EXECUTABLE}" -m examples.apple.coreml.scripts.export --model_name="${MODEL_NAME}" --compute_precision ${dtype} --use_partitioner ${RUN_WITH_PYBINDINGS}
244250
EXPORTED_MODEL=$(find "." -type f -name "${MODEL_NAME}*.pte" -print -quit)
245251

246252
if [ -n "$EXPORTED_MODEL" ]; then
247-
EXPORTED_MODEL_WITH_DTYPE="${EXPORTED_MODEL%.pte}_${DTYPE}.pte"
248-
mv "$EXPORTED_MODEL" "$EXPORTED_MODEL_WITH_DTYPE"
249-
EXPORTED_MODEL="$EXPORTED_MODEL_WITH_DTYPE"
250253
echo "OK exported model: $EXPORTED_MODEL"
251254
else
252255
echo "[error] failed to export model: no .pte file found"
@@ -303,7 +306,15 @@ elif [[ "${BACKEND}" == *"coreml"* ]]; then
303306
if [[ "${BACKEND}" == *"test"* ]]; then
304307
should_test_coreml=true
305308
fi
306-
test_model_with_coreml "${should_test_coreml}"
309+
test_with_pybindings=false
310+
if [[ "${BACKEND}" == *"pybind"* ]]; then
311+
test_with_pybindings=true
312+
fi
313+
dtype=float16
314+
if [[ "${BACKEND}" == *"float32"* ]]; then
315+
dtype=float32
316+
fi
317+
test_model_with_coreml "${should_test_coreml}" "${test_with_pybindings}" "${dtype}"
307318
if [[ $? -eq 0 ]]; then
308319
prepare_artifacts_upload
309320
fi

.ci/scripts/test_qnn_static_llama.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ exit_code1=$?
4141
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_llama_stories_110m --model SM8650 --build_folder build-x86/ --executorch_root . --artifact_dir . --llama_artifacts . --enable_x86_64
4242
exit_code2=$?
4343

44+
# Check BC
45+
bash backends/qualcomm/bc/test_qnn_static_llama_bc.sh
46+
exit_code3=$?
47+
4448
# Check the exit codes and print messages
4549
if [ $exit_code1 -ne 0 ]; then
4650
echo "Static Llama compile only with weight sharing test failed. $exit_code1."
@@ -50,8 +54,12 @@ if [ $exit_code2 -ne 0 ]; then
5054
echo "Static Llama accuracy test failed. $exit_code2."
5155
fi
5256

57+
if [ $exit_code3 -ne 0 ]; then
58+
echo "Static Llama BACKWARD COMPATIBILITY test failed. $exit_code3."
59+
fi
60+
5361
# Return failure if either program failed
54-
if [ $exit_code1 -ne 0 ] || [ $exit_code2 -ne 0 ]; then
62+
if [ $exit_code1 -ne 0 ] || [ $exit_code2 -ne 0 ] || [ $exit_code3 -ne 0 ]; then
5563
exit 1
5664
else
5765
exit 0

.github/workflows/pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ jobs:
371371
size=${arr[4]}
372372
# threshold=48120 on devserver with gcc11.4
373373
# todo(lfq): update once binary size is below 50kb.
374-
threshold="55584"
374+
threshold="63776"
375375
if [[ "$size" -le "$threshold" ]]; then
376376
echo "Success $size <= $threshold"
377377
else
@@ -406,7 +406,7 @@ jobs:
406406
output=$(ls -la cmake-out/test/size_test)
407407
arr=($output)
408408
size=${arr[4]}
409-
threshold="51728"
409+
threshold="51744"
410410
if [[ "$size" -le "$threshold" ]]; then
411411
echo "Success $size <= $threshold"
412412
else

.github/workflows/trunk.yml

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ concurrency:
1818
cancel-in-progress: true
1919

2020
jobs:
21-
test-models-macos:
22-
name: test-models-macos
21+
test-models-macos-cpu:
22+
name: test-models-macos-cpu
2323
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
2424
strategy:
2525
matrix:
@@ -242,12 +242,12 @@ jobs:
242242
setup_script_args=""
243243
if [[ ${{ matrix.os}} == "bare_metal" ]]; then
244244
toolchain_prefix=arm-none-eabi-
245-
threshold="104000" # should be ~103.7KB, set threshold to 104KB.
245+
threshold="109000"
246246
toolchain_cmake=examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
247247
elif [[ ${{ matrix.os}} == "zephyr-preset" ]]; then
248248
setup_script_args="--target-toolchain zephyr"
249249
toolchain_prefix=arm-zephyr-eabi-
250-
threshold="133120" # should be ~125KB, set threshold to 130KB
250+
threshold="135000"
251251
toolchain_cmake=examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
252252
else
253253
echo "Fail unsupport OS selection ${{ matrix.os }}"
@@ -568,10 +568,12 @@ jobs:
568568
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
569569
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh ${{ matrix.model }} "cmake" "qnn"
570570
571-
test-apple-model:
572-
name: test-apple-model
571+
test-models-macos-coreml:
572+
name: test-models-macos-coreml
573573
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
574574
strategy:
575+
matrix:
576+
model: [dl3, edsr, efficient_sam, emformer_join, emformer_transcribe, ic3, ic4, mobilebert, mv2, mv3, resnet50, vit, w2l]
575577
fail-fast: false
576578
with:
577579
runner: macos-m1-stable
@@ -580,7 +582,23 @@ jobs:
580582
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
581583
timeout: 90
582584
script: |
585+
MODEL_NAME=${{ matrix.model }}
583586
BUILD_TOOL=cmake
587+
BACKEND="coreml-pybind"
588+
589+
590+
# Set model specific overrides
591+
if [[ "${MODEL_NAME}" == "mobilebert" ]]; then
592+
# See https://github.com/pytorch/executorch/issues/12907
593+
# mobilebert has nan output on FP16, and high MSE on fp32, so we disable runtime test now
594+
BACKEND="coreml"
595+
fi
596+
597+
if [[ "${MODEL_NAME}" == "efficient_sam" ]]; then
598+
# See https://github.com/pytorch/executorch/issues/12906
599+
# efficient_sam fails to run on CoreML
600+
BACKEND="coreml"
601+
fi
584602
585603
bash .ci/scripts/setup-conda.sh
586604
@@ -589,13 +607,28 @@ jobs:
589607
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash backends/apple/coreml/scripts/install_requirements.sh
590608
echo "Finishing installing coreml."
591609
592-
# Build and test coreml model
593-
MODELS=(mv3 ic4 resnet50 edsr mobilebert w2l)
594-
for MODEL_NAME in "${MODELS[@]}"; do
595-
echo "::group::Exporting coreml model: $MODEL_NAME"
596-
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "coreml"
597-
echo "::endgroup::"
610+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
611+
612+
test-models-macos-mps:
613+
name: test-models-macos-mps
614+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
615+
strategy:
616+
fail-fast: false
617+
with:
618+
runner: macos-m1-stable
619+
python-version: '3.11'
620+
submodules: 'recursive'
621+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
622+
timeout: 90
623+
script: |
624+
BUILD_TOOL=cmake
625+
bash .ci/scripts/setup-conda.sh
626+
627+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
628+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh --build-tool "${BUILD_TOOL}"
598629
630+
# Build and test mps model
631+
for MODEL_NAME in mv3 ic4 resnet50 edsr mobilebert w2l; do
599632
echo "::group::Exporting mps model: $MODEL_NAME"
600633
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "mps"
601634
echo "::endgroup::"

0 commit comments

Comments
 (0)