Skip to content

Commit 3ffaf27

Browse files
Revert torch-family pin centralization (#19334)
Several macos jobs have been timing out really bad since this change blocking viablestrict. We could potentially just increase the runtime but until I actually get a viable strict bump I dont want to be sat waiting 1-2hrs for these jobs to run so reverting to get back to the 30-40m runtimes.
1 parent c7e8628 commit 3ffaf27

14 files changed

Lines changed: 130 additions & 348 deletions

File tree

.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_model_e2e.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,7 @@ elif [[ "$MODEL_NAME" == *whisper* ]] || [ "$MODEL_NAME" = "voxtral_realtime" ];
272272
fi
273273
fi
274274
pip install datasets soundfile
275-
# We pushd'd into EXECUTORCH_ROOT above, so torch_pin is importable here.
276-
TORCHCODEC_PKG=$(python -c "from torch_pin import torchcodec_spec; print(torchcodec_spec())")
277-
TORCHCODEC_INDEX=$(python -c "from torch_pin import torch_index_url_base; print(torch_index_url_base())")
278-
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
279276
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'])"
280277
fi
281278

.ci/scripts/test_wheel_package_qnn.sh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,25 @@ run_core_tests () {
150150
echo "=== [$LABEL] Installing wheel & deps ==="
151151
"$PIPBIN" install --upgrade pip
152152
"$PIPBIN" install "$WHEEL_FILE"
153-
# runpy.run_path uses a relative path, so the caller must run this script
154-
# from the executorch repo root (where torch_pin.py lives).
155-
TORCH_SPEC=$(
153+
TORCH_VERSION=$(
156154
"$PYBIN" - <<'PY'
157155
import runpy
158156
module_vars = runpy.run_path("torch_pin.py")
159-
print(module_vars["torch_spec"]())
157+
print(module_vars["TORCH_VERSION"])
160158
PY
161159
)
162-
TORCH_INDEX=$(
163-
"$PYBIN" - <<'PY'
164-
import runpy
165-
module_vars = runpy.run_path("torch_pin.py")
166-
print(module_vars["torch_index_url_base"]())
167-
PY
168-
)
169-
echo "=== [$LABEL] Install $TORCH_SPEC from ${TORCH_INDEX}/cpu ==="
170160

171-
# Install torch based on the pinned PyTorch version from the channel index.
172-
"$PIPBIN" install "$TORCH_SPEC" --index-url "${TORCH_INDEX}/cpu"
161+
# NIGHTLY_VERSION=$(
162+
# "$PYBIN" - <<'PY'
163+
# import runpy
164+
# module_vars = runpy.run_path("torch_pin.py")
165+
# print(module_vars["NIGHTLY_VERSION"])
166+
# PY
167+
# )
168+
echo "=== [$LABEL] Install torch==${TORCH_VERSION} ==="
169+
170+
# Install torch based on the pinned PyTorch version, preferring the PyTorch test index
171+
"$PIPBIN" install torch=="${TORCH_VERSION}" --extra-index-url "https://download.pytorch.org/whl/test"
173172
"$PIPBIN" install wheel
174173

175174
# Install torchao based on the pinned commit from third-party/ao submodule

.ci/scripts/tests/test_torch_pin.py

Lines changed: 0 additions & 54 deletions
This file was deleted.

.ci/scripts/utils.sh

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dedupe_macos_loader_path_rpaths() {
5353
pushd ..
5454
torch_lib_dir=$(python -c "import importlib.util; print(importlib.util.find_spec('torch').submodule_search_locations[0])")/lib
5555
popd
56-
56+
5757
if [[ -z "${torch_lib_dir}" || ! -d "${torch_lib_dir}" ]]; then
5858
return
5959
fi
@@ -89,30 +89,6 @@ install_domains() {
8989
}
9090

9191
install_pytorch_and_domains() {
92-
# CWD is the executorch repo root, where torch_pin.py lives.
93-
TORCH_CHANNEL=$(python -c "from torch_pin import CHANNEL; print(CHANNEL)")
94-
95-
if [ "${TORCH_CHANNEL}" != "nightly" ]; then
96-
# Test/release: install the published wheels directly from torch_pin.py's
97-
# channel index, skipping the source-build path entirely. RC wheels at
98-
# /whl/test/ get re-uploaded under the same version, so use --no-cache-dir
99-
# there to avoid stale cache hits.
100-
local torch_spec=$(python -c "from torch_pin import torch_spec; print(torch_spec())")
101-
local torchvision_spec=$(python -c "from torch_pin import torchvision_spec; print(torchvision_spec())")
102-
local torchaudio_spec=$(python -c "from torch_pin import torchaudio_spec; print(torchaudio_spec())")
103-
local torch_index_url=$(python -c "from torch_pin import torch_index_url_base; print(torch_index_url_base())")
104-
local cache_flag=""
105-
if [ "${TORCH_CHANNEL}" = "test" ]; then
106-
cache_flag="--no-cache-dir"
107-
fi
108-
pip install --force-reinstall ${cache_flag} \
109-
"${torch_spec}" "${torchvision_spec}" "${torchaudio_spec}" \
110-
--index-url "${torch_index_url}/cpu"
111-
return
112-
fi
113-
114-
# Nightly: source-build pytorch from the pinned SHA so CI catches upstream
115-
# regressions; pytorch's own audio/vision pins drive those installs.
11692
pushd .ci/docker || return
11793
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
11894
popd || return
@@ -164,10 +140,10 @@ install_pytorch_and_domains() {
164140
fi
165141

166142
dedupe_macos_loader_path_rpaths
167-
# We're on the nightly path here; defer to PyTorch's own pinned commits.
168-
TORCHAUDIO_VERSION=$(cat .github/ci_commit_pins/audio.txt)
143+
# Grab the pinned audio and vision commits from PyTorch
144+
TORCHAUDIO_VERSION=release/2.11
169145
export TORCHAUDIO_VERSION
170-
TORCHVISION_VERSION=$(cat .github/ci_commit_pins/vision.txt)
146+
TORCHVISION_VERSION=release/0.26
171147
export TORCHVISION_VERSION
172148

173149
install_domains
@@ -242,21 +218,17 @@ download_stories_model_artifacts() {
242218
}
243219

244220
do_not_use_nightly_on_ci() {
245-
# Sanity check that prevents accidentally landing a PR that pins to PyTorch
246-
# nightly without exercising the source-build path (see #6564).
247-
#
248-
# For CHANNEL=nightly, CI source-builds pytorch from the SHA in pytorch.txt,
249-
# so the installed torch shows up as e.g. 2.13.0a0+gitc8a648d — assert that.
250-
# For CHANNEL=test/release, we install published wheels by design (e.g.
251-
# 2.11.0), so the +git assertion doesn't apply.
252-
TORCH_CHANNEL=$(python -c "from torch_pin import CHANNEL; print(CHANNEL)")
253-
if [ "${TORCH_CHANNEL}" != "nightly" ]; then
254-
return 0
255-
fi
256-
221+
# An assert to make sure that we are not using PyTorch nightly on CI to prevent
222+
# regression as documented in https://github.com/pytorch/executorch/pull/6564
257223
TORCH_VERSION=$(pip list | grep -w 'torch ' | awk -F ' ' {'print $2'} | tr -d '\n')
224+
225+
# The version of PyTorch building from source looks like 2.6.0a0+gitc8a648d that
226+
# includes the commit while nightly (2.6.0.dev20241019+cpu) or release (2.6.0)
227+
# won't have that. Note that we couldn't check for the exact commit from the pin
228+
# ci_commit_pins/pytorch.txt here because the value will be different when running
229+
# this on PyTorch CI
258230
if [[ "${TORCH_VERSION}" != *"+git"* ]]; then
259-
echo "Unexpected torch version. Expected binary built from source for CHANNEL=nightly, got ${TORCH_VERSION}"
231+
echo "Unexpected torch version. Expected binary built from source, got ${TORCH_VERSION}"
260232
exit 1
261233
fi
262234
}

0 commit comments

Comments
 (0)