Skip to content

Commit 6e2fd3b

Browse files
authored
Merge branch 'main' into fix-et-lowered-module
2 parents 8139bdf + 1f4ad07 commit 6e2fd3b

123 files changed

Lines changed: 3130 additions & 809 deletions

File tree

Some content is hidden

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

.ci/scripts/export_model_artifact.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Arguments:
3434
3535
output_dir Output directory for artifacts (optional, default: current directory)
3636
37-
mode Export mode (optional, default: auto-detect based on model and device)
37+
mode Export mode (optional, default: vr-streaming)
3838
Supported modes:
3939
- vr-streaming: Voxtral Realtime streaming mode
4040
- vr-offline: Voxtral Realtime offline mode
@@ -256,16 +256,9 @@ if [ "$MODEL_NAME" = "voxtral_realtime" ]; then
256256
fi
257257

258258
# Determine streaming mode based on MODE parameter
259-
USE_STREAMING="false"
260-
if [ "$MODE" = "vr-streaming" ]; then
261-
USE_STREAMING="true"
262-
elif [ "$MODE" = "vr-offline" ]; then
259+
USE_STREAMING="true"
260+
if [ "$MODE" = "vr-offline" ]; then
263261
USE_STREAMING="false"
264-
elif [ -z "$MODE" ]; then
265-
# Auto-detect: XNNPACK uses streaming, others use offline
266-
if [ "$DEVICE" = "xnnpack" ]; then
267-
USE_STREAMING="true"
268-
fi
269262
fi
270263

271264
# Configure export and preprocessor based on streaming mode

.ci/scripts/test_lora.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212
cmake_install_executorch_libraries() {
1313
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
1414
rm -rf cmake-out
15-
cmake --workflow llm-release
15+
cmake --preset llm-release -DEXECUTORCH_ENABLE_LOGGING=ON
16+
cmake --build --preset llm-release-install
1617
}
1718

