Skip to content

Commit 5ea00e9

Browse files
committed
Update on "[Executorch] optimized sigmoid"
basically use exp approximation using sleef instead of std::exp Differential Revision: [D64156864](https://our.internmc.facebook.com/intern/diff/D64156864/) [ghstack-poisoned]
2 parents 946e71b + 89e6696 commit 5ea00e9

File tree

206 files changed

+831692
-1261
lines changed

Some content is hidden

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

206 files changed

+831692
-1261
lines changed

.ci/docker/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ case "${IMAGE_NAME}" in
3737
ARM_SDK=yes
3838
CLANG_VERSION=12
3939
;;
40+
executorch-ubuntu-22.04-qnn-sdk)
41+
QNN_SDK=yes
42+
CLANG_VERSION=12
43+
;;
4044
executorch-ubuntu-22.04-clang12-android)
4145
LINTRUNNER=""
4246
CLANG_VERSION=12
@@ -72,6 +76,7 @@ docker build \
7276
--build-arg "LINTRUNNER=${LINTRUNNER:-}" \
7377
--build-arg "BUILD_DOCS=${BUILD_DOCS}" \
7478
--build-arg "ARM_SDK=${ARM_SDK:-}" \
79+
--build-arg "QNN_SDK=${QNN_SDK:-}" \
7580
--build-arg "ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-}" \
7681
-f "${OS}"/Dockerfile \
7782
"$@" \

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c8a648d4dffb9f0133ff4a2ea0e660b42105d3ad
1+
19eff28ff3f19b50da46f5a9ff5f4d4d213806fe

.ci/docker/ci_commit_pins/torchao.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

.ci/docker/ubuntu/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,7 @@ COPY --chown=ci-user:ci-user ./arm /opt/arm
8282
# Set up ARM SDK if needed
8383
RUN if [ -n "${ARM_SDK}" ]; then git config --global user.email "[email protected]"; git config --global user.name "OSS CI"; bash /opt/arm/setup.sh --i-agree-to-the-contained-eula /opt/arm-sdk; chown -R ci-user:ci-user /opt/arm-sdk; fi
8484

85+
ARG QNN_SDK
86+
8587
USER ci-user
8688
CMD ["bash"]

.ci/scripts/gather_test_models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"ic4": "linux.12xlarge",
2525
"resnet50": "linux.12xlarge",
2626
"llava": "linux.12xlarge",
27+
"llama3_2_vision_encoder": "linux.12xlarge",
28+
# "llama3_2_text_decoder": "linux.12xlarge", # TODO: re-enable test when Huy's change is in / model gets smaller.
2729
# This one causes timeout on smaller runner, the root cause is unclear (T161064121)
2830
"dl3": "linux.12xlarge",
2931
"emformer_join": "linux.12xlarge",
@@ -88,8 +90,8 @@ def model_should_run_on_event(model: str, event: str) -> bool:
8890
if event == "pull_request":
8991
return model in ["mv3", "vit"]
9092
elif event == "push":
91-
# 'emformer_predict' is running super slow. Only run it periodically
92-
return model not in ["emformer_predict"]
93+
# These are super slow. Only run it periodically
94+
return model not in ["dl3", "edsr", "emformer_predict"]
9395
else:
9496
return True
9597

.ci/scripts/setup-linux.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ fi
2323
# of nightly. This allows CI to test against latest commits from PyTorch
2424
install_executorch "use-pt-pinned-commit"
2525
build_executorch_runner "${BUILD_TOOL}"
26+
do_not_use_nightly_on_ci

