Skip to content

Commit 3d84fb0

Browse files
authored
Merge branch 'main' into relative-paths-react-demo-ios
2 parents c6d7ed2 + cc5b3ed commit 3d84fb0

File tree

102 files changed

+2416
-827
lines changed

Some content is hidden

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

102 files changed

+2416
-827
lines changed

.ci/scripts/setup-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fi
2222
# have already been installed, so we use PyTorch build from source here instead
2323
# of nightly. This allows CI to test against latest commits from PyTorch
2424
install_executorch "use-pt-pinned-commit"
25-
build_executorch_runner "${BUILD_TOOL}"
25+
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"
2626

2727
if [[ "${GITHUB_BASE_REF:-}" == *main* || "${GITHUB_BASE_REF:-}" == *gh* ]]; then
2828
do_not_use_nightly_on_ci

.ci/scripts/setup-macos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ install_pytorch_and_domains
136136
# We build PyTorch from source here instead of using nightly. This allows CI to test against
137137
# the pinned commit from PyTorch
138138
install_executorch "use-pt-pinned-commit"
139-
build_executorch_runner "${BUILD_TOOL}"
139+
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"
140140

141141
if [[ "${GITHUB_BASE_REF:-}" == *main* || "${GITHUB_BASE_REF:-}" == *gh* ]]; then
142142
do_not_use_nightly_on_ci

.ci/scripts/unittest-linux.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ else
1414
exit 1
1515
fi
1616

17+
BUILD_MODE=$2
18+
if [[ "${BUILD_MODE:-}" =~ ^(Debug|Release)$ ]]; then
19+
echo "Running tests in build mode ${BUILD_MODE} ..."
20+
else
21+
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
22+
exit 1
23+
fi
24+
1725
# The generic Linux job chooses to use base env, not the one setup by the image
1826
eval "$(conda shell.bash hook)"
1927
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
@@ -25,7 +33,7 @@ source .ci/scripts/setup-vulkan-linux-deps.sh
2533
PYTHON_EXECUTABLE=python \
2634
EXECUTORCH_BUILD_PYBIND=ON \
2735
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
28-
.ci/scripts/setup-linux.sh "$BUILD_TOOL"
36+
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
2937

3038
# Install llama3_2_vision dependencies.
3139
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh

.ci/scripts/unittest-macos.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ else
1414
exit 1
1515
fi
1616

17+
BUILD_MODE=$2
18+
if [[ $BUILD_MODE =~ ^(Debug|Release)$ ]]; then
19+
echo "Running tests in build mode ${BUILD_MODE} ..."
20+
else
21+
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
22+
exit 1
23+
fi
24+
1725
bash .ci/scripts/setup-conda.sh
1826
eval "$(conda shell.bash hook)"
1927

@@ -27,10 +35,12 @@ PYTHON_EXECUTABLE=python \
2735
EXECUTORCH_BUILD_PYBIND=ON \
2836
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
2937
${CONDA_RUN} --no-capture-output \
30-
.ci/scripts/setup-macos.sh cmake
38+
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"
3139

3240
# Install llama3_2_vision dependencies.
33-
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
41+
PYTHON_EXECUTABLE=python \
42+
${CONDA_RUN} --no-capture-output \
43+
./examples/models/llama3_2_vision/install_requirements.sh
3444

3545
if [[ "$BUILD_TOOL" == "cmake" ]]; then
3646
.ci/scripts/unittest-macos-cmake.sh

