Skip to content

Commit 28f0d98

Browse files
authored
Merge branch 'main' into op_support
2 parents 246d9cb + 534defd commit 28f0d98

File tree

359 files changed

+9770
-3803
lines changed

Some content is hidden

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

359 files changed

+9770
-3803
lines changed

.buckconfig

+3
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@
3939

4040
[buck2]
4141
restarter=true
42+
43+
[oss]
44+
folly_cxx_tests = False

.ci/docker/ci_commit_pins/pytorch.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
27e35de6c288bffad1b4d18b393579c1d1a95547
1+
08434df1f2f88c9770e59246caa2ff9c6f613270

.ci/docker/common/install_java.sh

+12
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

+4
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

+4
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

+1
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

+33
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

+4
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

+17-1
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

+12-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ set -eux
88

99
# TODO: expand this to //...
1010
# TODO: can't query cadence & vulkan backends
11+
# TODO: can't query //kernels/prim_ops because of a cpp_unittest and
12+
# broken code in shim to read oss.folly_cxx_tests. Sending fix but it
13+
# needs to propagate and we need a submodule update.
1114
buck2 query "//backends/apple/... + //backends/example/... + \
1215
//backends/mediatek/... + //backends/test/... + //backends/transforms/... + \
13-
//backends/xnnpack/... + //configurations/... + //kernels/portable/cpu/... + \
14-
//runtime/... + //schema/... + //test/... + //util/..."
16+
//backends/xnnpack/... + //configurations/... + //kernels/aten/... + \
17+
//kernels/optimized/... + //kernels/portable/... + //kernels/quantized/... + \
18+
//kernels/test/... + //runtime/... + //schema/... + //test/... + //util/..."
1519

