From 55079cf58ecf282efad13fd2e21126d258b96007 Mon Sep 17 00:00:00 2001 From: RJ Ascani Date: Wed, 6 May 2026 12:49:55 -0700 Subject: [PATCH 1/2] ci: install pinned torch before requirements-ci.txt on macOS `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. --- .ci/scripts/setup-macos.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/setup-macos.sh b/.ci/scripts/setup-macos.sh index 4b43a730710..6bd26e0b171 100755 --- a/.ci/scripts/setup-macos.sh +++ b/.ci/scripts/setup-macos.sh @@ -116,7 +116,6 @@ setup_macos_env_variables # buck2 atm install_buck brew install libomp -install_pip_dependencies # TODO(huydhn): Unlike our self-hosted runner, GitHub runner doesn't have access # to our infra, so compiler caching needs to be setup differently using GitHub @@ -125,10 +124,17 @@ if [[ -z "${GITHUB_RUNNER:-}" ]]; then install_sccache fi +# Install pinned torch before requirements-ci.txt so torchsr's transitive +# torch dep is satisfied by the existing install and pip does not pull a +# separate copy from PyPI. sccache is initialized above so source-build +# cache misses still hit the cache. print_cmake_info install_pytorch_and_domains -# We build PyTorch from source here instead of using nightly. This allows CI to test against -# the pinned commit from PyTorch + +install_pip_dependencies + +# install_executorch's --use-pt-pinned-commit skips re-installing torch since +# install_pytorch_and_domains already installed the pinned build above. if [[ "$EDITABLE" == "true" ]]; then install_executorch --use-pt-pinned-commit --editable else From f041233ff8abbfbb77f718636eee0f442c22a3a8 Mon Sep 17 00:00:00 2001 From: RJ Ascani Date: Wed, 6 May 2026 14:45:45 -0700 Subject: [PATCH 2/2] ci: install PyTorch's own build deps before macOS source-build fallback `install_pytorch_and_domains`'s source-build fallback runs `python setup.py bdist_wheel`, which needs pyyaml, typing-extensions, ninja, and other PyTorch build-time deps. Those used to be present only because requirements-ci.txt happened to include them; the previous commit's reorder removed that incidental coverage and broke the fallback when the macOS wheel cache misses. Install PyTorch's own `requirements-build.txt` before the source build so it owns its deps and is order-independent. Authored with Claude Code. --- .ci/scripts/utils.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.ci/scripts/utils.sh b/.ci/scripts/utils.sh index 86e54b478ef..d226503384c 100644 --- a/.ci/scripts/utils.sh +++ b/.ci/scripts/utils.sh @@ -123,6 +123,10 @@ install_pytorch_and_domains() { if [[ "${torch_wheel_not_found}" == "1" ]]; then echo "No cached wheel found, continue with building PyTorch at ${TORCH_VERSION}" + # Install PyTorch's own build-time deps so the source build does not + # silently inherit them from whatever else happens to be in the env + # (e.g. executorch's requirements-ci.txt). + pip install -r requirements-build.txt git submodule update --init --recursive USE_DISTRIBUTED=1 python setup.py bdist_wheel pip install "$(echo dist/*.whl)"