Skip to content

Commit 3185f02

Browse files
authored
ci: install pinned torch before requirements-ci.txt on macOS (#19342)
### Summary `setup-macos.sh` runs `install_pip_dependencies` before `install_pytorch_and_domains`. That order lets torchsr's transitive torch dep get pulled from PyPI before the pinned source-built or S3-cached torch lands; `install_pytorch_and_domains` then overwrites the wrong-source torch. The overwrite is small in the current state, but the same race forced --no-cache-dir`. That cascaded reinstalls of every torch transitive dep, pushed the macOS unittest past its 60-minute timeout, until #19334 reverted it. Reorder so `install_pip_dependencies` runs after `install_pytorch_and_domains`. With torch already at the pinned version, torchsr's dep is satisfied and pip skips re-downloading. Removes the structural footgun so any future re-land of centralized torch install does not need `--force-reinstall`. Also rewrite two adjacent comments: - Add a comment above `install_pytorch_and_domains` recording the ordering rationale. - Drop the now-misleading "We build PyTorch from source here" comment that drifted above `install_executorch`; replace with one explaining why `install_executorch --use-pt-pinned-commit` is correct (torch is already installed). Authored with Claude Code. ### Test plan CI
1 parent ada8e35 commit 3185f02

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

.ci/scripts/setup-macos.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ setup_macos_env_variables
116116
# buck2 atm
117117
install_buck
118118
brew install libomp
119-
install_pip_dependencies
120119

121120
# TODO(huydhn): Unlike our self-hosted runner, GitHub runner doesn't have access
122121
# to our infra, so compiler caching needs to be setup differently using GitHub
@@ -125,10 +124,17 @@ if [[ -z "${GITHUB_RUNNER:-}" ]]; then
125124
install_sccache
126125
fi
127126

127+
# Install pinned torch before requirements-ci.txt so torchsr's transitive
128+
# torch dep is satisfied by the existing install and pip does not pull a
129+
# separate copy from PyPI. sccache is initialized above so source-build
130+
# cache misses still hit the cache.
128131
print_cmake_info
129132
install_pytorch_and_domains
130-
# We build PyTorch from source here instead of using nightly. This allows CI to test against
131-
# the pinned commit from PyTorch
133+
134+
install_pip_dependencies
135+
136+
# install_executorch's --use-pt-pinned-commit skips re-installing torch since
137+
# install_pytorch_and_domains already installed the pinned build above.
132138
if [[ "$EDITABLE" == "true" ]]; then
133139
install_executorch --use-pt-pinned-commit --editable
134140
else

.ci/scripts/utils.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ install_pytorch_and_domains() {
127127
if [[ "${torch_wheel_not_found}" == "1" ]]; then
128128
echo "No cached wheel found, continue with building PyTorch at ${TORCH_VERSION}"
129129

130+
# Install PyTorch's own build-time deps so the source build does not
131+
# silently inherit them from whatever else happens to be in the env
132+
# (e.g. executorch's requirements-ci.txt).
133+
pip install -r requirements-build.txt
130134
git submodule update --init --recursive
131135
USE_DISTRIBUTED=1 python setup.py bdist_wheel
132136
pip install "$(echo dist/*.whl)"

0 commit comments

Comments
 (0)