trunk/262cf70ac4475beb3b15147d657139bc418236bc: [BE] Build all macOS Python wheels on a single runner (#181171)
A single runner now builds all macOS Python wheels, cutting xlarge minutes from 427 to 106.
PyTorch has merged PR #181171, which dramatically optimizes its macOS wheel build process by consolidating all arm64 Python wheels onto a single `macos-26-xlarge` runner. Previously, seven parallel jobs each ran a full from-scratch build, consuming approximately 427 runner-minutes. The new approach uses a single job that pre-fetches all desired CPython versions in parallel, then runs a loop that performs a full build only for the first Python version (3.10, ~35 min) and incremental rebuilds for subsequent versions (3.11+, ~7 min each). This is enabled by a cache-invalidation fix from PR #181147 that ensures the shared `build/` directory only recompiles the `libtorch_python` and `_C` components between iterations.
The PR also introduces several workflow improvements: Delocate is now parallelized using `xargs -P` across all available CPU cores, and the diagnostic `delocate-listdeps` step (which took ~11 min per wheel) has been removed. A new reusable workflow chains testing on `macos-26` runners with uploads on Ubuntu, allowing per-Python version gating—if test-X fails, only upload-X is blocked. Sparse checkout for test jobs takes ~2 seconds per matrix instance. The result is a 75% reduction in `macos-26-xlarge` runner-minutes, though wall-clock time increases from ~72 min to ~112 min. Adding a new CPython version now requires only a one-line edit to `FULL_PYTHON_VERSIONS`.
- Runner-minute usage on `macos-26-xlarge` dropped from ~427 to ~106, a 75% reduction.
- First full build takes ~35 min; subsequent incremental rebuilds take only ~7 min each.
- New test-upload workflow gates per-Python version failures independently, preventing one failure from blocking all uploads.
Why It Matters
This optimization cuts CI costs by 75% for macOS builds while maintaining reliability, a win for open-source infrastructure efficiency.