Skip to content

Commit 5168a78

Browse files
committed
Update on "Re-enable optimized gelu test in CMake"
I missed this line disabling the test. (Splitting out re-enable of log_softmax because I think that one needs fixes.) Differential Revision: [D69929122](https://our.internmc.facebook.com/intern/diff/D69929122/) [ghstack-poisoned]
2 parents cb7292d + 197c0ac commit 5168a78

File tree

144 files changed

+2952
-1100
lines changed

Some content is hidden

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

144 files changed

+2952
-1100
lines changed

.buckconfig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
root = .
99
prelude = third-party/prelude
1010
shim = shim
11+
shim_et = shim_et
1112

1213
[repository_aliases]
1314
config = prelude
1415
ovr_config = prelude
15-
toolchains = shim
16-
fbcode = shim
17-
fbcode_macros = shim
18-
fbsource = shim
16+
toolchains = shim_et
17+
fbcode = shim_et
18+
fbcode_macros = shim_et
19+
fbsource = shim_et
1920
buck = shim
2021

2122
[cxx]

.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

0 commit comments

Comments
 (0)