Skip to content

Fix Windows libtorch x86_64 and arm64 packages overwriting each other - #187837

Closed
atalman wants to merge 1 commit into
pytorch:mainfrom
atalman:fix_libtorch_windows_x86
Closed

atalman wants to merge 1 commit into
pytorch:mainfrom
atalman:fix_libtorch_windows_x86

Conversation

@atalman

@atalman atalman commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Fixes #187812

Problem

The Windows libtorch CD packages for x86_64 and arm64 are generated with the same filename and uploaded to the same S3 location, so the arm64 build clobbers the x86_64 one. Users downloading the Windows x64 libtorch release actually receive Aarch64 binaries (c10.dll: PE32+ executable (DLL) (GUI) Aarch64).

Root cause

compute_zip_prefix() in .ci/libtorch/extract_libtorch_from_wheel.py returned libtorch-win-shared-with-deps for every Windows build regardless of architecture (the docstring even named libtorch-win-arm64-shared-with-deps, but the code never produced it). Both x86_64 and arm64 are CPU builds, so the upload subfolder (DESIRED_CUDA=cpu) and the zip filename were identical, and the S3 object key is the zip filename.

The arch-blind naming was introduced in #174753 (which added the wheel-extraction approach); the collision became live once the windows-arm64 wheel workflow started running the same extraction in #181586.

Fix

Thread architecture through the extraction so arm64 produces libtorch-win-arm64-shared-with-deps-{version}.zip while x86_64 keeps its existing libtorch-win-shared-with-deps-{version}.zip name (preserving the public download URL). generate_libtorch_extraction_configs also gives the arm64 job a distinct build_name so the GitHub artifact and job names no longer alias.

Test Plan

Verified prefix logic:

x86_64 -> libtorch-win-shared-with-deps
arm64  -> libtorch-win-arm64-shared-with-deps

Regenerated the binary build workflows (python .github/scripts/generate_ci_workflows.py); the windows-arm64 wheel workflow now passes --arch arm64 and uploads a distinct libtorch-arm64-cpu-shared-with-deps-release artifact, while the x86_64 workflow is unchanged apart from an explicit --arch x86_64.

This PR was authored with the assistance of an AI coding assistant (Claude Code).