20+
UNBUILDABLE_OPTIMIZED_OPS_REGEX="gelu|fft_r2c|log_softmax"
21+
BUILDABLE_OPTIMIZED_OPS=$(buck2 query //kernels/optimized/cpu/... | grep -E -v $UNBUILDABLE_OPTIMIZED_OPS_REGEX)
1622
# TODO: expand the covered scope of Buck targets.
17-
buck2 build //runtime/core/portable_type/...
18-
buck2 test //runtime/core/portable_type/...
23+
# //runtime/kernel/... is failing because //third-party:torchgen_files's shell script can't find python on PATH.
24+
# //runtime/test/... requires Python torch, which we don't have in our OSS buck setup.
25+
buck2 test $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... //runtime/backend/... //runtime/core/... \
26+
//runtime/executor: //runtime/kernel/... //runtime/platform/...

.github/workflows/doc-build.yml

+7
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ jobs:
6868
make html
6969
cd ..
7070
71+
# Build javadoc:
72+
cd extension/android
73+
./gradlew javadoc
74+
cp -rf build/docs/javadoc "${RUNNER_DOCS_DIR}"
75+
cd ../..
76+
7177
# If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
7278
echo "GitHub Ref: ${GITHUB_REF}"
7379
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
@@ -77,6 +83,7 @@ jobs:
7783
cp -rf docs/_build/html/* "${RUNNER_DOCS_DIR}"
7884
7985
mv docs/_build/html "${RUNNER_ARTIFACT_DIR}"
86+
cp -rf "${RUNNER_DOCS_DIR}"/javadoc "${RUNNER_ARTIFACT_DIR}"/html
8087
8188
ls -R "${RUNNER_ARTIFACT_DIR}"/*/*.html
8289

.github/workflows/trunk.yml

+23-1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,28 @@ jobs:
229229
# see if we can import the module successfully
230230
${CONDA_RUN} python -c "from executorch.extension.pybindings import portable_lib; print('success!')"
231231
232+
test-static-llama-ane:
233+
name: test-static-llama-ane
234+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
235+
with:
236+
runner: macos-m1-stable
237+
python-version: '3.11'
238+
submodules: 'true'
239+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
240+
script: |
241+
set -eux
242+
bash .ci/scripts/setup-conda.sh
243+
eval "$(conda shell.bash hook)"
244+
245+
# Install requirements
246+
sh install_requirements.sh
247+
sh backends/apple/coreml/scripts/install_requirements.sh
248+
python install_executorch.py --pybind coreml
249+
sh examples/models/llama/install_requirements.sh
250+
251+
# Test ANE llama
252+
sh .ci/scripts/test_ane_static_llama.sh
253+
232254
test-llama-runner-macos:
233255
name: test-llama-runner-mac
234256
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -311,7 +333,7 @@ jobs:
311333
strategy:
312334
matrix:
313335
dtype: [fp32]
314-
model: [dl3, mv3, mv2, ic4, ic3, vit]
336+
model: [dl3, mv3, mv2, ic4, ic3, vit, mb, w2l]
315337
fail-fast: false
316338
with:
317339
runner: linux.2xlarge

.github/workflows/update-viablestrict.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ concurrency:
1212
jobs:
1313
do_update_viablestrict:
1414
if: ${{ github.repository_owner == 'pytorch' }}
15-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-22.04
1616
environment: ${{ (github.event_name == 'schedule') && 'update-viable-strict' || '' }}
1717
steps:
1818
- name: Update viable/strict

.gitmodules

+3-9
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,9 @@
2828
[submodule "backends/xnnpack/third-party/pthreadpool"]
2929
path = backends/xnnpack/third-party/pthreadpool
3030
url = https://github.com/Maratyszcza/pthreadpool.git
31-
[submodule "extension/llm/third-party/abseil-cpp"]
32-
path = extension/llm/third-party/abseil-cpp
33-
url = https://github.com/abseil/abseil-cpp.git
34-
[submodule "extension/llm/third-party/re2"]
35-
path = extension/llm/third-party/re2
36-
url = https://github.com/google/re2.git
37-
[submodule "extension/llm/third-party/sentencepiece"]
38-
path = extension/llm/third-party/sentencepiece
39-
url = https://github.com/google/sentencepiece.git
31+
[submodule "extension/llm/tokenizers"]
32+
path = extension/llm/tokenizers
33+
url = https://github.com/pytorch-labs/tokenizers.git
4034
[submodule "kernels/optimized/third-party/eigen"]
4135
path = kernels/optimized/third-party/eigen
4236
url = https://gitlab.com/libeigen/eigen.git

.lintrunner.toml

+2
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ exclude_patterns = [
218218
'examples/**',
219219
'extension/**',
220220
'kernels/optimized/**',
221+
# Justified <functional> include.
222+
'runtime/kernel/thread_parallel_interface.h',
221223
'scripts/**',
222224
'third-party/**',
223225
'util/**',

CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,15 @@ cmake_dependent_option(
248248
"NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF
249249
)
250250

251-
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
251+
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
252252
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
253+
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
254+
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
255+
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
253256
endif()
254257

255-
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
256-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
258+
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
257259
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
258-
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
259260
endif()
260261

261262
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
@@ -748,7 +749,6 @@ endif()
748749

749750
if(EXECUTORCH_BUILD_PTHREADPOOL
750751
AND EXECUTORCH_BUILD_CPUINFO
751-
AND CMAKE_CXX_STANDARD GREATER_EQUAL 14
752752
)
753753
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/threadpool)
754754
endif()

CODEOWNERS

+16-16
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/backends/vulkan @SS-JIA
1616
/backends/xnnpack @digantdesai @mcr229
1717

18-
/build @GregoryComer @dbort @kirklandsign
18+
/build @GregoryComer @kirklandsign
1919

2020
/codegen @larryliu0820 @lucylq
2121

@@ -47,36 +47,36 @@
4747
/extension/apple @shoumikhin
4848
/extension/aten_util @JacobSzwejbka
4949
/extension/benchmark @tarun292
50-
/extension/data_loader @JacobSzwejbka @lucylq @dbort
51-
/extension/evalue_util @GregoryComer @dbort
50+
/extension/data_loader @JacobSzwejbka @lucylq
51+
/extension/evalue_util @GregoryComer
5252
/extension/export_util @kimishpatel
5353
/extension/flat_tensor @lucylq
5454
/extension/gguf_util @larryliu0820
55-
/extension/kernel_util @kimishpatel @manuelcandales
56-
/extension/llm @jackzhxng @iseeyuan @larryliu0820
57-
/extension/memory_allocator @JacobSzwejbka @dbort
55+
/extension/kernel_util @kimishpatel @manuelcandales @swolchok
56+
/extension/llm @jackzhxng @iseeyuan @larryliu0820 @swolchok
57+
/extension/memory_allocator @JacobSzwejbka @swolchok
5858
/extension/module @shoumikhin
59-
/extension/parallel @kimishpatel
59+
/extension/parallel @kimishpatel @swolchok
6060
/extension/pybindings @JacobSzwejbka @larryliu0820
61-
/extension/pytree @JacobSzwejbka
62-
/extension/runner_util @dbort
61+
/extension/pytree @JacobSzwejbka @swolchok
62+
/extension/runner_util @swolchok
6363
/extension/tensor @shoumikhin
64-
/extension/testing_util @dbort
65-
/extension/threadpool @kimishpatel
64+
/extension/testing_util @swolchok
65+
/extension/threadpool @kimishpatel @swolchok
6666
/extension/training @JacobSzwejbka
6767

68-
/kernels @manuelcandales
68+
/kernels @manuelcandales @swolchok
6969

7070
/profiler @tarun292 @Gasoonjia
7171

72-
/runtime @dbort @JacobSzwejbka @lucylq
72+
/runtime @JacobSzwejbka @lucylq @swolchok
7373
/runtime/backend @cccclai
7474

75-
/schema @dbort @JacobSzwejbka @lucylq
75+
/schema @JacobSzwejbka @lucylq
7676

77-
/scripts @GregoryComer
77+
/scripts @GregoryComer @swolchok
7878

79-
/shim @larryliu0820 @GregoryComer
79+
/shim @larryliu0820 @GregoryComer @swolchok
8080

8181
/third-party @GregoryComer
8282

Test.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ if(BUILD_TESTING)
1313
add_subdirectory(extension/evalue_util/test)
1414
add_subdirectory(extension/kernel_util/test)
1515
add_subdirectory(extension/memory_allocator/test)
16-
add_subdirectory(extension/parallel/test)
1716
add_subdirectory(extension/pytree/test)
1817
add_subdirectory(kernels/portable/cpu/util/test)
1918
add_subdirectory(kernels/prim_ops/test)

0 commit comments

Comments
 (0)