.ci/scripts/test_model.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ test_model() {
7777
# Install requirements for export_llama
7878
bash examples/models/llama/install_requirements.sh
7979
# Test export_llama script: python3 -m examples.models.llama.export_llama
80-
"${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama -c examples/models/llama/params/demo_rand_params.pth -p examples/models/llama/params/demo_config.json
80+
"${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama --model "${MODEL_NAME}" -c examples/models/llama/params/demo_rand_params.pth -p examples/models/llama/params/demo_config.json
8181
run_portable_executor_runner
8282
rm "./${MODEL_NAME}.pte"
8383
fi
@@ -87,6 +87,10 @@ test_model() {
8787
bash examples/models/llava/install_requirements.sh
8888
STRICT="--no-strict"
8989
fi
90+
if [[ "$MODEL_NAME" == "llama3_2_vision_encoder" || "$MODEL_NAME" == "llama3_2_text_decoder" ]]; then
91+
# Install requirements for llama vision.
92+
bash examples/models/llama3_2_vision/install_requirements.sh
93+
fi
9094
# python3 -m examples.portable.scripts.export --model_name="llama2" should works too
9195
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}" "${STRICT}"
9296
run_portable_executor_runner

.ci/scripts/utils.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,26 @@ cmake_install_executorch_lib() {
113113
}
114114

115115
download_stories_model_artifacts() {
116-
# Download stories110M.pt and tokenizer from Github
116+
# Download stories110M.pt and tokenizer from Github
117117
curl -Ls "https://huggingface.co/karpathy/tinyllamas/resolve/main/stories110M.pt" --output stories110M.pt
118118
curl -Ls "https://raw.githubusercontent.com/karpathy/llama2.c/master/tokenizer.model" --output tokenizer.model
119119
# Create params.json file
120120
touch params.json
121121
echo '{"dim": 768, "multiple_of": 32, "n_heads": 12, "n_layers": 12, "norm_eps": 1e-05, "vocab_size": 32000}' > params.json
122122
}
123+
124+
do_not_use_nightly_on_ci() {
125+
# An assert to make sure that we are not using PyTorch nightly on CI to prevent
126+
# regression as documented in https://github.com/pytorch/executorch/pull/6564
127+
TORCH_VERSION=$(pip list | grep -w 'torch ' | awk -F ' ' {'print $2'} | tr -d '\n')
128+
129+
# The version of PyTorch building from source looks like 2.6.0a0+gitc8a648d that
130+
# includes the commit while nightly (2.6.0.dev20241019+cpu) or release (2.6.0)
131+
# won't have that. Note that we couldn't check for the exact commit from the pin
132+
# ci_commit_pins/pytorch.txt here because the value will be different when running
133+
# this on PyTorch CI
134+
if [[ "${TORCH_VERSION}" != *"+git"* ]]; then
135+
echo "Unexpected torch version. Expected binary built from source, got ${TORCH_VERSION}"
136+
exit 1
137+
fi
138+
}

.github/workflows/_android.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ jobs:
7373
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug.apk
7474
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug-androidTest.apk
7575
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
76+
curl -o android-test-debug.apk https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/library_test_dir/executorch-debug.apk
77+
curl -o android-test-debug-androidTest.apk https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/library_test_dir/executorch-debug-androidTest.apk
7678
unzip model.zip
7779
mv *.pte model.pte
7880

.github/workflows/apple.yml

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
- release/*
88
pull_request:
99
paths:
10-
- .ci/docker/**
1110
- .ci/scripts/setup-ios.sh
1211
- .github/workflows/apple.yml
1312
- install_requirements.sh
@@ -21,12 +20,26 @@ on:
2120
- extension/benchmark/apple/**
2221
- extension/module/**
2322
workflow_dispatch:
23+
schedule:
24+
- cron: '0 10 * * *' # Runs daily at 2 AM PST
2425

2526
concurrency:
2627
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
2728
cancel-in-progress: true
2829

2930
jobs:
31+
set-version:
32+
runs-on: ubuntu-22.04
33+
outputs:
34+
version: ${{ steps.set_version.outputs.version }}
35+
steps:
36+
- name: Set VERSION variable
37+
id: set_version
38+
shell: bash
39+
run: |
40+
VERSION="0.4.0.$(TZ='PST8PDT' date +%Y%m%d)"
41+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
42+
3043
build-demo-ios:
3144
name: build-demo-ios
3245
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -40,6 +53,8 @@ jobs:
4053
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_DEMO_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
4154
upload-artifact: ios-apps
4255
script: |
56+
set -eux
57+
4358
BUILD_TOOL=cmake
4459
4560
.ci/scripts/setup-conda.sh
@@ -58,7 +73,7 @@ jobs:
5873
5974
# Build and test iOS Demo App
6075
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
61-
build/test_ios_ci.sh ${ARTIFACTS_DIR_NAME}
76+
build/test_ios_ci.sh "${ARTIFACTS_DIR_NAME}"
6277
6378
# Upload the test demo app to S3
6479
upload-demo-ios:
@@ -76,6 +91,7 @@ jobs:
7691
shell: bash
7792
working-directory: ${{ runner.temp }}/artifacts/
7893
run: |
94+
set -eux
7995
ls -lah ./
8096
8197
- name: Upload the artifacts to S3
@@ -113,6 +129,7 @@ jobs:
113129

114130
build-frameworks-ios:
115131
name: build-frameworks-ios
132+
needs: set-version
116133
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
117134
with:
118135
runner: macos-latest-xlarge
@@ -122,8 +139,10 @@ jobs:
122139
upload-artifact: executorch-frameworks-ios
123140
timeout: 90
124141
script: |
142+
set -eux
143+
125144
BUILD_TOOL=cmake
126-
VERSION="latest"
145+
VERSION="${{ needs.set-version.outputs.version }}"
127146
FRAMEWORKS=(
128147
"executorch"
129148
"backend_coreml"
@@ -172,13 +191,17 @@ jobs:
172191
173192
upload-frameworks-ios:
174193
runs-on: ubuntu-22.04
175-
needs: build-frameworks-ios
194+
needs: [build-frameworks-ios, set-version]
176195
timeout-minutes: 30
196+
environment: ${{ github.ref == 'refs/heads/main' && 'cherry-pick-bot' || '' }}
177197
permissions:
178198
id-token: write
179-
contents: read
199+
contents: write
180200
steps:
181201
- uses: actions/checkout@v3
202+
with:
203+
fetch-depth: 0
204+
token: ${{ secrets.GH_PYTORCHBOT_CHERRY_PICK_TOKEN || secrets.GITHUB_TOKEN }}
182205
- uses: actions/setup-python@v4
183206
with:
184207
python-version: '3.11'
@@ -195,15 +218,15 @@ jobs:
195218
name: executorch-frameworks-ios
196219
path: ${{ runner.temp }}/frameworks-ios/
197220
- name: Only push to S3 when running the workflow manually from main branch
198-
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
221+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }}
199222
shell: bash
200223
run: |
201-
set -eux
202224
echo "UPLOAD_ON_MAIN=1" >> "${GITHUB_ENV}"
203225
- name: Upload the artifact to ossci-ios S3 bucket
204226
shell: bash
205227
run: |
206228
set -eux
229+
VERSION="${{ needs.set-version.outputs.version }}"
207230
208231
pip install awscli==1.32.18
209232
@@ -214,9 +237,44 @@ jobs:
214237
215238
for FILENAME in "${RUNNER_TEMP}"/frameworks-ios/*.zip; do
216239
[ -e "${FILENAME}" ] || continue
217-
shasum -a 256 "${FILENAME}"
240+
FRAMEWORK_NAME=$(basename "${FILENAME}" | sed "s/-${VERSION}.zip//")
241+
CHECKSUM=$(shasum -a 256 "${FILENAME}" | cut -d ' ' -f1)
242+
echo "${FRAMEWORK_NAME} ${CHECKSUM}" >> "${RUNNER_TEMP}/checksums.txt"
218243
${AWS_CMD} "${FILENAME}" s3://ossci-ios/executorch/ --acl public-read
219244
done
245+
- name: Update SwiftPM
246+
shell: bash
247+
run: |
248+
set -eux
249+
VERSION="${{ needs.set-version.outputs.version }}"
250+
BRANCH="swiftpm-${VERSION}"
251+
252+
git checkout swiftpm
253+
254+
if git show-ref --verify --quiet refs/heads/${BRANCH}; then
255+
git checkout "${BRANCH}"
256+
else
257+
git checkout -b "${BRANCH}"
258+
fi
259+
260+
[[ -f Package.swift ]] || mv Package.swift.template Package.swift
261+
262+
sed -i "s/__VERSION__/${VERSION}/g" Package.swift
263+
264+
while read -r FRAMEWORK CHECKSUM; do
265+
sed -i "s/__SHA256_${FRAMEWORK}__/${CHECKSUM}/g" Package.swift
266+
done < "${RUNNER_TEMP}/checksums.txt"
267+
268+
if [[ "${UPLOAD_ON_MAIN:-0}" == "1" ]]; then
269+
git config --global user.name "PyTorch Bot"
270+
git config --global user.email "[email protected]"
271+
git add Package.swift
272+
git commit -am "${VERSION}"
273+
git push -f origin "${BRANCH}"
274+
else
275+
echo "Draft Package.swift:"
276+
cat Package.swift
277+
fi
220278
221279
build-benchmark-app:
222280
name: build-benchmark-app
@@ -282,5 +340,5 @@ jobs:
282340
echo "::group::Build ExecuTorch benchmark app"
283341
mkdir -p extension/benchmark/apple/Benchmark/Models
284342
${CONDA_RUN} --no-capture-output \
285-
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
343+
build/build_apple_llm_demo.sh "${ARTIFACTS_DIR_NAME}"
286344
echo "::endgroup::"

.github/workflows/docker-builds.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- docker-image-name: executorch-ubuntu-22.04-clang12
3939
- docker-image-name: executorch-ubuntu-22.04-linter
4040
- docker-image-name: executorch-ubuntu-22.04-arm-sdk
41+
- docker-image-name: executorch-ubuntu-22.04-qnn-sdk
4142
- docker-image-name: executorch-ubuntu-22.04-clang12-android
4243
env:
4344
DOCKER_IMAGE: 308535385114.dkr.ecr.us-east-1.amazonaws.com/executorch/${{ matrix.docker-image-name }}

.github/workflows/pull.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ jobs:
372372
fail-fast: false
373373
with:
374374
runner: linux.2xlarge
375-
docker-image: executorch-ubuntu-22.04-clang12-android
375+
docker-image: executorch-ubuntu-22.04-qnn-sdk
376376
submodules: 'true'
377377
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
378378
timeout: 900

.github/workflows/trunk.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
bash .ci/scripts/setup-conda.sh
5959
# Setup MacOS dependencies as there is no Docker support on MacOS atm
6060
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
61-
# Build and test xecutorch
61+
# 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
6464
test-custom-ops-macos:
@@ -411,8 +411,6 @@ jobs:
411411
pip install -U "huggingface_hub[cli]"
412412
huggingface-cli login --token $SECRET_EXECUTORCH_HF_TOKEN
413413
pip install accelerate sentencepiece
414-
# TODO(guangyang): Switch to use released transformers library after all required patches are included
415-
pip install "git+https://github.com/huggingface/transformers.git@6cc4dfe3f1e8d421c6d6351388e06e9b123cbfe1"
416414
pip list
417415
echo "::endgroup::"
418416

0 commit comments

Comments
 (0)