1819
cmake_build_llama_runner() {

.ci/scripts/test_lora_multimethod.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212
cmake_install_executorch_libraries() {
1313
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
1414
rm -rf cmake-out
15-
cmake --workflow llm-release
15+
cmake --preset llm-release -DEXECUTORCH_ENABLE_LOGGING=ON
16+
cmake --build --preset llm-release-install
1617
}
1718

1819
cmake_build_llama_runner() {

.ci/scripts/test_model_e2e.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,9 @@ case "$MODEL_NAME" in
272272
voxtral_realtime)
273273
RUNNER_ARGS="--model_path ${MODEL_DIR}/model.pte --tokenizer_path ${MODEL_DIR}/$TOKENIZER_FILE --preprocessor_path ${MODEL_DIR}/$PREPROCESSOR --audio_path ${MODEL_DIR}/$AUDIO_FILE --temperature 0"
274274
# Determine streaming mode based on MODE parameter
275-
USE_STREAMING="false"
276-
if [ "$MODE" = "vr-streaming" ]; then
277-
USE_STREAMING="true"
278-
elif [ "$MODE" = "vr-offline" ]; then
275+
USE_STREAMING="true"
276+
if [ "$MODE" = "vr-offline" ]; then
279277
USE_STREAMING="false"
280-
elif [ -z "$MODE" ]; then
281-
# Auto-detect: XNNPACK uses streaming, others use offline
282-
if [ "$DEVICE" = "xnnpack" ]; then
283-
USE_STREAMING="true"
284-
fi
285278
fi
286279
# Add streaming flag if needed
287280
if [ "$USE_STREAMING" = "true" ]; then

.github/workflows/_android.yml

Lines changed: 55 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,98 +5,89 @@ on:
55
workflow_dispatch:
66

77
jobs:
8-
build-llm-demo:
9-
name: build-llm-demo
10-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
8+
build-android:
9+
name: build-android
10+
runs-on: 16-core-ubuntu
1111
permissions:
1212
id-token: write
1313
contents: read
14-
with:
15-
runner: linux.2xlarge
16-
docker-image: ci-image:executorch-ubuntu-22.04-clang12-android
17-
submodules: 'recursive'
18-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
19-
timeout: 90
20-
upload-artifact: android-apps
21-
upload-artifact-to-s3: true
22-
script: |
23-
set -eux
14+
env:
15+
PYTHON_EXECUTABLE: python3
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
2420

25-
# Use sccache for NDK compiler as well
26-
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
27-
export CMAKE_C_COMPILER_LAUNCHER=sccache
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.11'
2825

29-
# The generic Linux job chooses to use base env, not the one setup by the image
30-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
31-
conda activate "${CONDA_ENV}"
32-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2
33-
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
34-
mkdir -p ${ARTIFACTS_DIR_NAME}/
26+
- name: Install Python dependencies
27+
run: |
28+
pip install torch executorch
3529
36-
# Build LLM Demo for Android
37-
export BUILD_AAR_DIR=aar-out
38-
mkdir -p $BUILD_AAR_DIR
39-
bash scripts/build_android_library.sh
40-
cp ${BUILD_AAR_DIR}/executorch.aar $ARTIFACTS_DIR_NAME
30+
- name: Set up Android NDK
31+
run: |
32+
# Use the pre-installed NDK from the GH runner
33+
ANDROID_NDK=$(ls -d "$ANDROID_HOME/ndk/"*/ 2>/dev/null | sort -V | tail -1)
34+
if [ -z "$ANDROID_NDK" ]; then
35+
echo "No Android NDK found at $ANDROID_HOME/ndk/"
36+
exit 1
37+
fi
38+
ANDROID_NDK="${ANDROID_NDK%/}"
39+
echo "Using Android NDK: $ANDROID_NDK"
40+
echo "ANDROID_NDK=$ANDROID_NDK" >> "$GITHUB_ENV"
41+
42+
- name: Build Android library
43+
run: |
44+
set -eux
45+
export BUILD_AAR_DIR=aar-out
46+
mkdir -p $BUILD_AAR_DIR
47+
bash scripts/build_android_library.sh
4148
42-
mkdir -p ${ARTIFACTS_DIR_NAME}/library_test_dir
43-
bash extension/android/executorch_android/android_test_setup.sh
44-
(cd extension/android; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:assembleAndroidTest)
45-
cp extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk "${ARTIFACTS_DIR_NAME}/library_test_dir"
49+
- name: Build Android test APK
50+
run: |
51+
set -eux
52+
bash extension/android/executorch_android/android_test_setup.sh
53+
cd extension/android
54+
ANDROID_HOME="${ANDROID_HOME}" ./gradlew :executorch_android:assembleAndroidTest
4655
47-
mkdir -p ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
48-
bash examples/models/llama/install_requirements.sh
49-
bash ".ci/scripts/test_llama.sh" -model stories110M -build_tool cmake -dtype fp16 -mode portable -upload ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
56+
- name: Upload artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: android-apps
60+
path: |
61+
aar-out/executorch.aar
62+
extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk
5063
5164
# Running Android emulator directly on the runner and not using Docker
5265
run-emulator:
53-
needs: build-llm-demo
66+
needs: build-android
5467
# NB: This job runs on the shared 8-core-ubuntu runner; KVM / bare-metal assumptions no longer apply
5568
runs-on: 8-core-ubuntu
5669
env:
57-
ANDROID_NDK_VERSION: r28c
5870
API_LEVEL: 34
5971
steps:
6072
- name: Setup SSH (Click me for login details)
6173
uses: pytorch/test-infra/.github/actions/setup-ssh@main
6274
with:
6375
github-secret: ${{ secrets.GITHUB_TOKEN }}
6476
instructions: |
65-
This is used to run Android emulators, ANDROID_HOME is installed at /opt/android/sdk
77+
This is used to run Android emulators
6678
67-
- uses: actions/checkout@v3
79+
- uses: actions/checkout@v4
6880
with:
6981
submodules: false
7082

71-
- name: Setup conda
72-
uses: pytorch/test-infra/.github/actions/setup-miniconda@main
83+
- name: Download Artifacts
84+
uses: actions/download-artifact@v4
7385
with:
74-
python-version: '3.10'
75-
76-
- name: Install Android dependencies
77-
shell: bash
78-
run: |
79-
set -eux
86+
name: android-apps
8087

81-
# Reuse the script that install Android on ET Docker image
82-
sudo -E bash .ci/docker/common/install_android.sh
83-
84-
# After https://github.com/ReactiveCircus/android-emulator-runner/releases/tag/v2.33.0 release,
85-
# it seems that we need to chown the Android setup to the current user instead of root to
86-
# avoid permission issue
87-
sudo chown -R "${USER}" /opt/android
88-
89-
- name: Download Artifacts
90-
shell: bash
88+
- name: Prepare test APK
9189
run: |
92-
set -eux
93-
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
94-
curl -o android-test-debug-androidTest.apk https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/library_test_dir/executorch_android-debug-androidTest.apk
95-
unzip model.zip
96-
mv *.pte model.pte
97-
98-
- name: Gradle cache
99-
uses: gradle/actions/setup-gradle@v3
90+
cp extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk android-test-debug-androidTest.apk
10091
10192
- name: AVD cache
10293
uses: actions/cache@v4
@@ -109,21 +100,15 @@ jobs:
109100

110101
# NB: It takes about 10m to cold boot the emulator here
111102
- name: Run Android emulator
112-
env:
113-
ANDROID_HOME: /opt/android/sdk
114103
uses: reactivecircus/android-emulator-runner@v2
115104
with:
116105
api-level: ${{ env.API_LEVEL }}
117106
arch: x86_64
118107
script: ./scripts/run_android_emulator.sh
119-
# NB: This is to boot the emulator faster following the instructions on
120-
# https://github.com/ReactiveCircus/android-emulator-runner. The max number
121-
# of cores we can set is 6, any higher number will be reduced to 6.
122108
cores: 6
123109
ram-size: 16384M
124110
heap-size: 12288M
125111
force-avd-creation: false
126112
disable-animations: true
127113
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
128-
# This is to make sure that the job doesn't fail flakily
129114
emulator-boot-timeout: 900

.github/workflows/lint.yml

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,58 +21,58 @@ jobs:
2121
uses: ./.github/workflows/_get-changed-files.yml
2222

2323
lintrunner-mypy:
24-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
2524
needs: [get-changed-files]
25+
runs-on: ubuntu-latest
2626
permissions:
27-
id-token: write
2827
contents: read
2928
if: |
30-
github.repository_owner == 'pytorch' && (
31-
needs.get-changed-files.outputs.changed-files == '*' ||
32-
contains(needs.get-changed-files.outputs.changed-files, '.py') ||
33-
contains(needs.get-changed-files.outputs.changed-files, '.pyi')
34-
)
35-
with:
36-
runner: linux.2xlarge
37-
docker-image: ci-image:executorch-ubuntu-22.04-linter
38-
submodules: 'recursive'
39-
fetch-depth: 0
40-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
41-
timeout: 90
42-
script: |
43-
# The generic Linux job chooses to use base env, not the one setup by the image
44-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
45-
conda activate "${CONDA_ENV}"
46-
47-
# For mypy linting, we need to first install executorch first so that
48-
# it builds the python package information.
49-
BUILD_TOOL="cmake"
50-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "${BUILD_TOOL}"
51-
52-
CACHE_DIRECTORY="/tmp/.lintbin"
53-
# Try to recover the cached binaries
54-
if [[ -d "${CACHE_DIRECTORY}" ]]; then
55-
# It's ok to fail this as lintrunner init would download these binaries
56-
# again if they do not exist
57-
cp -r "${CACHE_DIRECTORY}" . || true
58-
fi
59-
60-
RC=0
61-
# Run lintrunner on all files. pytorch/pytorch notes that mypy
62-
# in particular needs this.
63-
if ! lintrunner --force-color --all-files --take MYPY --tee-json=lint.json 2> /dev/null; then
64-
echo ""
65-
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner --take MYPY\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
66-
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
67-
RC=1
68-
fi
69-
70-
# Use jq to massage the JSON lint output into GitHub Actions workflow commands.
71-
jq --raw-output \
72-
'"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
73-
lint.json || true
74-
75-
exit $RC
29+
needs.get-changed-files.outputs.changed-files == '*' ||
30+
contains(needs.get-changed-files.outputs.changed-files, '.py') ||
31+
contains(needs.get-changed-files.outputs.changed-files, '.pyi')
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
36+
37+
- name: Checkout torchao submodule
38+
run: git submodule update --init third-party/ao
39+
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: '3.11'
43+
cache: 'pip'
44+
cache-dependency-path: requirements-lintrunner.txt
45+
46+
- name: Install dependencies
47+
run: |
48+
pip install torch --index-url https://download.pytorch.org/whl/cpu
49+
pip install lintrunner==0.12.7 lintrunner-adapters==0.13.0
50+
pip install -r requirements-lintrunner.txt
51+
USE_CPP=0 pip install --no-build-isolation third-party/ao
52+
pip install pytest numpy parameterized huggingface_hub transformers timm expecttest types-requests
53+
pip install torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
54+
55+
- name: Generate mypy stubs for C++ bindings
56+
run: |
57+
cp extension/pybindings/pybindings.pyi extension/pybindings/_portable_lib.pyi
58+
59+
- name: Run mypy
60+
run: |
61+
lintrunner init
62+
RC=0
63+
if ! lintrunner --force-color --all-files --take MYPY --tee-json=lint.json 2> /dev/null; then
64+
echo ""
65+
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner --take MYPY\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
66+
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
67+
RC=1
68+
fi
69+
70+
# Use jq to massage the JSON lint output into GitHub Actions workflow commands.
71+
jq --raw-output \
72+
'"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
73+
lint.json || true
74+
75+
exit $RC
7676
7777
lintrunner:
7878
needs: [get-changed-files]

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,11 @@ if(EXECUTORCH_BUILD_PYBIND)
987987
-fexceptions>
988988
)
989989

