Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/187944
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 17 Unclassified FailuresAs of commit a350c45 with merge base 47edb83 ( NEW FAILURE - The following job has failed:
UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| @@ -0,0 +1,86 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
This script should be shared across linux/windows and Mac, shouldn't it?
There was a problem hiding this comment.
Agree the duplication is real -- retry, pip_install, and numpy_pin are copy-pasted across all three (manywheel, windows, and this new macwheel). I would like to do the dedup as a focused follow-up rather than fold it in here: sharing them means editing all three directories plus establishing a stable import path (the three pipelines run from different CWDs/interpreters), and re-validating the Linux and Windows binary builds -- more scope than this macOS port should carry, and easy to get wrong silently.
Worth noting only the boilerplate unifies cleanly: the numpy pin tables genuinely differ per platform (mac cp313->2.1.0, win cp313->2.1.2, linux cp31->2.1.0 + --pre), so that data stays per-platform regardless.
Planned end-state is consolidating to .ci/wheel/{mac,linux,windows}/ with a shared _common.py (which Windows already partially has). Tracked as a follow-up; will pick it up right after this lands.
|
@claude review this |
|
Claude finished @malfet's task in 4m 36s —— View job PR ReviewNice work — the macOS pipeline reads cleanly and the parallel to 1.
|
numpy retry |
pip_install |
numpy_pin |
clean step | platform tail | |
|---|---|---|---|---|---|
.ci/manywheel/build_install_deps.py |
✓ | ✓ | ✓ | setup.py clean |
rocm build_amd.py |
.ci/pytorch/windows/build_install_deps.py |
✓ | ✓ | ✓ | spin clean |
libuv extract |
.ci/macwheel/build_install_deps.py (new) |
✓ | ✓ | ✓ | spin clean |
libomp via brew |
retry, pip_install, and numpy_pin are copy-pasted verbatim across all three. The natural move is a shared helper module (e.g. .ci/ci_commons.py or similar) exposing those three, with each platform script keeping only its main() + platform tail. Windows already imports a _common for download/write_env_exports, so there's precedent.
Two things that argue against fully unifying main() (worth being explicit about in the PR so the scope is clear):
- The numpy pin tables genuinely differ — mac
cp313→2.1.0, wincp313→2.1.2, linuxcp31→2.1.0(note linux'scp31prefix matches 3.10–3.13, the others pin 3.13 specifically). So the table data stays per-platform even if the lookup function is shared. - linux installs numpy with
--pre; mac/win don't.
My suggestion: share retry/pip_install/numpy_pin (pure boilerplate) now, leave the per-platform main() and pin tables in place. That captures the bulk of the duplication without forcing a leaky abstraction. If you'd rather keep this PR focused on the macOS port, a tracking issue for the three-way dedup is a reasonable alternative — but the duplication is real and worth not growing silently.
Additional observations
build_env_setup.py:11-15 docstring mismatch. The Environment variables read: section lists OMP_PREFIX, but the code never reads OMP_PREFIX — it probes the path /opt/llvm-openmp and writes OMP_PREFIX to the env file. The docstring describes the behavior correctly in prose but files it under the wrong heading. Minor, but it'll confuse the next reader. Consider "Outputs:" or just dropping the heading.
build_install_deps.py:73 vs manywheel ordering. Here spin clean runs after the numpy/requirements installs; in manywheel setup.py clean runs between requirements-build.txt and requirements.txt. Almost certainly harmless (clean just wipes build/ artifacts), but since you're explicitly mirroring manywheel, a one-line note on why the order differs would save a future reader the diff.
build_wheel.py:32 does pip install build even though build_install_deps.py already installs requirements-build.txt. This matches the manywheel script verbatim, so I'd leave it — just flagging it's a (harmless) redundant install, consistent across both platforms.
Nit — repair_wheel.py:40 / build_wheel.py: the raw wheel dir is a mktemp -d that's never cleaned up (unlike ENV_FILE, which has a trap). On the CI runner it's ephemeral so it doesn't matter; not worth changing.
None of these are blocking. The two comments from @malfet are the substantive ones — #1 is a quick comment fix, #2 is a judgment call on scope (dedup now vs. follow-up issue).
- Read the four stage modules +
build.sh - Read
build_all_macos_wheels.shand workflow template - Address malfet's two review comments
- Compare with Linux/Windows pipelines for the shared-script question
- Post review
· branchcd-macos-python-scripts
Port the macOS arm64 CD wheel build from the monolithic build_wheel.sh to the same staged Python pipeline used for Linux (pytorch#182409) and Windows (pytorch#184407): build_env_setup.py emits the macOS build flags to an env file, build_install_deps.py installs the pinned build/runtime deps (and libomp when not staged), build_wheel.py runs `python -m build`, and repair_wheel.py delocates the wheel in place. A per-Python build.sh owns the stage contract; build_all_macos_wheels.sh selects the interpreter and loops. Delocation moves into the per-Python build (repair_wheel.py) instead of a separate workflow step, so the template drops the "Delocate all wheels" step and the generated workflow is regenerated to match. build_wheel.sh and delocate_wheels.sh are removed: the former's wheel path is superseded by the Python modules and its BUILD_PYTHONLESS/libtorch branch was dead code (macOS ships no libtorch package; libtorch is built on Linux via .ci/libtorch/), and the latter's logic now lives in repair_wheel.py. Review in pipeline order: build.sh (the contract) first, then the four stage modules, then build_all_macos_wheels.sh and the workflow template. Test Plan: Static checks only so far (no macOS runner in this environment): ``` python3 -m py_compile .ci/wheel/*.py bash -n .ci/wheel/build.sh .ci/wheel/build_all_macos_wheels.sh python3 .github/scripts/generate_ci_workflows.py # regen, clean diff lintrunner .ci/wheel/*.py .ci/wheel/*.sh \ .github/templates/macos_binary_build_workflow.yml.j2 \ .github/workflows/generated-macos-arm64-binary-wheel-nightly.yml ``` End-to-end validation on a macOS arm64 runner (the nightly wheel matrix) is pending and will be exercised via ciflow/binaries. Authored with assistance from Claude Code.
Rename the macOS-only wheel-build directory from the over-generic .ci/wheel
to .ci/macwheel, parallel to the Linux .ci/manywheel. Update the workflow
template and regenerate the generated workflow to match.
Also switch build_install_deps.py from `setup.py clean` to `spin clean`
(matching the Windows pipeline). Both call the same tools/clean.py today, but
`setup.py clean` stops working once the scikit-build-core migration removes
setup.py, whereas `spin clean` does not. The dependency install is reordered
so spin (from requirements.txt) is present before the clean runs.
Test Plan:
```
python3 -m py_compile .ci/macwheel/*.py
bash -n .ci/macwheel/build.sh .ci/macwheel/build_all_macos_wheels.sh
python3 .github/scripts/generate_ci_workflows.py # only the macOS workflow changes
lintrunner .ci/macwheel/* \
.github/templates/macos_binary_build_workflow.yml.j2 \
.github/workflows/generated-macos-arm64-binary-wheel-nightly.yml
```
Authored with assistance from Claude Code.
Address review feedback on the macOS CD pipeline: - build.sh: the scope comment claimed macOS ships no libtorch. It does -- the libtorch artifact is extracted from the finished wheel by a later workflow job (.ci/libtorch/extract_libtorch_from_wheel.py, which has macOS handling). What is true is that there is no separate BUILD_PYTHONLESS libtorch build on macOS; reword to say that. - build_env_setup.py: OMP_PREFIX was listed under "Environment variables read" but the script writes it (to --env-out), not reads it. Move it under a "written" heading. Authored with assistance from Claude Code.
367a84a to
a6dd57b
Compare
The macOS wheel build's numpy_pin() used a prefix table with a 2.0.2 default, so an unsupported interpreter (e.g. a future 3.15, which the binary matrix does not yet build on non-Linux OSes) would silently build against numpy 2.0.2 instead of erroring. The legacy .ci/wheel/build_wheel.sh used an explicit per-version case with `exit 1` on the default arm; restore that fail-closed behavior. Replace the prefix table + default with an explicit per-version map covering the versions actually built (3.10-3.14; freethreaded 3.14t shares 3.14's pin since sys.version_info does not carry the `t`), and sys.exit with an actionable message for anything unlisted -- so enabling a new Python forces a deliberate pin choice here. Test Plan: - Exercised numpy_pin() with simulated sys.version_info for 3.10-3.14 (returns 2.0.2 / 2.1.0 / 2.3.4 matching the legacy table) and 3.15 (exits with "Unsupported Python version 3.15: add a numpy pin ..."). - `lintrunner .ci/macwheel/build_install_deps.py` clean. Authored with assistance from Claude Code.
|
@pytorchbot merge -i |
…#187944) ## Summary Refactors the macOS arm64 CD wheel build from the monolithic `build_wheel.sh` into the same staged Python pipeline already adopted for Linux (pytorch#182409) and Windows (pytorch#184407). This is the third and final platform, bringing macOS in line with the cross-platform structure. Following the Linux template, the build is split into four single-responsibility modules under `.ci/macwheel/`, driven by a per-Python `build.sh` orchestrator that owns the stage contract: - `build_env_setup.py` — emits the macOS build flags (`USE_DISTRIBUTED`, deployment target, Metal/CoreML, libomp prefix) to an `--env-out` file the orchestrator sources - `build_install_deps.py` — pinned build/runtime deps + numpy pin; libomp via Homebrew when not staged - `build_wheel.py` — sets the arm64 host platform / `ARCHFLAGS` and runs `python -m build --wheel --no-isolation` - `repair_wheel.py` — delocates the wheel in place (the macOS analog of Linux's `auditwheel`/patchelf; Windows needs no repair) `build_all_macos_wheels.sh` selects each interpreter and loops, reusing the ABI-free `libtorch_cpu` across Python versions via `SKIP_SETUP_CLEAN` (same incremental-build trick as Linux). ### Notable points - **macOS is arm64-only.** Main builds no Intel-Mac wheels (the matrix emits only `macos-arm64`), so the pipeline is arm64-only by design — and the dead `x86_64`/`BUILD_PYTHONLESS` libtorch branches in the old `build_wheel.sh` are removed. macOS still ships a libtorch artifact, but it is *extracted from the finished wheel* by a later workflow job (`.ci/libtorch/extract_libtorch_from_wheel.py`), not produced by a separate `BUILD_PYTHONLESS` build. - **Delocation moves inline** into the per-Python build (`repair_wheel.py`), so the workflow drops its separate "Delocate all wheels" step. - **Directory renamed** `.ci/wheel/` → `.ci/macwheel/`, parallel to Linux's `.ci/manywheel/` (the old name was too generic for a macOS-only build). - `build_install_deps.py` uses **`spin clean`** rather than `setup.py clean`, matching Windows and surviving the eventual `setup.py` removal. ### Review order 1. `build.sh` (the stage contract), then the four stage modules 2. `build_all_macos_wheels.sh` and the workflow template 3. The second commit is a pure rename + `spin clean` switch ## Test Plan Static + structural checks locally: ``` python3 -m py_compile .ci/macwheel/*.py bash -n .ci/macwheel/build.sh .ci/macwheel/build_all_macos_wheels.sh python3 .github/scripts/generate_ci_workflows.py # only the macOS workflow changes lintrunner .ci/macwheel/* .github/templates/macos_binary_build_workflow.yml.j2 ``` A from-source build on a dev Mac exercised the pipeline through environment setup, dependency install, CMake configure, and compilation, confirming the orchestration contract (venv handoff, `--env-out` sourcing, `python -m build` invocation). End-to-end wheel production + delocation is validated by this PR's `ciflow/binaries` run on the `macos-arm64` runner. Opening as a draft for a first round of CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#187944 Approved by: https://github.com/atalman
…#187944) ## Summary Refactors the macOS arm64 CD wheel build from the monolithic `build_wheel.sh` into the same staged Python pipeline already adopted for Linux (pytorch#182409) and Windows (pytorch#184407). This is the third and final platform, bringing macOS in line with the cross-platform structure. Following the Linux template, the build is split into four single-responsibility modules under `.ci/macwheel/`, driven by a per-Python `build.sh` orchestrator that owns the stage contract: - `build_env_setup.py` — emits the macOS build flags (`USE_DISTRIBUTED`, deployment target, Metal/CoreML, libomp prefix) to an `--env-out` file the orchestrator sources - `build_install_deps.py` — pinned build/runtime deps + numpy pin; libomp via Homebrew when not staged - `build_wheel.py` — sets the arm64 host platform / `ARCHFLAGS` and runs `python -m build --wheel --no-isolation` - `repair_wheel.py` — delocates the wheel in place (the macOS analog of Linux's `auditwheel`/patchelf; Windows needs no repair) `build_all_macos_wheels.sh` selects each interpreter and loops, reusing the ABI-free `libtorch_cpu` across Python versions via `SKIP_SETUP_CLEAN` (same incremental-build trick as Linux). ### Notable points - **macOS is arm64-only.** Main builds no Intel-Mac wheels (the matrix emits only `macos-arm64`), so the pipeline is arm64-only by design — and the dead `x86_64`/`BUILD_PYTHONLESS` libtorch branches in the old `build_wheel.sh` are removed. macOS still ships a libtorch artifact, but it is *extracted from the finished wheel* by a later workflow job (`.ci/libtorch/extract_libtorch_from_wheel.py`), not produced by a separate `BUILD_PYTHONLESS` build. - **Delocation moves inline** into the per-Python build (`repair_wheel.py`), so the workflow drops its separate "Delocate all wheels" step. - **Directory renamed** `.ci/wheel/` → `.ci/macwheel/`, parallel to Linux's `.ci/manywheel/` (the old name was too generic for a macOS-only build). - `build_install_deps.py` uses **`spin clean`** rather than `setup.py clean`, matching Windows and surviving the eventual `setup.py` removal. ### Review order 1. `build.sh` (the stage contract), then the four stage modules 2. `build_all_macos_wheels.sh` and the workflow template 3. The second commit is a pure rename + `spin clean` switch ## Test Plan Static + structural checks locally: ``` python3 -m py_compile .ci/macwheel/*.py bash -n .ci/macwheel/build.sh .ci/macwheel/build_all_macos_wheels.sh python3 .github/scripts/generate_ci_workflows.py # only the macOS workflow changes lintrunner .ci/macwheel/* .github/templates/macos_binary_build_workflow.yml.j2 ``` A from-source build on a dev Mac exercised the pipeline through environment setup, dependency install, CMake configure, and compilation, confirming the orchestration contract (venv handoff, `--env-out` sourcing, `python -m build` invocation). End-to-end wheel production + delocation is validated by this PR's `ciflow/binaries` run on the `macos-arm64` runner. Opening as a draft for a first round of CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#187944 Approved by: https://github.com/atalman
…#187944) ## Summary Refactors the macOS arm64 CD wheel build from the monolithic `build_wheel.sh` into the same staged Python pipeline already adopted for Linux (pytorch#182409) and Windows (pytorch#184407). This is the third and final platform, bringing macOS in line with the cross-platform structure. Following the Linux template, the build is split into four single-responsibility modules under `.ci/macwheel/`, driven by a per-Python `build.sh` orchestrator that owns the stage contract: - `build_env_setup.py` — emits the macOS build flags (`USE_DISTRIBUTED`, deployment target, Metal/CoreML, libomp prefix) to an `--env-out` file the orchestrator sources - `build_install_deps.py` — pinned build/runtime deps + numpy pin; libomp via Homebrew when not staged - `build_wheel.py` — sets the arm64 host platform / `ARCHFLAGS` and runs `python -m build --wheel --no-isolation` - `repair_wheel.py` — delocates the wheel in place (the macOS analog of Linux's `auditwheel`/patchelf; Windows needs no repair) `build_all_macos_wheels.sh` selects each interpreter and loops, reusing the ABI-free `libtorch_cpu` across Python versions via `SKIP_SETUP_CLEAN` (same incremental-build trick as Linux). ### Notable points - **macOS is arm64-only.** Main builds no Intel-Mac wheels (the matrix emits only `macos-arm64`), so the pipeline is arm64-only by design — and the dead `x86_64`/`BUILD_PYTHONLESS` libtorch branches in the old `build_wheel.sh` are removed. macOS still ships a libtorch artifact, but it is *extracted from the finished wheel* by a later workflow job (`.ci/libtorch/extract_libtorch_from_wheel.py`), not produced by a separate `BUILD_PYTHONLESS` build. - **Delocation moves inline** into the per-Python build (`repair_wheel.py`), so the workflow drops its separate "Delocate all wheels" step. - **Directory renamed** `.ci/wheel/` → `.ci/macwheel/`, parallel to Linux's `.ci/manywheel/` (the old name was too generic for a macOS-only build). - `build_install_deps.py` uses **`spin clean`** rather than `setup.py clean`, matching Windows and surviving the eventual `setup.py` removal. ### Review order 1. `build.sh` (the stage contract), then the four stage modules 2. `build_all_macos_wheels.sh` and the workflow template 3. The second commit is a pure rename + `spin clean` switch ## Test Plan Static + structural checks locally: ``` python3 -m py_compile .ci/macwheel/*.py bash -n .ci/macwheel/build.sh .ci/macwheel/build_all_macos_wheels.sh python3 .github/scripts/generate_ci_workflows.py # only the macOS workflow changes lintrunner .ci/macwheel/* .github/templates/macos_binary_build_workflow.yml.j2 ``` A from-source build on a dev Mac exercised the pipeline through environment setup, dependency install, CMake configure, and compilation, confirming the orchestration contract (venv handoff, `--env-out` sourcing, `python -m build` invocation). End-to-end wheel production + delocation is validated by this PR's `ciflow/binaries` run on the `macos-arm64` runner. Opening as a draft for a first round of CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#187944 Approved by: https://github.com/atalman
Summary
Refactors the macOS arm64 CD wheel build from the monolithic
build_wheel.shinto the same staged Python pipeline already adopted for Linux (#182409) and Windows (#184407). This is the third and final platform, bringing macOS in line with the cross-platform structure.Following the Linux template, the build is split into four single-responsibility modules under
.ci/macwheel/, driven by a per-Pythonbuild.shorchestrator that owns the stage contract:build_env_setup.py— emits the macOS build flags (USE_DISTRIBUTED, deployment target, Metal/CoreML, libomp prefix) to an--env-outfile the orchestrator sourcesbuild_install_deps.py— pinned build/runtime deps + numpy pin; libomp via Homebrew when not stagedbuild_wheel.py— sets the arm64 host platform /ARCHFLAGSand runspython -m build --wheel --no-isolationrepair_wheel.py— delocates the wheel in place (the macOS analog of Linux'sauditwheel/patchelf; Windows needs no repair)build_all_macos_wheels.shselects each interpreter and loops, reusing the ABI-freelibtorch_cpuacross Python versions viaSKIP_SETUP_CLEAN(same incremental-build trick as Linux).Notable points
macos-arm64), so the pipeline is arm64-only by design — and the deadx86_64/BUILD_PYTHONLESSlibtorch branches in the oldbuild_wheel.share removed. macOS still ships a libtorch artifact, but it is extracted from the finished wheel by a later workflow job (.ci/libtorch/extract_libtorch_from_wheel.py), not produced by a separateBUILD_PYTHONLESSbuild.repair_wheel.py), so the workflow drops its separate "Delocate all wheels" step..ci/wheel/→.ci/macwheel/, parallel to Linux's.ci/manywheel/(the old name was too generic for a macOS-only build).build_install_deps.pyusesspin cleanrather thansetup.py clean, matching Windows and surviving the eventualsetup.pyremoval.Review order
build.sh(the stage contract), then the four stage modulesbuild_all_macos_wheels.shand the workflow templatespin cleanswitchTest Plan
Static + structural checks locally:
A from-source build on a dev Mac exercised the pipeline through environment setup, dependency install, CMake configure, and compilation, confirming the orchestration contract (venv handoff,
--env-outsourcing,python -m buildinvocation). End-to-end wheel production + delocation is validated by this PR'sciflow/binariesrun on themacos-arm64runner.Opening as a draft for a first round of CI.
🤖 Generated with Claude Code