Skip to content

[release validation][macOS wheel] Add wheel platform tag vs dylib minos validation - #177609

Closed
yangw-dev wants to merge 17 commits into
mainfrom
verify
Closed

yangw-dev wants to merge 17 commits into
mainfrom
verify

Conversation

@yangw-dev

@yangw-dev yangw-dev commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #177140

Summary

Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:

torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

@yangw-dev
yangw-dev requested a review from a team as a code owner March 17, 2026 02:50
@pytorch-bot

pytorch-bot Bot commented Mar 17, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/177609

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 2 Unrelated Failures

As of commit b9da75b with merge base ec48f0c (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot

pytorch-bot Bot commented Mar 17, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Mar 17, 2026
@yangw-dev yangw-dev added the ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR label Mar 17, 2026
@yangw-dev yangw-dev changed the title verify macos monos [macOS wheel] Add wheel platform tag vs dylib minos validation Mar 17, 2026
@atalman

atalman commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator

This is looks nice. Lets add a general tag validation for Linux, Linux aarch64, Windows, MacOS the tag is located inside WHEEL file and looks like: Tag: cp314-cp314-manylinux_2_28_aarch64

@yangw-dev
yangw-dev requested a review from atalman March 17, 2026 23:03

@atalman atalman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. lets merge on green

@yangw-dev

Copy link
Copy Markdown
Contributor Author

it seems like the failure is not related to my changes

@yangw-dev

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@yangw-dev

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -i

@yangw-dev yangw-dev closed this Mar 18, 2026
@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 18, 2026
@yangw-dev yangw-dev reopened this Mar 18, 2026
@yangw-dev

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: windows-arm64-binary-wheel / wheel-py3_13-cpu-test

Details for Dev Infra team Raised by workflow job

@yangw-dev

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 4 checks: trunk / linux-jammy-cuda13.0-py3.10-gcc11 / test (default, 3, 5, lf.linux.g6.4xlarge.experimental.nvidia.gpu), windows-arm64-binary-wheel / wheel-py3_11-cpu-test, windows-arm64-binary-wheel / wheel-py3_12-cpu-test, windows-arm64-binary-wheel / wheel-py3_13-cpu-test

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

ryanzhang22 pushed a commit to ryanzhang22/pytorch that referenced this pull request Mar 19, 2026
…ch#177609)

Fixes pytorch#177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: pytorch#177609
Approved by: https://github.com/atalman
yangw-dev added a commit that referenced this pull request Mar 19, 2026
Fixes #177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: #177609
Approved by: https://github.com/atalman
yangw-dev added a commit that referenced this pull request Mar 20, 2026
…) (#177903)

Fixes #177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: #177609
Approved by: https://github.com/atalman
AaronWang04 pushed a commit to AaronWang04/pytorch that referenced this pull request Mar 31, 2026
…ch#177609)

Fixes pytorch#177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: pytorch#177609
Approved by: https://github.com/atalman
AaronWang04 pushed a commit to AaronWang04/pytorch that referenced this pull request Mar 31, 2026
…ch#177609) (pytorch#177903)

Fixes pytorch#177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: pytorch#177609
Approved by: https://github.com/atalman
nklshy-aws pushed a commit to nklshy-aws/pytorch that referenced this pull request Apr 7, 2026
…ch#177609) (pytorch#177903)

Fixes pytorch#177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: pytorch#177609
Approved by: https://github.com/atalman
nklshy-aws pushed a commit to nklshy-aws/pytorch that referenced this pull request Apr 7, 2026
…ch#177609) (pytorch#177903)

Fixes pytorch#177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: pytorch#177609
Approved by: https://github.com/atalman
@github-actions
github-actions Bot deleted the verify branch April 19, 2026 02:25
@yangw-dev yangw-dev changed the title [macOS wheel] Add wheel platform tag vs dylib minos validation [release validation][macOS wheel] Add wheel platform tag vs dylib minos validation May 15, 2026
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ch#177609)

Fixes pytorch#177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: pytorch#177609
Approved by: https://github.com/atalman
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ch#177609) (pytorch#177903)

Fixes pytorch#177140

# Summary
Adds a check to validate that the macOS wheel platform tag matches the actual minos (minimum OS version) in the Mach-O binaries.

For example, given a wheel like:
```
torch-2.12.0.dev20260316-cp313-cp313t-macosx_11_0_arm64.whl
```

The platform tag claims macosx_11_0_arm64, meaning minos should be 11.0. This script runs otool -l on each installed .dylib and verifies the minos from LC_BUILD_VERSION (or LC_VERSION_MIN_MACOSX) matches 11.0.

Pull Request resolved: pytorch#177609
Approved by: https://github.com/atalman
zklaus added a commit to zklaus/pytorch that referenced this pull request Aug 29, 2026
This job builds a wheel and never imports it -- the smoke test further down is
gated on *full-debug*, which this build environment is not -- so an extension
module named wrongly passes silently. That is not hypothetical: run 33078360947,
on this branch two days ago, linked `torch/_C.so` untagged and went green.

The cause was pytorchgh-189388, which has since landed: FindPython does not run the
interpreter to compute Python_SOABI while cross-compiling, so WITH_SOABI composes
a name with no ABI tag. Run 33243561273, on the rebase that picked the fix up,
links `torch/_C.cpython-312-riscv64-linux-gnu.so` instead. Nothing in CI checks
that, which is how the class went unnoticed long enough to be reported from
conda-forge rather than found here.

The check asks whether the wheel is self-consistent, rather than comparing it
against the running interpreter. A wheel states its tags twice -- in the filename
and in .dist-info/WHEEL -- and the extension module inside has to agree with
both. So it verifies that those two agree, that exactly one torch/_C module is
present, that it is not the untagged torch/_C.so, and that its ABI tag matches
the wheel's, cp312 against cpython-312.

Deriving the expectation from sysconfig instead, as a first draft did, makes the
result depend on which interpreter happens to be active -- for a cross build that
is the crossenv interpreter reporting the target's values, not the obvious one.
That held here, but only by construction: it is a property of where the call sits
relative to the crossenv activation, invisible at the call site, and it would
silently become a false failure if either moved. Reading the wheel's own tags has
no such coupling, and lets the check run under any interpreter.

It also catches more. A wheel whose filename and metadata disagree, or whose
module is tagged for a different Python than the wheel claims, are both real
mis-builds that the sysconfig form would have passed whenever the checker
happened to run under the matching interpreter.

The checker lives in .ci/pytorch/check_wheel_soabi.py rather than inline: as a
file it is linted and directly testable, which an embedded heredoc is not, and
.ci/pytorch already holds print_sccache_log.py and rocm_preflight.py. It takes
any number of wheels so the caller passes the glob directly -- dist/ is not
guaranteed to hold exactly one, pip_install_whl in common_utils.sh already splits
a multi-path argument for that reason, and an earlier draft using
`$(echo dist/*.whl)` would have silently checked whichever wheel sorted first.

It is gated on the riscv64 cross environment. A native build satisfies it
trivially, and adding wheel inspection to every build job is a wider change than
this branch should make; the check is cheap enough that generalising it later is
worth considering.

There is adjacent prior art. .ci/pytorch/smoke_test/check_wheel_tags.py, added in
pytorch#177609, validates a wheel's declared tags against the running interpreter and
TARGET_OS -- answering "did we build for the target we meant to", which does need
an external reference. It never inspects the extension module's filename, so an
untagged torch/_C.so inside a correctly tagged wheel passes it cleanly; that is
the gap pytorchgh-189388 fell through. It is also reachable only via smoke_test.py,
which imports torch and therefore cannot run in a cross job. Folding the
module-name check in there would cover every platform's binary builds rather than
this one job, and is worth doing, but it is filed separately: that file is
smoke-test-only, so the cross job would still need its own call site.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

The assertion needs a ciflow/riscv64 run to exercise in place, and should pass:
run 33243561273 already produced the tagged name it looks for.

Because the check reads only the wheel, the riscv64 case is testable without a
riscv64 toolchain -- a wheel is a zip. These were built to order and run under
**host CPython 3.10 on x86_64**, deliberately neither the Python nor the
architecture the wheels claim, which is the property the sysconfig form lacked:

| wheel under test | exit |
| --- | --- |
| `cp312-cp312-linux_riscv64` shipping `_C.cpython-312-riscv64-linux-gnu.so` | 0 |
| same, shipping untagged `torch/_C.so` (the pytorchgh-189388 regression) | 1 |
| same, shipping no `torch/_C*` at all (the conda-forge symptom) | 1 |
| filename says `cp312-...`, `.dist-info/WHEEL` says `cp310-...` | 1 |
| declares `cp312`, ships `_C.cpython-310-riscv64-linux-gnu.so` | 1 |
| ships both the tagged module and an untagged `torch/_C.so` | 1 |
| a libtorch wheel plus a good torch wheel (former skipped) | 0 |
| a libtorch wheel alone, so nothing was verified | 1 |

Each failure names what it found and what it expected. Exit codes were read
directly rather than through a pipe, since `head` would otherwise mask them.

Lint:

```
lintrunner --paths-cmd='git diff --cached --name-only'
bash -n .ci/pytorch/build.sh
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Aug 30, 2026
This job builds a wheel and never imports it -- the smoke test further down is
gated on *full-debug*, which this build environment is not -- so an extension
module named wrongly passes silently. That is not hypothetical: run 33078360947,
on this branch two days ago, linked `torch/_C.so` untagged and went green.

The cause was pytorchgh-189388, which has since landed: FindPython does not run the
interpreter to compute Python_SOABI while cross-compiling, so WITH_SOABI composes
a name with no ABI tag. Run 33243561273, on the rebase that picked the fix up,
links `torch/_C.cpython-312-riscv64-linux-gnu.so` instead. Nothing in CI checks
that, which is how the class went unnoticed long enough to be reported from
conda-forge rather than found here.

The check asks whether the wheel is self-consistent, rather than comparing it
against the running interpreter. A wheel states its tags twice -- in the filename
and in .dist-info/WHEEL -- and the extension module inside has to agree with
both. So it verifies that those two agree, that exactly one torch/_C module is
present, that it is not the untagged torch/_C.so, and that its ABI tag matches
the wheel's, cp312 against cpython-312.

Deriving the expectation from sysconfig instead, as a first draft did, makes the
result depend on which interpreter happens to be active -- for a cross build that
is the crossenv interpreter reporting the target's values, not the obvious one.
That held here, but only by construction: it is a property of where the call sits
relative to the crossenv activation, invisible at the call site, and it would
silently become a false failure if either moved. Reading the wheel's own tags has
no such coupling, and lets the check run under any interpreter.

It also catches more. A wheel whose filename and metadata disagree, or whose
module is tagged for a different Python than the wheel claims, are both real
mis-builds that the sysconfig form would have passed whenever the checker
happened to run under the matching interpreter.

The checker lives in .ci/pytorch/check_wheel_soabi.py rather than inline: as a
file it is linted and directly testable, which an embedded heredoc is not, and
.ci/pytorch already holds print_sccache_log.py and rocm_preflight.py. It takes
any number of wheels so the caller passes the glob directly -- dist/ is not
guaranteed to hold exactly one, pip_install_whl in common_utils.sh already splits
a multi-path argument for that reason, and an earlier draft using
`$(echo dist/*.whl)` would have silently checked whichever wheel sorted first.

It is gated on the riscv64 cross environment. A native build satisfies it
trivially, and adding wheel inspection to every build job is a wider change than
this branch should make; the check is cheap enough that generalising it later is
worth considering.

There is adjacent prior art. .ci/pytorch/smoke_test/check_wheel_tags.py, added in
pytorch#177609, validates a wheel's declared tags against the running interpreter and
TARGET_OS -- answering "did we build for the target we meant to", which does need
an external reference. It never inspects the extension module's filename, so an
untagged torch/_C.so inside a correctly tagged wheel passes it cleanly; that is
the gap pytorchgh-189388 fell through. It is also reachable only via smoke_test.py,
which imports torch and therefore cannot run in a cross job. Folding the
module-name check in there would cover every platform's binary builds rather than
this one job, and is worth doing, but it is filed separately: that file is
smoke-test-only, so the cross job would still need its own call site.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

The assertion needs a ciflow/riscv64 run to exercise in place, and should pass:
run 33243561273 already produced the tagged name it looks for.

Because the check reads only the wheel, the riscv64 case is testable without a
riscv64 toolchain -- a wheel is a zip. These were built to order and run under
**host CPython 3.10 on x86_64**, deliberately neither the Python nor the
architecture the wheels claim, which is the property the sysconfig form lacked:

| wheel under test | exit |
| --- | --- |
| `cp312-cp312-linux_riscv64` shipping `_C.cpython-312-riscv64-linux-gnu.so` | 0 |
| same, shipping untagged `torch/_C.so` (the pytorchgh-189388 regression) | 1 |
| same, shipping no `torch/_C*` at all (the conda-forge symptom) | 1 |
| filename says `cp312-...`, `.dist-info/WHEEL` says `cp310-...` | 1 |
| declares `cp312`, ships `_C.cpython-310-riscv64-linux-gnu.so` | 1 |
| ships both the tagged module and an untagged `torch/_C.so` | 1 |
| a libtorch wheel plus a good torch wheel (former skipped) | 0 |
| a libtorch wheel alone, so nothing was verified | 1 |

Each failure names what it found and what it expected. Exit codes were read
directly rather than through a pipe, since `head` would otherwise mask them.

Lint:

```
lintrunner --paths-cmd='git diff --cached --name-only'
bash -n .ci/pytorch/build.sh
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some macOS wheels say macOS 11.0+ but inside there's libomp.dylib with minos 14.0

3 participants