990-
# util lib
990+
# util lib PyTorch requires C++20, so util must be compiled with C++20.
991991
add_library(
992992
util ${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
993993
)
994+
set_target_properties(util PROPERTIES CXX_STANDARD 20)
994995
target_include_directories(
995996
util PUBLIC ${_common_include_directories} ${TORCH_INCLUDE_DIRS}
996997
)
@@ -1002,8 +1003,11 @@ if(EXECUTORCH_BUILD_PYBIND)
10021003
# pybind portable_lib
10031004
pybind11_add_module(portable_lib SHARED extension/pybindings/pybindings.cpp)
10041005
# The actual output file needs a leading underscore so it can coexist with
1005-
# portable_lib.py in the same python package.
1006-
set_target_properties(portable_lib PROPERTIES OUTPUT_NAME "_portable_lib")
1006+
# portable_lib.py in the same python package. PyTorch requires C++20, so
1007+
# pybindings must be compiled with C++20.
1008+
set_target_properties(
1009+
portable_lib PROPERTIES OUTPUT_NAME "_portable_lib" CXX_STANDARD 20
1010+
)
10071011
target_compile_definitions(
10081012
portable_lib PUBLIC EXECUTORCH_PYTHON_MODULE_NAME=_portable_lib
10091013
)

CMakePresets.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,8 @@
290290
"name": "arm-ethosu-linux",
291291
"displayName": "Build ExecuTorch for Arm Ethos-U Linux",
292292
"inherits": ["common"],
293-
"description": "musl declares __assert_fail with int for line; avoid NDEBUG forward-decl mismatch in Release builds",
294293
"cacheVariables": {
295-
"EXECUTORCH_BUILD_ARM_ETHOSU_LINUX": "ON",
296-
"EXECUTORCH_BUILD_EXECUTOR_RUNNER": "ON",
297-
"EXECUTORCH_BUILD_KERNELS_QUANTIZED": "ON",
298-
"CMAKE_C_FLAGS_RELEASE": "-UNDEBUG",
299-
"CMAKE_CXX_FLAGS_RELEASE": "-UNDEBUG",
294+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/arm_ethosu_linux.cmake",
300295
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/examples/arm/ethos-u-setup/aarch64-linux-musl-toolchain.cmake"
301296
}
302297
}

0 commit comments

Comments
 (0)