The Windows libtorch CD packages for x86_64 and arm64 were generated with
the same filename and uploaded to the same S3 location, so the arm64 build
clobbered the x86_64 one. Users downloading the Windows x64 libtorch release
actually received Aarch64 binaries (issue pytorch#187812).

Root cause: compute_zip_prefix() in .ci/libtorch/extract_libtorch_from_wheel.py
returned "libtorch-win-shared-with-deps" for every Windows build regardless of
architecture (the docstring named "libtorch-win-arm64-shared-with-deps" but the
code never produced it). Both x86_64 and arm64 are CPU builds, so the upload
subfolder (DESIRED_CUDA=cpu) and the zip filename were identical, and the S3
object key is the zip filename. The arch-blind naming was introduced in
pytorch#174753; the collision became live once the windows-arm64 wheel workflow
started running the same extraction (pytorch#181586).

The fix threads architecture through the extraction so arm64 produces
"libtorch-win-arm64-shared-with-deps-{version}.zip" while x86_64 keeps its
existing "libtorch-win-shared-with-deps-{version}.zip" name (preserving the
public download URL). generate_libtorch_extraction_configs also gives the
arm64 job a distinct build_name so the GitHub artifact and job names no longer
alias.

Test Plan:

Verified the prefix logic for each platform/arch:

```
python -c "
import importlib.util
spec = importlib.util.spec_from_file_location('m', '.ci/libtorch/extract_libtorch_from_wheel.py')
m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
for arch in ['x86_64','arm64']:
    print(arch, '->', m.compute_zip_prefix('windows','cpu','shared-with-deps',arch))
"
# x86_64 -> libtorch-win-shared-with-deps
# arm64  -> libtorch-win-arm64-shared-with-deps
```

Regenerated the binary build workflows and confirmed the windows-arm64 wheel
workflow now passes --arch arm64 and uploads a distinct
libtorch-arm64-cpu-shared-with-deps-release artifact, while the x86_64
workflow is unchanged apart from an explicit --arch x86_64:

```
python .github/scripts/generate_ci_workflows.py
```

This PR was authored with the assistance of an AI coding assistant (Claude Code).
@atalman
atalman requested a review from a team as a code owner June 22, 2026 14:46
@pytorch-bot

pytorch-bot Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 3 Unclassified Failures

As of commit e65861a with merge base dbd6811 (image):

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.

@atalman atalman added the ciflow/binaries Trigger all binary build and upload jobs on the PR label Jun 22, 2026
@atalman atalman added the ciflow/binaries_libtorch Trigger binary build and upload jobs for libtorch on the PR label Jun 22, 2026
@atalman

atalman commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "build and lint looks good"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

atalman added a commit to pytorch/test-infra that referenced this pull request Jun 23, 2026
## Problem

The libtorch branch of `validate_binaries.sh` only downloaded and
unzipped the package, then `exit 0` with no verification:

```bash
if [[ ${MATRIX_PACKAGE_TYPE} == "libtorch" ]]; then
    curl "${MATRIX_INSTALLATION}" -o libtorch.zip
    unzip libtorch.zip
    exit 0
fi
```

So the arch mismatch in pytorch/pytorch#187812 -- where the Windows
x86_64 libtorch package was overwritten by the arm64 build and shipped
Aarch64 binaries under the x64 download URL -- slipped through
validation entirely.

## Fix

After unzip, read the machine field directly from the extracted `c10`
library header (PE on Windows, ELF on Linux, Mach-O on macOS) and fail
validation if it doesn't match the runner architecture. This is shared
by the linux/windows/macos validate workflows, so all are covered.

- Dependency-free: uses the runner's `python` and parses the binary
header directly (no `file(1)`, which isn't reliably present on Windows
runners).
- Skips gracefully if the c10 library or python can't be found.

The upstream packaging fix is pytorch/pytorch#187837; this is the
validation-side guard so a future regression is caught before release
rather than by users.

## Test Plan

Verified header parsing against a real ELF binary and synthetic PE/ELF
headers with arm64 machine fields:

```
real /bin/ls on x86_64 host -> x86_64 (matches, passes)
synthetic AArch64 ELF (e_machine=0xB7) -> arm64 (mismatch on x64 runner, fails)
synthetic ARM64 PE (machine=0xAA64)    -> arm64 (mismatch on x64 runner, fails)
```

Confirmed the script still parses: `bash -n
.github/scripts/validate_binaries.sh`.

This change was authored with the assistance of an AI coding assistant
(Claude Code).

---------

Co-authored-by: Andrey Talman <[email protected]>
@atalman

atalman commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot cherry-pick --onto release/2.13 -c critical

@pytorchbot

Copy link
Copy Markdown
Collaborator

Cherry picking #187837

The cherry pick PR is at #187973 and it is recommended to link a critical cherry pick PR with an issue. The following tracker issues are updated:

Details for Dev Infra team Raised by workflow job

atalman added a commit that referenced this pull request Jun 23, 2026
…#187973)

Fix Windows libtorch x86_64 and arm64 packages overwriting each other (#187837)

Fixes #187812

## Problem

The Windows libtorch CD packages for x86_64 and arm64 are generated with the **same filename** and uploaded to the **same S3 location**, so the arm64 build clobbers the x86_64 one. Users downloading the Windows x64 libtorch release actually receive Aarch64 binaries (`c10.dll: PE32+ executable (DLL) (GUI) Aarch64`).

## Root cause

`compute_zip_prefix()` in `.ci/libtorch/extract_libtorch_from_wheel.py` returned `libtorch-win-shared-with-deps` for every Windows build regardless of architecture (the docstring even named `libtorch-win-arm64-shared-with-deps`, but the code never produced it). Both x86_64 and arm64 are CPU builds, so the upload subfolder (`DESIRED_CUDA=cpu`) and the zip filename were identical, and the S3 object key is the zip filename.

The arch-blind naming was introduced in #174753 (which added the wheel-extraction approach); the collision became live once the windows-arm64 wheel workflow started running the same extraction in #181586.

## Fix

Thread architecture through the extraction so arm64 produces `libtorch-win-arm64-shared-with-deps-{version}.zip` while x86_64 keeps its existing `libtorch-win-shared-with-deps-{version}.zip` name (preserving the public download URL). `generate_libtorch_extraction_configs` also gives the arm64 job a distinct `build_name` so the GitHub artifact and job names no longer alias.

## Test Plan

Verified prefix logic:

```
x86_64 -> libtorch-win-shared-with-deps
arm64  -> libtorch-win-arm64-shared-with-deps
```

Regenerated the binary build workflows (`python .github/scripts/generate_ci_workflows.py`); the windows-arm64 wheel workflow now passes `--arch arm64` and uploads a distinct `libtorch-arm64-cpu-shared-with-deps-release` artifact, while the x86_64 workflow is unchanged apart from an explicit `--arch x86_64`.

This PR was authored with the assistance of an AI coding assistant (Claude Code).
Pull Request resolved: #187837
Approved by: https://github.com/Skylion007, https://github.com/huydhn, https://github.com/malfet

(cherry picked from commit 599fb5c)

Co-authored-by: atalman <[email protected]>
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…pytorch#187837)

Fixes pytorch#187812

## Problem

The Windows libtorch CD packages for x86_64 and arm64 are generated with the **same filename** and uploaded to the **same S3 location**, so the arm64 build clobbers the x86_64 one. Users downloading the Windows x64 libtorch release actually receive Aarch64 binaries (`c10.dll: PE32+ executable (DLL) (GUI) Aarch64`).

## Root cause

`compute_zip_prefix()` in `.ci/libtorch/extract_libtorch_from_wheel.py` returned `libtorch-win-shared-with-deps` for every Windows build regardless of architecture (the docstring even named `libtorch-win-arm64-shared-with-deps`, but the code never produced it). Both x86_64 and arm64 are CPU builds, so the upload subfolder (`DESIRED_CUDA=cpu`) and the zip filename were identical, and the S3 object key is the zip filename.

The arch-blind naming was introduced in pytorch#174753 (which added the wheel-extraction approach); the collision became live once the windows-arm64 wheel workflow started running the same extraction in pytorch#181586.

## Fix

Thread architecture through the extraction so arm64 produces `libtorch-win-arm64-shared-with-deps-{version}.zip` while x86_64 keeps its existing `libtorch-win-shared-with-deps-{version}.zip` name (preserving the public download URL). `generate_libtorch_extraction_configs` also gives the arm64 job a distinct `build_name` so the GitHub artifact and job names no longer alias.

## Test Plan

Verified prefix logic:

```
x86_64 -> libtorch-win-shared-with-deps
arm64  -> libtorch-win-arm64-shared-with-deps
```

Regenerated the binary build workflows (`python .github/scripts/generate_ci_workflows.py`); the windows-arm64 wheel workflow now passes `--arch arm64` and uploads a distinct `libtorch-arm64-cpu-shared-with-deps-release` artifact, while the x86_64 workflow is unchanged apart from an explicit `--arch x86_64`.

This PR was authored with the assistance of an AI coding assistant (Claude Code).
Pull Request resolved: pytorch#187837
Approved by: https://github.com/Skylion007, https://github.com/huydhn, https://github.com/malfet
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…pytorch#187837)

Fixes pytorch#187812

## Problem

The Windows libtorch CD packages for x86_64 and arm64 are generated with the **same filename** and uploaded to the **same S3 location**, so the arm64 build clobbers the x86_64 one. Users downloading the Windows x64 libtorch release actually receive Aarch64 binaries (`c10.dll: PE32+ executable (DLL) (GUI) Aarch64`).

## Root cause

`compute_zip_prefix()` in `.ci/libtorch/extract_libtorch_from_wheel.py` returned `libtorch-win-shared-with-deps` for every Windows build regardless of architecture (the docstring even named `libtorch-win-arm64-shared-with-deps`, but the code never produced it). Both x86_64 and arm64 are CPU builds, so the upload subfolder (`DESIRED_CUDA=cpu`) and the zip filename were identical, and the S3 object key is the zip filename.

The arch-blind naming was introduced in pytorch#174753 (which added the wheel-extraction approach); the collision became live once the windows-arm64 wheel workflow started running the same extraction in pytorch#181586.

## Fix

Thread architecture through the extraction so arm64 produces `libtorch-win-arm64-shared-with-deps-{version}.zip` while x86_64 keeps its existing `libtorch-win-shared-with-deps-{version}.zip` name (preserving the public download URL). `generate_libtorch_extraction_configs` also gives the arm64 job a distinct `build_name` so the GitHub artifact and job names no longer alias.

## Test Plan

Verified prefix logic:

```
x86_64 -> libtorch-win-shared-with-deps
arm64  -> libtorch-win-arm64-shared-with-deps
```

Regenerated the binary build workflows (`python .github/scripts/generate_ci_workflows.py`); the windows-arm64 wheel workflow now passes `--arch arm64` and uploads a distinct `libtorch-arm64-cpu-shared-with-deps-release` artifact, while the x86_64 workflow is unchanged apart from an explicit `--arch x86_64`.

This PR was authored with the assistance of an AI coding assistant (Claude Code).
Pull Request resolved: pytorch#187837
Approved by: https://github.com/Skylion007, https://github.com/huydhn, https://github.com/malfet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries_libtorch Trigger binary build and upload jobs for libtorch on the PR ciflow/binaries Trigger all binary build and upload jobs on the PR Merged release notes: releng release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LibTorch 2.12.1 on Windows release package is for Aarch64

6 participants