Skip to content

Commit 4139ed9

Browse files
Merge branch 'main' into remove-repeated-recompiles-in-constant-fusion
2 parents f1d2775 + af90130 commit 4139ed9

89 files changed

Lines changed: 1178 additions & 859 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/docker/build.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,6 @@ esac
9292
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
9393
BUILD_DOCS=1
9494

95-
# Pull channel + spec/url helpers out of torch_pin.py so install_pytorch.sh
96-
# (which runs inside the docker build, where torch_pin.py isn't available)
97-
# can decide between wheel install (test/release) and source build (nightly).
98-
# Self-hosted runners often have python3 but not the unversioned python alias.
99-
PYTHON_BIN=$(command -v python3 || command -v python)
100-
TORCH_PIN_HELPERS=$(cd ../.. && "$PYTHON_BIN" -c "from torch_pin import CHANNEL, torch_spec, torchaudio_spec, torchvision_spec, torch_index_url_base; print(CHANNEL); print(torch_spec()); print(torchaudio_spec()); print(torchvision_spec()); print(torch_index_url_base())")
101-
TORCH_CHANNEL=$(echo "${TORCH_PIN_HELPERS}" | sed -n '1p')
102-
TORCH_SPEC=$(echo "${TORCH_PIN_HELPERS}" | sed -n '2p')
103-
TORCHAUDIO_SPEC=$(echo "${TORCH_PIN_HELPERS}" | sed -n '3p')
104-
TORCHVISION_SPEC=$(echo "${TORCH_PIN_HELPERS}" | sed -n '4p')
105-
TORCH_INDEX_URL=$(echo "${TORCH_PIN_HELPERS}" | sed -n '5p')
106-
10795
# Copy requirements-lintrunner.txt from root to here
10896
cp ../../requirements-lintrunner.txt ./
10997

@@ -116,11 +104,6 @@ docker build \
116104
--build-arg "PYTHON_VERSION=${PYTHON_VERSION}" \
117105
--build-arg "MINICONDA_VERSION=${MINICONDA_VERSION}" \
118106
--build-arg "TORCH_VERSION=${TORCH_VERSION}" \
119-
--build-arg "TORCH_CHANNEL=${TORCH_CHANNEL}" \
120-
--build-arg "TORCH_SPEC=${TORCH_SPEC}" \
121-
--build-arg "TORCHAUDIO_SPEC=${TORCHAUDIO_SPEC}" \
122-
--build-arg "TORCHVISION_SPEC=${TORCHVISION_SPEC}" \
123-
--build-arg "TORCH_INDEX_URL=${TORCH_INDEX_URL}" \
124107
--build-arg "BUCK2_VERSION=${BUCK2_VERSION}" \
125108
--build-arg "LINTRUNNER=${LINTRUNNER:-}" \
126109
--build-arg "BUILD_DOCS=${BUILD_DOCS}" \
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
release/2.11
1+
release/2.11

.ci/docker/common/install_pytorch.sh

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,6 @@ install_domains() {
1717
}
1818