.ci/scripts/utils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ build_executorch_runner_cmake() {
109109
pushd "${CMAKE_OUTPUT_DIR}" || return
110110
# This command uses buck2 to gather source files and buck2 could crash flakily
111111
# on MacOS
112-
retry cmake -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DCMAKE_BUILD_TYPE=Release ..
112+
retry cmake -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DCMAKE_BUILD_TYPE="${1:-Release}" ..
113113
popd || return
114114

115115
if [ "$(uname)" == "Darwin" ]; then
@@ -124,7 +124,7 @@ build_executorch_runner() {
124124
if [[ $1 == "buck2" ]]; then
125125
build_executorch_runner_buck2
126126
elif [[ $1 == "cmake" ]]; then
127-
build_executorch_runner_cmake
127+
build_executorch_runner_cmake "$2"
128128
else
129129
echo "Invalid build tool $1. Only buck2 and cmake are supported atm"
130130
exit 1

.github/scripts/extract_benchmark_results.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,22 @@ def extract_ios_metric(
229229

230230
elif method == "forward":
231231
if metric_name == "Clock Monotonic Time, s":
232-
benchmark_result["metric"] = (
233-
"generate_time(ms)"
234-
if "llama" in test_name
235-
else "avg_inference_latency(ms)"
236-
)
232+
benchmark_result["metric"] = "avg_inference_latency(ms)"
237233
benchmark_result["actualValue"] = metric_value * 1000
238234

239235
elif metric_name == "Memory Peak Physical, kB":
240236
# NB: Showing the value in mB is friendlier IMO
241237
benchmark_result["metric"] = "peak_inference_mem_usage(mb)"
242238
benchmark_result["actualValue"] = metric_value / 1024
243239

244-
elif method == "generate" and metric_name == "Tokens Per Second, t/s":
245-
benchmark_result["metric"] = "token_per_sec"
246-
benchmark_result["actualValue"] = metric_value
240+
elif method == "generate":
241+
if metric_name == "Clock Monotonic Time, s":
242+
benchmark_result["metric"] = "generate_time(ms)"
243+
benchmark_result["actualValue"] = metric_value * 1000
244+
245+
elif metric_name == "Tokens Per Second, t/s":
246+
benchmark_result["metric"] = "token_per_sec"
247+
benchmark_result["actualValue"] = metric_value
247248

248249
return benchmark_result
249250

.github/workflows/_unittest.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
required: true
88
type: string
99
description: Name of the docker image to use.
10+
build-mode:
11+
required: true
12+
type: string
13+
description: Build mode to use, Debug or Release.
1014
build-tool:
1115
required: true
1216
type: string
@@ -30,7 +34,7 @@ jobs:
3034
timeout: 90
3135
script: |
3236
set -eux
33-
.ci/scripts/unittest-linux.sh "${{ inputs.build-tool }}"
37+
.ci/scripts/unittest-linux.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"
3438
3539
macos:
3640
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -41,4 +45,4 @@ jobs:
4145
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
4246
script: |
4347
set -eux
44-
.ci/scripts/unittest-macos.sh "${{ inputs.build-tool }}"
48+
.ci/scripts/unittest-macos.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"

.github/workflows/pull.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ jobs:
367367
id-token: write
368368
contents: read
369369
with:
370+
build-mode: Debug
370371
build-tool: cmake
371372
docker-image: executorch-ubuntu-22.04-clang12
372373

@@ -376,6 +377,7 @@ jobs:
376377
id-token: write
377378
contents: read
378379
with:
380+
build-mode: Debug
379381
build-tool: buck2
380382
docker-image: executorch-ubuntu-22.04-clang12
381383

.github/workflows/trunk.yml

Lines changed: 42 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,13 @@ jobs:
374374
secrets: inherit
375375
strategy:
376376
matrix:
377-
hf_model_repo: [google/gemma-2-2b]
377+
hf_model_id: [
378+
google/gemma-2-2b,
379+
Qwen/Qwen2.5-0.5B,
380+
HuggingFaceTB/SmolLM2-135M,
381+
meta-llama/Llama-3.2-1B,
382+
allenai/OLMo-1B-hf
383+
]
378384
fail-fast: false
379385
with:
380386
secrets-env: EXECUTORCH_HF_TOKEN
@@ -389,66 +395,39 @@ jobs:
389395
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
390396
conda activate "${CONDA_ENV}"
391397
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh cmake
392-
393-
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
394-
rm -rf cmake-out
395-
cmake \
396-
-DCMAKE_INSTALL_PREFIX=cmake-out \
397-
-DCMAKE_BUILD_TYPE=Release \
398-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
399-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
400-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
401-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
402-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
403-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
404-
-DEXECUTORCH_BUILD_XNNPACK=ON \
405-
-DPYTHON_EXECUTABLE=python \
406-
-Bcmake-out .
407-
cmake --build cmake-out -j9 --target install --config Release
408-
409-
echo "Build llama runner"
410-
dir="examples/models/llama"
411-
cmake \
412-
-DCMAKE_INSTALL_PREFIX=cmake-out \
413-
-DCMAKE_BUILD_TYPE=Release \
414-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
415-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
416-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
417-
-DEXECUTORCH_BUILD_XNNPACK=ON \
418-
-DPYTHON_EXECUTABLE=python \
419-
-Bcmake-out/${dir} \
420-
${dir}
421-
cmake --build cmake-out/${dir} -j9 --config Release
422398
echo "::endgroup::"
423399
424-
echo "::group::Set up HuggingFace Dependencies"
425-
if [ -z "$SECRET_EXECUTORCH_HF_TOKEN" ]; then
426-
echo "::error::SECRET_EXECUTORCH_HF_TOKEN is empty. For security reason secrets won't be accessible on forked PRs. Please make sure you submit a non-forked PR."
427-
exit 1
428-
fi
400+
echo "::group::Set up Hugging Face"
429401
pip install -U "huggingface_hub[cli]"
430402
huggingface-cli login --token $SECRET_EXECUTORCH_HF_TOKEN
403+
git clone https://github.com/huggingface/optimum-executorch
404+
cd optimum-executorch
405+
# There is no release yet, for CI stability, always test from the same commit on main
406+
git checkout 6a7e83f3eee2976fa809335bfb78a45b1ea1cb25
407+
pip install .
431408
pip install accelerate sentencepiece
432409
pip list
433410
echo "::endgroup::"
434411
435-
echo "::group::Export to ExecuTorch"
436-
TOKENIZER_FILE=tokenizer.model
437-
TOKENIZER_BIN_FILE=tokenizer.bin
438-
ET_MODEL_NAME=et_model
439-
DOWNLOADED_TOKENIZER_FILE_PATH=$(bash .ci/scripts/download_hf_hub.sh --model_id "${{ matrix.hf_model_repo }}" --files "${TOKENIZER_FILE}")
440-
if [ -f "$DOWNLOADED_TOKENIZER_FILE_PATH/$TOKENIZER_FILE" ]; then
441-
echo "${TOKENIZER_FILE} downloaded successfully at: $DOWNLOADED_TOKENIZER_FILE_PATH"
442-
python -m extension.llm.tokenizer.tokenizer -t "$DOWNLOADED_TOKENIZER_FILE_PATH/$TOKENIZER_FILE" -o ./${TOKENIZER_BIN_FILE}
443-
ls ./tokenizer.bin
444-
else
445-
echo "Failed to download ${TOKENIZER_FILE} from ${{ matrix.hf_model_repo }}."
446-
exit 1
447-
fi
448-
449-
python -m extension.export_util.export_hf_model -hfm=${{ matrix.hf_model_repo }} -o ${ET_MODEL_NAME}
450-
451-
cmake-out/examples/models/llama/llama_main --model_path=${ET_MODEL_NAME}.pte --tokenizer_path=${TOKENIZER_BIN_FILE} --prompt="My name is"
412+
echo "::group::Export and Run ${{ matrix.hf_model_id }}"
413+
# Pass matrix variable as environment variable
414+
export MODEL_ID="${{ matrix.hf_model_id }}"
415+
python -c "
416+
import os
417+
from optimum.executorch import ExecuTorchModelForCausalLM
418+
from transformers import AutoTokenizer
419+
420+
model_id = os.getenv('MODEL_ID')
421+
print(f'Loading model: {model_id}')
422+
model = ExecuTorchModelForCausalLM.from_pretrained(model_id, recipe='xnnpack')
423+
tokenizer = AutoTokenizer.from_pretrained(model_id)
424+
generated_text = model.text_generation(
425+
tokenizer=tokenizer,
426+
prompt='Simply put, the theory of relativity states that',
427+
max_seq_len=64
428+
)
429+
print(generated_text)
430+
"
452431
echo "::endgroup::"
453432
454433
@@ -489,3 +468,13 @@ jobs:
489468
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
490469
# Test llama2
491470
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh -model stories110M -build_tool "${BUILD_TOOL}" -mode "${MODE}" -dtype "${DTYPE}" -pt2e_quantize "${PT2E_QUANTIZE}"
471+
472+
unittest-release:
473+
uses: ./.github/workflows/_unittest.yml
474+
permissions:
475+
id-token: write
476+
contents: read
477+
with:
478+
build-mode: Release
479+
build-tool: cmake
480+
docker-image: executorch-ubuntu-22.04-clang12

backends/apple/coreml/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ runtime.cxx_python_extension(
7676
base_module = "",
7777
visibility = [
7878
"//executorch/examples/apple/coreml/...",
79+
"@EXECUTORCH_CLIENTS",
7980
],
8081
external_deps = [
8182
"pybind11",

backends/arm/_passes/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ python_library(
77
deps = [
88
"//executorch/backends/arm:tosa_quant_utils",
99
"//executorch/backends/arm:tosa_utils",
10+
"//executorch/backends/transforms:replace_scalar_with_tensor",
1011
"//executorch/backends/xnnpack/_passes:xnnpack_passes",
1112
"//executorch/exir:lib",
1213
],

backends/arm/operator_support/TARGETS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ python_library(
55
srcs = glob(["*.py"]),
66
typing = True,
77
deps = [
8+
"//executorch/backends/arm/_passes:passes",
9+
"//executorch/backends/arm:tosa_specification",
810
"//executorch/backends/xnnpack/_passes:xnnpack_passes",
911
"//executorch/exir:lib",
10-
"//executorch/backends/arm:tosa_specification"
1112
],
1213
)

backends/arm/test/misc/test_multiple_outputs.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,21 @@ def _test_ethosu_BI_pipeline(
7676
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)
7777

7878
@pytest.mark.corstone_fvp
79-
def test_u85_BI(self):
79+
def test_u55_BI(self):
8080
module = self.MultipleOutputsModule()
8181
test_data = module.get_inputs()
8282
self._test_ethosu_BI_pipeline(
8383
module,
8484
test_data,
85-
common.get_u85_compile_spec(),
85+
common.get_u55_compile_spec(),
8686
)
8787

8888
@pytest.mark.corstone_fvp
89-
@conftest.expectedFailureOnFVP
90-
# TODO MLETORCH-598
91-
def test_u55_BI(self):
89+
def test_u85_BI(self):
9290
module = self.MultipleOutputsModule()
9391
test_data = module.get_inputs()
9492
self._test_ethosu_BI_pipeline(
9593
module,
9694
test_data,
97-
common.get_u55_compile_spec(),
95+
common.get_u85_compile_spec(),
9896
)

backends/arm/test/misc/test_partition_decomposed_quantized_ops.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def test_softplus_tosa_BI(test_data: input_t1):
6060
pipeline.pop_stage("check_not.exir")
6161
# check that all ops in exir_op except add are rejected
6262
pipeline.add_stage_after(
63-
"partition", pipeline.tester.check, exir_op[1:], suffix="exir_post_partition"
63+
"to_edge_transform_and_lower",
64+
pipeline.tester.check,
65+
exir_op[1:],
66+
suffix="exir_post_partition",
6467
)
6568
pipeline.run()

backends/arm/test/ops/test_bmm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ def test_bmm_single_input_tosa_BI(self, test_data_generator: Callable[[], Tuple]
150150
test_data = test_data_generator()
151151
self._test_bmm_tosa_BI_pipeline(self.BMMSingleInput(), test_data)
152152

153+
# Expected to fail on FVP as TOSA.MATMUL is not supported on U55
153154
@parameterized.expand(BMM.test_data_generators)
154155
@pytest.mark.corstone_fvp
155-
@unittest.expectedFailure
156+
@conftest.expectedFailureOnFVP
156157
def test_bmm_u55_BI_xfails(self, test_data_generator: Callable[[], Tuple]):
157158
test_data = test_data_generator()
158159
self._test_bmm_ethosu_BI_pipeline(
@@ -167,10 +168,10 @@ def test_bmm_u85_BI(self, test_data_generator: Callable[[], Tuple]):
167168
self.BMM(), common.get_u85_compile_spec(), test_data
168169
)
169170

170-
# Expected to fail with error: Warning, unsupported fusing of TOSA Rescale previous operator is of type: Memcpy
171+
# Expected to fail on FVP as TOSA.MATMUL is not supported on U55
171172
@parameterized.expand(BMMSingleInput.test_data_generators)
172173
@pytest.mark.corstone_fvp
173-
@unittest.expectedFailure
174+
@conftest.expectedFailureOnFVP
174175
def test_bmm_single_input_u55_BI_xfails(
175176
self, test_data_generator: Callable[[], Tuple]
176177
):

backends/arm/test/ops/test_conv2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def test_conv2d_tosa_BI(test_module):
370370
pipeline = TosaPipelineBI[input_t](
371371
test_module, test_module.get_inputs(), aten_op, exir_op
372372
)
373-
pipeline.change_args("run_method_and_compare_outputs.0", qtol=1)
373+
pipeline.change_args("run_method_and_compare_outputs", qtol=1)
374374
pipeline.run()
375375

376376

0 commit comments

Comments
 (0)