1919
install_pytorch_and_domains() {
20-
if [ "${TORCH_CHANNEL}" != "nightly" ]; then
21-
# Test/release: install the published wheels directly. The specs and URL
22-
# are passed in as docker build args (computed from torch_pin.py by
23-
# .ci/docker/build.sh). RC wheels at /whl/test/ get re-uploaded under the
24-
# same version, so use --no-cache-dir there to avoid stale cache hits.
25-
local cache_flag=""
26-
if [ "${TORCH_CHANNEL}" = "test" ]; then
27-
cache_flag="--no-cache-dir"
28-
fi
29-
pip_install --force-reinstall ${cache_flag} \
30-
"${TORCH_SPEC}" "${TORCHVISION_SPEC}" "${TORCHAUDIO_SPEC}" \
31-
--index-url "${TORCH_INDEX_URL}/cpu"
32-
return
33-
fi
34-
35-
# Nightly: build pytorch from source against the pinned SHA in pytorch.txt
36-
# so we catch upstream regressions, then install audio/vision from the
37-
# commits that pytorch itself pins.
3820
git clone https://github.com/pytorch/pytorch.git
3921

4022
# Fetch the target commit
@@ -45,19 +27,14 @@ install_pytorch_and_domains() {
4527
chown -R ci-user .
4628

4729
export _GLIBCXX_USE_CXX11_ABI=1
48-
# PyTorch's FindARM.cmake hard-fails when the SVE+BF16 compile probe
49-
# doesn't pass — gcc-11 in this image is too old to accept the combined
50-
# NEON/SVE/bfloat16 intrinsics the probe exercises. Executorch's aarch64
51-
# runtime targets (phones, embedded) don't use SVE, so bypass the check.
52-
export BUILD_IGNORE_SVE_UNAVAILABLE=1
5330
# Then build and install PyTorch
5431
conda_run python setup.py bdist_wheel
5532
pip_install "$(echo dist/*.whl)"
5633

57-
# Defer to PyTorch's own pinned audio/vision commits.
58-
TORCHAUDIO_VERSION=$(cat .github/ci_commit_pins/audio.txt)
34+
# Grab the pinned audio and vision commits from PyTorch
35+
TORCHAUDIO_VERSION=release/2.11
5936
export TORCHAUDIO_VERSION
60-
TORCHVISION_VERSION=$(cat .github/ci_commit_pins/vision.txt)
37+
TORCHVISION_VERSION=release/0.26
6138
export TORCHVISION_VERSION
6239

6340
install_domains

.ci/docker/ubuntu/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ ENV SCCACHE_S3_KEY_PREFIX executorch
6464
ENV SCCACHE_REGION us-east-1
6565

6666
ARG TORCH_VERSION
67-
ARG TORCH_CHANNEL
68-
ARG TORCH_SPEC
69-
ARG TORCHAUDIO_SPEC
70-
ARG TORCHVISION_SPEC
71-
ARG TORCH_INDEX_URL
7267
ARG SKIP_PYTORCH
7368
COPY ./common/install_pytorch.sh install_pytorch.sh
7469
COPY ./common/utils.sh utils.sh

.ci/scripts/test_backend.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export PYTHON_EXECUTABLE=python
3535

3636
# CMake options to use, in addition to the defaults.
3737
EXTRA_BUILD_ARGS=""
38+
PYTEST_RETRY_ARGS=()
3839

3940
if [[ "$FLOW" == *qnn* ]]; then
4041
# Setup QNN sdk and deps - note that this is a bit hacky due to the nature of the
@@ -57,6 +58,9 @@ if [[ "$FLOW" == *vulkan* ]]; then
5758
fi
5859

5960
if [[ "$FLOW" == *arm* ]]; then
61+
if [[ "$SUITE" == "operators" ]]; then
62+
PYTEST_RETRY_ARGS=(--reruns 2 --reruns-delay 1)
63+
fi
6064

6165
# Setup ARM deps.
6266
if [[ "$FLOW" == *vgf* ]]; then
@@ -95,6 +99,11 @@ GOLDEN_DIR="${ARTIFACT_DIR}/golden-artifacts"
9599
export GOLDEN_ARTIFACTS_DIR="${GOLDEN_DIR}"
96100

97101
EXIT_CODE=0
98-
${CONDA_RUN_CMD} pytest -c /dev/null -n auto backends/test/suite/$SUITE/ -m flow_$FLOW --json-report --json-report-file="$REPORT_FILE" || EXIT_CODE=$?
102+
PYTEST_ARGS=(-c /dev/null -n auto)
103+
if [[ ${#PYTEST_RETRY_ARGS[@]} -gt 0 ]]; then
104+
PYTEST_ARGS+=("${PYTEST_RETRY_ARGS[@]}")
105+
fi
106+
PYTEST_ARGS+=("backends/test/suite/$SUITE/" -m "flow_$FLOW" --json-report --json-report-file="$REPORT_FILE")
107+
${CONDA_RUN_CMD} pytest "${PYTEST_ARGS[@]}" || EXIT_CODE=$?
99108
# Generate markdown summary.
100109
${CONDA_RUN_CMD} python -m executorch.backends.test.suite.generate_markdown_summary_json "$REPORT_FILE" > ${GITHUB_STEP_SUMMARY:-"step_summary.md"} --exit-code $EXIT_CODE

.ci/scripts/test_coreml_bc.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ source "${REPO_ROOT}/.ci/scripts/utils.sh"
2323
# Create a conda environment with Python 3.10 for compatibility with old ET versions
2424
# ET 1.0.0 only supports Python >=3.10,<3.13
2525
CONDA_ENV_NAME="coreml_bc_test_env"
26-
conda create -y -n "${CONDA_ENV_NAME}" python=3.10
26+
conda create -y -n "${CONDA_ENV_NAME}" python=3.10 pip packaging
2727

2828
# Use conda run to execute commands in the new environment
2929
CONDA_RUN="conda run --no-capture-output -n ${CONDA_ENV_NAME}"
@@ -69,7 +69,7 @@ git submodule sync --recursive
6969
git submodule update --init --recursive
7070

7171
# Install executorch
72-
${CONDA_RUN} pip install --upgrade pip
72+
${CONDA_RUN} python -m pip install --upgrade pip
7373
${CONDA_RUN} python install_executorch.py
7474

7575
# Step 3: Export model
@@ -129,7 +129,7 @@ git submodule update --init --recursive
129129

130130
# Step 5: Install current version
131131
echo "=== Step 5: Installing current ET version ==="
132-
${CONDA_RUN} pip install --upgrade pip
132+
${CONDA_RUN} python -m pip install --upgrade pip
133133
${CONDA_RUN} python install_executorch.py
134134

135135
# Step 6: Run the old pte file

.ci/scripts/test_huggingface_optimum_model.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import gc
33
import logging
44
import math
5+
import shutil
56
import subprocess
67
import tempfile
8+
import time
79
from pathlib import Path
810
from typing import List
911

@@ -25,6 +27,17 @@
2527
)
2628

2729

30+
EXPORT_RETRIES = 3
31+
32+
33+
def _clear_export_dir(model_dir):
34+
for path in Path(model_dir).iterdir():
35+
if path.is_dir() and not path.is_symlink():
36+
shutil.rmtree(path)
37+
else:
38+
path.unlink()
39+
40+
2841
def cli_export(command, model_dir):
2942
p = Path(model_dir)
3043
if p.exists():
@@ -34,11 +47,19 @@ def cli_export(command, model_dir):
3447
raise Exception(
3548
f"Existing directory {model_dir} is non-empty. Please remove it first."
3649
)
37-
try:
38-
subprocess.run(command, check=True)
39-
print("Export completed successfully.")
40-
except subprocess.CalledProcessError as e:
41-
print(f"Export failed with error: {e}")
50+
51+
for attempt in range(1, EXPORT_RETRIES + 1):
52+
try:
53+
subprocess.run(command, check=True)
54+
print("Export completed successfully.")
55+
return
56+
except subprocess.CalledProcessError as e:
57+
print(f"Export attempt {attempt}/{EXPORT_RETRIES} failed with error: {e}")
58+
if attempt == EXPORT_RETRIES:
59+
raise
60+
if p.exists():
61+
_clear_export_dir(model_dir)
62+
time.sleep(attempt * 10)
4263

4364

4465
def check_causal_lm_output_quality(

.ci/scripts/test_lora.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ cleanup_files() {
3333
rm result*.txt
3434
}
3535

36+
matches_base_response_prefix() {
37+
local output_file="$1"
38+
python - "$output_file" <<'PY'
39+
import pathlib
40+
import re
41+
import sys
42+
43+
text = pathlib.Path(sys.argv[1]).read_text()
44+
pattern = re.compile(
45+
r"^<\|im_start\|>user Calculate 15% of 80\?<\|im_end\|><\|im_start\|>assistant:\n"
46+
r"(?:<think>\n)+"
47+
r"Okay, so I need to calculate 15% of 80\.",
48+
re.MULTILINE,
49+
)
50+
sys.exit(0 if pattern.match(text) else 1)
51+
PY
52+
}
53+
3654
# Hosting lora adapter in personal repo for now.
3755
python -m pip install -q huggingface_hub
3856
HF_ADAPTER_REPO="lucylq/qwen3_06B_lora_math"
@@ -142,6 +160,13 @@ To calculate 15% of 80, we can multiply 80 by 15/100.
142160
So, 15% of 80 is equal to (80 * 15) / 100 = 1200 / 100 = 12.
143161
#### 12
144162
The answer is: 12<|im_end|>"
163+
EXPECTED_QUANT_LORA_ALTERNATE_PREFIX="
164+
<|im_start|>user Calculate 15% of 80?<|im_end|><|im_start|>assistant
165+
To calculate 15% of 80, we can multiply 80 by 15/100.
166+
80 * 15/100 = 12.
167+
So, 15% of 80 is 12.
168+
#### 12
169+
The answer is: 12<|im_end|>"
145170

146171
# Export Quantized PTE, PTD file, no LoRA.
147172
# override base.lora_config=null to avoid creating a lora model
@@ -186,7 +211,7 @@ cmake-out/examples/models/llama/llama_main --model_path=qwen_q.pte --data_paths=
186211
NOW=$(date +"%H:%M:%S")
187212
echo "Finished at ${NOW}"
188213
RESULT=$(cat result.txt)
189-
if [[ "${RESULT}" == "${EXPECTED_QUANT_PREFIX}"* ]]; then
214+
if matches_base_response_prefix result.txt; then
190215
echo "Expected result prefix: ${EXPECTED_QUANT_PREFIX}"
191216
echo "Actual result: ${RESULT}"
192217
echo "Test 3: Success"
@@ -207,12 +232,13 @@ NOW=$(date +"%H:%M:%S")
207232
echo "Finished at ${NOW}"
208233

209234
RESULT=$(cat result.txt)
210-
if [[ "${RESULT}" == "${EXPECTED_QUANT_LORA_PREFIX}"* ]]; then
235+
if [[ "${RESULT}" == "${EXPECTED_QUANT_LORA_PREFIX}"* ]] || [[ "${RESULT}" == "${EXPECTED_QUANT_LORA_ALTERNATE_PREFIX}"* ]]; then
211236
echo "Expected result prefix: ${EXPECTED_QUANT_LORA_PREFIX}"
212237
echo "Actual result: ${RESULT}"
213238
echo "Test 4: Success"
214239
else
215240
echo "Expected result prefix: ${EXPECTED_QUANT_LORA_PREFIX}"
241+
echo "Alternate expected result prefix: ${EXPECTED_QUANT_LORA_ALTERNATE_PREFIX}"
216242
echo "Actual result: ${RESULT}"
217243
echo "Test 4: Failure; results not the same"
218244
cleanup_files

.ci/scripts/test_lora_multimethod.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ cleanup_files() {
3333
rm -f result*.txt
3434
}
3535

36+
matches_base_response_prefix() {
37+
local output_file="$1"
38+
python - "$output_file" <<'PY'
39+
import pathlib
40+
import re
41+
import sys
42+
43+
text = pathlib.Path(sys.argv[1]).read_text()
44+
pattern = re.compile(
45+
r"^<\|im_start\|>user Calculate 15% of 80\?<\|im_end\|><\|im_start\|>assistant:\n"
46+
r"(?:<think>\n)+"
47+
r"Okay, so I need to calculate 15% of 80\.",
48+
re.MULTILINE,
49+
)
50+
sys.exit(0 if pattern.match(text) else 1)
51+
PY
52+
}
53+
3654
# Download LoRA adapter.
3755
python -m pip install -q huggingface_hub
3856
HF_ADAPTER_REPO="lucylq/qwen3_06B_lora_math"
@@ -107,7 +125,7 @@ NOW=$(date +"%H:%M:%S")
107125
echo "Finished at ${NOW}"
108126

109127
RESULT=$(cat result_base.txt)
110-
if [[ "${RESULT}" == "${EXPECTED_BASE_PREFIX}"* ]]; then
128+
if matches_base_response_prefix result_base.txt; then
111129
echo "Test 2 (base_forward): Success"
112130
else
113131
echo "Test 2 (base_forward): Failure"

.ci/scripts/test_model_e2e.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,21 @@ fi
258258
if [ "$AUDIO_URL" != "" ]; then
259259
curl -L $AUDIO_URL -o ${MODEL_DIR}/$AUDIO_FILE
260260
elif [[ "$MODEL_NAME" == *whisper* ]] || [ "$MODEL_NAME" = "voxtral_realtime" ]; then
261-
conda install -y -c conda-forge "ffmpeg<8"
261+
if ! command -v ffmpeg >/dev/null; then
262+
if [ "$(uname -s)" = "Linux" ] && command -v apt-get >/dev/null; then
263+
if [ "$(id -u)" -eq 0 ]; then
264+
apt-get update
265+
apt-get install -y --no-install-recommends ffmpeg
266+
else
267+
sudo apt-get update
268+
sudo apt-get install -y --no-install-recommends ffmpeg
269+
fi
270+
else
271+
conda install -y -c conda-forge ffmpeg
272+
fi
273+
fi
262274
pip install datasets soundfile
263-
# We pushd'd into EXECUTORCH_ROOT above, so torch_pin is importable here.
264-
TORCHCODEC_PKG=$(python -c "from torch_pin import torchcodec_spec; print(torchcodec_spec())")
265-
TORCHCODEC_INDEX=$(python -c "from torch_pin import torch_index_url_base; print(torch_index_url_base())")
266-
pip install "$TORCHCODEC_PKG" --extra-index-url "${TORCHCODEC_INDEX}/cpu"
275+
pip install torchcodec==0.11.0 --extra-index-url https://download.pytorch.org/whl/test/cpu
267276
python -c "from datasets import load_dataset;import soundfile as sf;sample = load_dataset('distil-whisper/librispeech_long', 'clean', split='validation')[0]['audio'];sf.write('${MODEL_DIR}/$AUDIO_FILE', sample['array'][:sample['sampling_rate']*30], sample['sampling_rate'])"
268277
fi
269278

0 commit comments

Comments
 (0)