Skip to content

[BE] Slim Jinja templates: render matrix-driven binary workflows - #181586

Closed
atalman wants to merge 4 commits into
gh/atalman/1/basefrom
gh/atalman/1/head
Closed

atalman wants to merge 4 commits into
gh/atalman/1/basefrom
gh/atalman/1/head

Conversation

@atalman

@atalman atalman commented Apr 27, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Summary

Refactor the linux + windows jinja templates to follow the slim pattern introduced for macOS in #181153: each template emits a single matrix-driven build / test / upload job whose strategy.matrix.include list is unrolled at template-generation time from the configs supplied by generate_binary_build_matrix.py.

Adding a new Python or CUDA / ROCm version is now a one-line edit to FULL_PYTHON_VERSIONS / CUDA_ARCHES / ROCM_ARCHES in .github/scripts/generate_binary_build_matrix.py, followed by a .github/regenerate.sh run.

Templates touched

  • linux_binary_build_workflow.yml.j2 (4698 -> 1417 generated lines for x86)
    one matrix-driven manywheel-build job; manywheel-test for cpu/cuda; separate manywheel-test-rocm and manywheel-test-xpu matrix jobs that delegate to new reusable workflows so the rocm-/xpu-specific setup stays out of the main yaml.
  • windows_binary_build_workflow.yml.j2 (~8400 -> ~1100 generated lines for x86 wheel)
    one matrix-driven wheel-build / wheel-test / wheel-upload chain; arm64 keeps its bootstrap_*.bat steps in the same template path, selected via {%- if os == "windows-arm64" %}.
  • macos_binary_build_workflow.yml.j2 unchanged (already slim from [BE] Make macos_binary_build_workflow.yml use matrix #181153).

New reusable workflows

  • .github/workflows/_binary-test-rocm-linux.yml
  • .github/workflows/_binary-test-xpu-linux.yml

Both replicate the legacy inline ROCm / XPU test logic (setup-rocm / setup-xpu, ECR docker pull, test-pytorch-binary), but as uses:-able workflows so the slim main template stays small.

Generated outputs

Workflow Before After
linux x86 manywheel 4698 1417
linux aarch64 manywheel 2085 774
linux s390x manywheel 525 292
windows x86 wheel 8414 1128
windows x86 libtorch-debug 1020 387
windows arm64 wheel 554 325
windows arm64 libtorch-debug 209 242
macos arm64 wheel 270 270

All YAMLs ship with the standard # @generated DO NOT EDIT MANUALLY header and the regenerate-and-diff lint check enforces that the templates and the on-disk YAMLs stay in sync.

Job names in the GitHub UI are preserved via per-matrix-cell name: ${{ matrix.build_name }}-build, so external references (HUD, required-status-checks) keep matching manywheel-py3_10-cuda12_6-build-style names.

Test plan

  • ciflow/binaries_wheel/* tag push triggers all eight workflows with the expected matrix cell counts.
  • lint workflow-checks job passes (generate_ci_workflows.py produces a clean diff).
  • Adding a CUDA version to CUDA_ARCHES + running regenerate.sh adds new matrix entries to all generated workflows.

Authored with Claude.

Remove the jinja template generator entirely; hand-edit the
generated-*-nightly.yml files instead. Binary workflows now share
a runtime matrix via generate_binary_build_matrix.py, so adding a
new python/CUDA/ROCm version there is picked up automatically without
regenerating any YAML.

Converted in this PR:
  - generated-linux-s390x-binary-manywheel-nightly.yml (prototype)

New plumbing:
  - generate_binary_build_matrix.py grows a `--runtime-matrix <os>`
    CLI that prints the wheels-matrix JSON and writes it to
    $GITHUB_OUTPUT as `configs=<json>` for `strategy.matrix` consumption.

Removed:
  - .github/templates/ (all five *.yml.j2 files)
  - .github/scripts/generate_ci_workflows.py
  - .github/regenerate.sh
  - .github/requirements/regenerate-requirements.txt

Follow-ups (separate PRs):
  - Convert generated-linux-aarch64-binary-manywheel-nightly.yml
  - Convert generated-linux-binary-manywheel-nightly.yml (adds ROCm
    inline test + XPU oneAPI sourcing)
  - Convert the macOS and Windows generated workflows

Authored with Claude.

[ghstack-poisoned]
@atalman
atalman requested a review from a team as a code owner April 27, 2026 14:49
@pytorch-bot

pytorch-bot Bot commented Apr 27, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

❌ 15 New Failures, 21 Cancelled Jobs

As of commit 8bd62a1 with merge base d3b8bf0 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

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

…enerator"

Remove the jinja template generator entirely; hand-edit the
generated-*-nightly.yml files instead. Binary workflows now share
a runtime matrix via generate_binary_build_matrix.py, so adding a
new python/CUDA/ROCm version there is picked up automatically without
regenerating any YAML.

Converted in this PR:
  - generated-linux-s390x-binary-manywheel-nightly.yml (prototype)

New plumbing:
  - generate_binary_build_matrix.py grows a `--runtime-matrix <os>`
    CLI that prints the wheels-matrix JSON and writes it to
    $GITHUB_OUTPUT as `configs=<json>` for `strategy.matrix` consumption.

Removed:
  - .github/templates/ (all five *.yml.j2 files)
  - .github/scripts/generate_ci_workflows.py
  - .github/regenerate.sh
  - .github/requirements/regenerate-requirements.txt

Follow-ups (separate PRs):
  - Convert generated-linux-aarch64-binary-manywheel-nightly.yml
  - Convert generated-linux-binary-manywheel-nightly.yml (adds ROCm
    inline test + XPU oneAPI sourcing)
  - Convert the macOS and Windows generated workflows

Authored with Claude.

[ghstack-poisoned]
@atalman atalman changed the title Matrix-driven linux-s390x manywheel workflow; drop jinja generator [BE] Remove Jinja template generator for binary workflows Apr 27, 2026

@malfet malfet 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.

To make binary workflows more easily searchable, should they all start from binary-?

Also, in description would be nice to outline how one is expected to add say new Python version

@malfet malfet added the ciflow/binaries Trigger all binary build and upload jobs on the PR label Apr 27, 2026
## Summary

Drop the jinja template generator for binary build workflows. All eight `generated-*-nightly.yml` files are now hand-edited, matrix-driven workflows that consume the GPU/arch/python matrix from `.github/scripts/generate_binary_build_matrix.py` at runtime. Adding a new CUDA / ROCm / Python version now only requires editing that single script — no YAML regeneration.

**Net: +1,941 / -18,886 across 33 files.**

## What changed

### Infrastructure
- **Deleted:** `.github/templates/` (all five `*.yml.j2`), `.github/scripts/generate_ci_workflows.py`, `.github/regenerate.sh`, `.github/requirements/regenerate-requirements.txt`.
- **`lint.yml`:** dropped the `workflow-checks` regenerate-and-diff step. `ensure_actions_will_cancel.py` kept.
- **`generate_binary_build_matrix.py`:** new `--runtime-matrix <os>` CLI emits to `$GITHUB_OUTPUT`:
  - `configs` — full wheels matrix (build + upload)
  - `test-standard-configs` — CPU + CUDA (driven through `_binary-test-linux.yml`)
  - `test-rocm-configs` — ROCm only
  - `test-xpu-configs` — XPU only
  - `libtorch-configs` — libtorch extraction configs (py3.10 per arch)
  - `libtorch-debug-configs` — Windows libtorch-debug matrix
- **`.gitattributes`:** removed `generated-*` `linguist-generated` entries.

### Renamed workflows (dropped `generated-` prefix, stripped `generated` headers)

| Before | After | Lines |
|---|---|---|
| `generated-linux-binary-manywheel-nightly.yml` | `linux-binary-manywheel-nightly.yml` | 4698 → 207 |
| `generated-linux-aarch64-binary-manywheel-nightly.yml` | `linux-aarch64-binary-manywheel-nightly.yml` | 2085 → 155 |
| `generated-linux-s390x-binary-manywheel-nightly.yml` | `linux-s390x-binary-manywheel-nightly.yml` | 525 → 150 |
| `generated-macos-arm64-binary-wheel-nightly.yml` | `macos-arm64-binary-wheel-nightly.yml` | 257 → 251 |
| `generated-windows-binary-wheel-nightly.yml` | `windows-binary-wheel-nightly.yml` | 8414 → 131 |
| `generated-windows-binary-libtorch-debug-nightly.yml` | `windows-binary-libtorch-debug-nightly.yml` | 1020 → 124 |
| `generated-windows-arm64-binary-wheel-nightly.yml` | `windows-arm64-binary-wheel-nightly.yml` | 554 → 192 |
| `generated-windows-arm64-binary-libtorch-debug-nightly.yml` | `windows-arm64-binary-libtorch-debug-nightly.yml` | 209 → 126 |

Workflow `name:` keys and `concurrency` groups are unchanged — external references (HUD, required-status-checks) keep matching. Job names stay in the `manywheel-py3_10-cuda12_6-build` style via per-matrix-cell `name:` overrides.

### New reusable workflows
- `_binary-test-rocm-linux.yml` — setup-rocm + GPU_FLAG + ECR docker pull + teardown-rocm.
- `_binary-test-xpu-linux.yml` — setup-xpu + ECR login + teardown-xpu.
- `_binary-build-windows.yml`, `_binary-test-windows.yml` — shared EC2 metadata / SSH / long-paths / Windows Defender boilerplate.
- `_binary-build-windows-arm64.yml`, `_binary-test-windows-arm64.yml` — arm64-specific `bootstrap_*.bat` steps.

## Test plan

- [ ] `ciflow/binaries_wheel/*` tag push triggers all eight workflows with the expected matrix cell counts (49 Linux x86, 28 Linux aarch64, 7 Linux s390x, 7 macOS, 35 Win x86, 5 Win arm64, 4 Win libtorch-debug, 3 Win arm64 libtorch-debug).
- [ ] Job names in the GitHub UI still read `manywheel-py3_10-cuda12_6-build` etc.
- [ ] lint `workflow-checks` job is green without the regenerate step.
- [ ] Adding a CUDA version to `CUDA_ARCHES` in `generate_binary_build_matrix.py` (and rerunning the workflow) adds new matrix cells without touching any YAML.

## Risks / follow-ups

- Matrix strategy + reusable workflow is supported by GitHub Actions but the check-name wire format may differ slightly from the old flat per-config jobs; verify HUD + branch-protection still match.
- ROCm/XPU tests on Linux used to keep per-config upload granularity (each upload independent of other configs' test results). With matrix, `upload` uses `!failure() && !cancelled()` — any test cell failure blocks the entire matrix upload.
- Windows x86 builds share one big reusable workflow across CPU/CUDA/XPU; if any of those ever need divergent setup, we'd add conditional inputs.

Authored with Claude.


[ghstack-poisoned]
atalman added a commit that referenced this pull request Apr 27, 2026
Refactor the linux + windows jinja templates to follow the slim pattern
introduced for macos in #181153: each template emits a single
matrix-driven build/test/upload job whose `strategy.matrix.include` list
is unrolled at template-generation time from the configs supplied by
generate_binary_build_matrix.py. Adding a new Python or CUDA/ROCm
version is a one-line edit to FULL_PYTHON_VERSIONS / CUDA_ARCHES /
ROCM_ARCHES + a `regenerate.sh` run.

Templates touched:
  - linux_binary_build_workflow.yml.j2 (4698 -> 1417 generated)
    one matrix-driven manywheel-build job; manywheel-test for
    cpu/cuda; separate manywheel-test-rocm and manywheel-test-xpu
    matrix jobs that delegate to new reusable workflows so the
    rocm-/xpu-specific setup stays out of the main yaml.
  - windows_binary_build_workflow.yml.j2 (~8400 -> ~1100 generated for x86 wheel)
    one matrix-driven wheel-build / wheel-test / wheel-upload chain;
    arm64 keeps its bootstrap_*.bat steps in the same template path,
    selected via {%- if os == "windows-arm64" %}.
  - macos_binary_build_workflow.yml.j2 unchanged (already slim from #181153).

New reusable workflows:
  - _binary-test-rocm-linux.yml
  - _binary-test-xpu-linux.yml
  Both replicate the legacy inline ROCm/XPU test logic (setup-rocm /
  setup-xpu, ECR docker pull, test-pytorch-binary), but as `uses:`-able
  workflows so the slim main template stays small.

Python versions are controlled solely by FULL_PYTHON_VERSIONS in
.github/scripts/generate_binary_build_matrix.py — `python_version`
flows from there into `build_configs` into the template's
matrix.include emission.

Generated YAMLs ship with the standard `# @generated DO NOT EDIT
MANUALLY` header and the regenerate-and-diff lint check enforces that
the templates and the on-disk YAMLs stay in sync.

Authored with Claude.

ghstack-source-id: 70f5c2b
Pull Request resolved: #181586
## Summary

Drop the jinja template generator for binary build workflows. All eight `generated-*-nightly.yml` files are now hand-edited, matrix-driven workflows that consume the GPU/arch/python matrix from `.github/scripts/generate_binary_build_matrix.py` at runtime. Adding a new CUDA / ROCm / Python version now only requires editing that single script — no YAML regeneration.

**Net: +1,941 / -18,886 across 33 files.**

## What changed

### Infrastructure
- **Deleted:** `.github/templates/` (all five `*.yml.j2`), `.github/scripts/generate_ci_workflows.py`, `.github/regenerate.sh`, `.github/requirements/regenerate-requirements.txt`.
- **`lint.yml`:** dropped the `workflow-checks` regenerate-and-diff step. `ensure_actions_will_cancel.py` kept.
- **`generate_binary_build_matrix.py`:** new `--runtime-matrix <os>` CLI emits to `$GITHUB_OUTPUT`:
  - `configs` — full wheels matrix (build + upload)
  - `test-standard-configs` — CPU + CUDA (driven through `_binary-test-linux.yml`)
  - `test-rocm-configs` — ROCm only
  - `test-xpu-configs` — XPU only
  - `libtorch-configs` — libtorch extraction configs (py3.10 per arch)
  - `libtorch-debug-configs` — Windows libtorch-debug matrix
- **`.gitattributes`:** removed `generated-*` `linguist-generated` entries.

### Renamed workflows (dropped `generated-` prefix, stripped `generated` headers)

| Before | After | Lines |
|---|---|---|
| `generated-linux-binary-manywheel-nightly.yml` | `linux-binary-manywheel-nightly.yml` | 4698 → 207 |
| `generated-linux-aarch64-binary-manywheel-nightly.yml` | `linux-aarch64-binary-manywheel-nightly.yml` | 2085 → 155 |
| `generated-linux-s390x-binary-manywheel-nightly.yml` | `linux-s390x-binary-manywheel-nightly.yml` | 525 → 150 |
| `generated-macos-arm64-binary-wheel-nightly.yml` | `macos-arm64-binary-wheel-nightly.yml` | 257 → 251 |
| `generated-windows-binary-wheel-nightly.yml` | `windows-binary-wheel-nightly.yml` | 8414 → 131 |
| `generated-windows-binary-libtorch-debug-nightly.yml` | `windows-binary-libtorch-debug-nightly.yml` | 1020 → 124 |
| `generated-windows-arm64-binary-wheel-nightly.yml` | `windows-arm64-binary-wheel-nightly.yml` | 554 → 192 |
| `generated-windows-arm64-binary-libtorch-debug-nightly.yml` | `windows-arm64-binary-libtorch-debug-nightly.yml` | 209 → 126 |

Workflow `name:` keys and `concurrency` groups are unchanged — external references (HUD, required-status-checks) keep matching. Job names stay in the `manywheel-py3_10-cuda12_6-build` style via per-matrix-cell `name:` overrides.

### New reusable workflows
- `_binary-test-rocm-linux.yml` — setup-rocm + GPU_FLAG + ECR docker pull + teardown-rocm.
- `_binary-test-xpu-linux.yml` — setup-xpu + ECR login + teardown-xpu.
- `_binary-build-windows.yml`, `_binary-test-windows.yml` — shared EC2 metadata / SSH / long-paths / Windows Defender boilerplate.
- `_binary-build-windows-arm64.yml`, `_binary-test-windows-arm64.yml` — arm64-specific `bootstrap_*.bat` steps.

## Test plan

- [ ] `ciflow/binaries_wheel/*` tag push triggers all eight workflows with the expected matrix cell counts (49 Linux x86, 28 Linux aarch64, 7 Linux s390x, 7 macOS, 35 Win x86, 5 Win arm64, 4 Win libtorch-debug, 3 Win arm64 libtorch-debug).
- [ ] Job names in the GitHub UI still read `manywheel-py3_10-cuda12_6-build` etc.
- [ ] lint `workflow-checks` job is green without the regenerate step.
- [ ] Adding a CUDA version to `CUDA_ARCHES` in `generate_binary_build_matrix.py` (and rerunning the workflow) adds new matrix cells without touching any YAML.

## Risks / follow-ups

- Matrix strategy + reusable workflow is supported by GitHub Actions but the check-name wire format may differ slightly from the old flat per-config jobs; verify HUD + branch-protection still match.
- ROCm/XPU tests on Linux used to keep per-config upload granularity (each upload independent of other configs' test results). With matrix, `upload` uses `!failure() && !cancelled()` — any test cell failure blocks the entire matrix upload.
- Windows x86 builds share one big reusable workflow across CPU/CUDA/XPU; if any of those ever need divergent setup, we'd add conditional inputs.

Authored with Claude.


[ghstack-poisoned]
@atalman atalman changed the title [BE] Remove Jinja template generator for binary workflows [BE] Slim Jinja templates: render matrix-driven binary workflows Apr 27, 2026
@atalman
atalman requested a review from malfet April 27, 2026 21:45
@atalman

atalman commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "everything looks correct"

@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 that referenced this pull request May 6, 2026
Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
helpers, and write the new helpers in Python rather than shell:

- build_env_setup.py    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.py shared build-time dependency install
- build_wheel.py        the actual wheel build (python -m build)
- repair_wheel.py       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.py +
build_wheel.py) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

build_env_setup.py writes its build-flag exports (USE_CUDA,
TH_BINARY_BUILD, ...) to a file via --env-out which build.sh sources;
this is what lets those flags reach the wheel-build subprocess (a plain
`bash build_env_setup.sh` would have dropped them).

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.

ghstack-source-id: d892d0d
Pull Request resolved: #182409
atalman added a commit that referenced this pull request May 6, 2026
…it env setup, deps, wheel, repair)"

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.

[ghstack-poisoned]
atalman added a commit that referenced this pull request May 6, 2026
…ps, wheel, repair)"

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.

[ghstack-poisoned]
atalman added a commit that referenced this pull request May 6, 2026
Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
helpers, and write the new helpers in Python rather than shell:

- build_env_setup.py    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.py shared build-time dependency install
- build_wheel.py        the actual wheel build (python -m build)
- repair_wheel.py       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.py +
build_wheel.py) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

build_env_setup.py writes its build-flag exports (USE_CUDA,
TH_BINARY_BUILD, ...) to a file via --env-out which build.sh sources;
this is what lets those flags reach the wheel-build subprocess (a plain
`bash build_env_setup.sh` would have dropped them).

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.

ghstack-source-id: a6345a5
Pull Request resolved: #182409
atalman added a commit that referenced this pull request May 6, 2026
…it env setup, deps, wheel, repair)"

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.

[ghstack-poisoned]
atalman added a commit that referenced this pull request May 6, 2026
…ps, wheel, repair)"

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.

[ghstack-poisoned]
atalman added a commit that referenced this pull request May 6, 2026
Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
helpers, and write the new helpers in Python rather than shell:

- build_env_setup.py    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.py shared build-time dependency install
- build_wheel.py        the actual wheel build (python -m build)
- repair_wheel.py       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.py +
build_wheel.py) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

build_env_setup.py writes its build-flag exports (USE_CUDA,
TH_BINARY_BUILD, ...) to a file via --env-out which build.sh sources;
this is what lets those flags reach the wheel-build subprocess (a plain
`bash build_env_setup.sh` would have dropped them).

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.

ghstack-source-id: 7a45e73
Pull Request resolved: #182409
atalman added a commit that referenced this pull request May 7, 2026
…ps, wheel, repair)"

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request May 7, 2026
…repair) (#182409)

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via #181586 (and follow-ups #181599, #182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.
Pull Request resolved: #182409
Approved by: https://github.com/seemethere, https://github.com/huydhn
Alokksinha00 pushed a commit to Alokksinha00/pytorch that referenced this pull request May 15, 2026
…ch#181599)

Replace the docker-in-docker dance in the matrix-driven Linux binary
workflows with GitHub Actions' native `container:` directive. Each
matrix-cell job now starts directly inside the build container — the
existing .ci/* shell scripts read the same env vars (PYTORCH_ROOT,
PYTORCH_FINAL_PACKAGE_DIR, BINARY_ENV_FILE, ...) and run unchanged.

_binary-build-linux.yml and _binary-test-linux.yml are converted in
place: `runs-on: <runner>` + `container: image: <image>:<tag>`. The
CUDA test job adds `--gpus all -e NVIDIA_DRIVER_CAPABILITIES=...` via
container.options. _binary-test-rocm-linux.yml and
_binary-test-xpu-linux.yml get the same treatment with their device
passthrough flags.

s390x carve-out: the s390x runners are self-hosted, only register
with the bare `linux.s390x` label, and lack a host-level docker CLI
compatible with GHA's container directive (they use podman). Two new
reusables, _binary-build-linux-s390x.yml and
_binary-test-linux-s390x.yml, hold the legacy `docker run`-from-step
flow for s390x; the template routes s390x to those and everything
else to the new container-based reusables.

Build scripts in .ci/* are unchanged.

Authored with Claude.
Pull Request resolved: pytorch#181599
Approved by: https://github.com/huydhn
ghstack dependencies: pytorch#181586
Alokksinha00 pushed a commit to Alokksinha00/pytorch that referenced this pull request May 15, 2026
…rch#182335)

## Summary

The Jinja refactor in pytorch#181586 collapsed the linux binary build workflows into a single matrix-driven job and dropped the per-config ROCm timeout that pytorch#179596 had set, so x86 ROCm manywheel builds regressed from `timeout-minutes: 420` to `common.timeout_minutes` (240).

Make the timeout per-matrix-entry: `420` for ROCm, otherwise the per-OS default (`common.timeout_minutes` for x86, `420` for aarch64/s390x). Pass `${{ matrix.timeout_minutes }}` into `_binary-build-linux.yml`.

Net effect:
- ROCm x86: 240 -> 420 (restores pytorch#179596)
- CUDA / CPU / XPU x86: stay 240
- aarch64, s390x: stay 420

## Test plan

- [ ] Regenerated workflow renders cleanly: each matrix entry in `generated-linux-binary-manywheel-nightly.yml` has a `timeout_minutes` field; the job-level `timeout-minutes` reads from `${{ matrix.timeout_minutes }}`.
- [ ] Aarch64 / s390x generated workflows show `timeout_minutes: 420` on every entry (no behavior change).
- [ ] Nightly ROCm manywheel builds no longer hit the 240-minute cap.

Authored with Claude.

Pull Request resolved: pytorch#182335
Approved by: https://github.com/huydhn
Alokksinha00 pushed a commit to Alokksinha00/pytorch that referenced this pull request May 15, 2026
…repair) (pytorch#182409)

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via pytorch#181586 (and follow-ups pytorch#181599, pytorch#182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.
Pull Request resolved: pytorch#182409
Approved by: https://github.com/seemethere, https://github.com/huydhn
aperson30 pushed a commit to aperson30/pytorch that referenced this pull request Jun 20, 2026
…orch#181586)

## Summary

Refactor the linux + windows jinja templates to follow the slim pattern introduced for macOS in pytorch#181153: each template emits a single matrix-driven `build` / `test` / `upload` job whose `strategy.matrix.include` list is unrolled at template-generation time from the configs supplied by `generate_binary_build_matrix.py`.

Adding a new Python or CUDA / ROCm version is now a one-line edit to `FULL_PYTHON_VERSIONS` / `CUDA_ARCHES` / `ROCM_ARCHES` in `.github/scripts/generate_binary_build_matrix.py`, followed by a `.github/regenerate.sh` run.

## Templates touched

- `linux_binary_build_workflow.yml.j2` (4698 -> 1417 generated lines for x86)
  one matrix-driven `manywheel-build` job; `manywheel-test` for cpu/cuda; separate `manywheel-test-rocm` and `manywheel-test-xpu` matrix jobs that delegate to new reusable workflows so the rocm-/xpu-specific setup stays out of the main yaml.
- `windows_binary_build_workflow.yml.j2` (~8400 -> ~1100 generated lines for x86 wheel)
  one matrix-driven `wheel-build` / `wheel-test` / `wheel-upload` chain; arm64 keeps its `bootstrap_*.bat` steps in the same template path, selected via `{%- if os == "windows-arm64" %}`.
- `macos_binary_build_workflow.yml.j2` unchanged (already slim from pytorch#181153).

## New reusable workflows

- `.github/workflows/_binary-test-rocm-linux.yml`
- `.github/workflows/_binary-test-xpu-linux.yml`

Both replicate the legacy inline ROCm / XPU test logic (setup-rocm / setup-xpu, ECR docker pull, test-pytorch-binary), but as `uses:`-able workflows so the slim main template stays small.

## Generated outputs

| Workflow | Before | After |
|---|---:|---:|
| linux x86 manywheel | 4698 | 1417 |
| linux aarch64 manywheel | 2085 | 774 |
| linux s390x manywheel | 525 | 292 |
| windows x86 wheel | 8414 | 1128 |
| windows x86 libtorch-debug | 1020 | 387 |
| windows arm64 wheel | 554 | 325 |
| windows arm64 libtorch-debug | 209 | 242 |
| macos arm64 wheel | 270 | 270 |

All YAMLs ship with the standard `# @generated DO NOT EDIT MANUALLY` header and the regenerate-and-diff lint check enforces that the templates and the on-disk YAMLs stay in sync.

Job names in the GitHub UI are preserved via per-matrix-cell `name: ${{ matrix.build_name }}-build`, so external references (HUD, required-status-checks) keep matching `manywheel-py3_10-cuda12_6-build`-style names.

## Test plan

- [ ] `ciflow/binaries_wheel/*` tag push triggers all eight workflows with the expected matrix cell counts.
- [ ] lint workflow-checks job passes (`generate_ci_workflows.py` produces a clean diff).
- [ ] Adding a CUDA version to `CUDA_ARCHES` + running `regenerate.sh` adds new matrix entries to all generated workflows.

Authored with Claude.
Pull Request resolved: pytorch#181586
Approved by: https://github.com/malfet
aperson30 pushed a commit to aperson30/pytorch that referenced this pull request Jun 20, 2026
…ch#181599)

Replace the docker-in-docker dance in the matrix-driven Linux binary
workflows with GitHub Actions' native `container:` directive. Each
matrix-cell job now starts directly inside the build container — the
existing .ci/* shell scripts read the same env vars (PYTORCH_ROOT,
PYTORCH_FINAL_PACKAGE_DIR, BINARY_ENV_FILE, ...) and run unchanged.

_binary-build-linux.yml and _binary-test-linux.yml are converted in
place: `runs-on: <runner>` + `container: image: <image>:<tag>`. The
CUDA test job adds `--gpus all -e NVIDIA_DRIVER_CAPABILITIES=...` via
container.options. _binary-test-rocm-linux.yml and
_binary-test-xpu-linux.yml get the same treatment with their device
passthrough flags.

s390x carve-out: the s390x runners are self-hosted, only register
with the bare `linux.s390x` label, and lack a host-level docker CLI
compatible with GHA's container directive (they use podman). Two new
reusables, _binary-build-linux-s390x.yml and
_binary-test-linux-s390x.yml, hold the legacy `docker run`-from-step
flow for s390x; the template routes s390x to those and everything
else to the new container-based reusables.

Build scripts in .ci/* are unchanged.

Authored with Claude.
Pull Request resolved: pytorch#181599
Approved by: https://github.com/huydhn
ghstack dependencies: pytorch#181586
aperson30 pushed a commit to aperson30/pytorch that referenced this pull request Jun 20, 2026
…rch#182335)

## Summary

The Jinja refactor in pytorch#181586 collapsed the linux binary build workflows into a single matrix-driven job and dropped the per-config ROCm timeout that pytorch#179596 had set, so x86 ROCm manywheel builds regressed from `timeout-minutes: 420` to `common.timeout_minutes` (240).

Make the timeout per-matrix-entry: `420` for ROCm, otherwise the per-OS default (`common.timeout_minutes` for x86, `420` for aarch64/s390x). Pass `${{ matrix.timeout_minutes }}` into `_binary-build-linux.yml`.

Net effect:
- ROCm x86: 240 -> 420 (restores pytorch#179596)
- CUDA / CPU / XPU x86: stay 240
- aarch64, s390x: stay 420

## Test plan

- [ ] Regenerated workflow renders cleanly: each matrix entry in `generated-linux-binary-manywheel-nightly.yml` has a `timeout_minutes` field; the job-level `timeout-minutes` reads from `${{ matrix.timeout_minutes }}`.
- [ ] Aarch64 / s390x generated workflows show `timeout_minutes: 420` on every entry (no behavior change).
- [ ] Nightly ROCm manywheel builds no longer hit the 240-minute cap.

Authored with Claude.

Pull Request resolved: pytorch#182335
Approved by: https://github.com/huydhn
aperson30 pushed a commit to aperson30/pytorch that referenced this pull request Jun 20, 2026
…repair) (pytorch#182409)

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via pytorch#181586 (and follow-ups pytorch#181599, pytorch#182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.
Pull Request resolved: pytorch#182409
Approved by: https://github.com/seemethere, https://github.com/huydhn
pytorchmergebot pushed a commit that referenced this pull request Jun 22, 2026
…#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
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
…orch#181586)

## Summary

Refactor the linux + windows jinja templates to follow the slim pattern introduced for macOS in pytorch#181153: each template emits a single matrix-driven `build` / `test` / `upload` job whose `strategy.matrix.include` list is unrolled at template-generation time from the configs supplied by `generate_binary_build_matrix.py`.

Adding a new Python or CUDA / ROCm version is now a one-line edit to `FULL_PYTHON_VERSIONS` / `CUDA_ARCHES` / `ROCM_ARCHES` in `.github/scripts/generate_binary_build_matrix.py`, followed by a `.github/regenerate.sh` run.

## Templates touched

- `linux_binary_build_workflow.yml.j2` (4698 -> 1417 generated lines for x86)
  one matrix-driven `manywheel-build` job; `manywheel-test` for cpu/cuda; separate `manywheel-test-rocm` and `manywheel-test-xpu` matrix jobs that delegate to new reusable workflows so the rocm-/xpu-specific setup stays out of the main yaml.
- `windows_binary_build_workflow.yml.j2` (~8400 -> ~1100 generated lines for x86 wheel)
  one matrix-driven `wheel-build` / `wheel-test` / `wheel-upload` chain; arm64 keeps its `bootstrap_*.bat` steps in the same template path, selected via `{%- if os == "windows-arm64" %}`.
- `macos_binary_build_workflow.yml.j2` unchanged (already slim from pytorch#181153).

## New reusable workflows

- `.github/workflows/_binary-test-rocm-linux.yml`
- `.github/workflows/_binary-test-xpu-linux.yml`

Both replicate the legacy inline ROCm / XPU test logic (setup-rocm / setup-xpu, ECR docker pull, test-pytorch-binary), but as `uses:`-able workflows so the slim main template stays small.

## Generated outputs

| Workflow | Before | After |
|---|---:|---:|
| linux x86 manywheel | 4698 | 1417 |
| linux aarch64 manywheel | 2085 | 774 |
| linux s390x manywheel | 525 | 292 |
| windows x86 wheel | 8414 | 1128 |
| windows x86 libtorch-debug | 1020 | 387 |
| windows arm64 wheel | 554 | 325 |
| windows arm64 libtorch-debug | 209 | 242 |
| macos arm64 wheel | 270 | 270 |

All YAMLs ship with the standard `# @generated DO NOT EDIT MANUALLY` header and the regenerate-and-diff lint check enforces that the templates and the on-disk YAMLs stay in sync.

Job names in the GitHub UI are preserved via per-matrix-cell `name: ${{ matrix.build_name }}-build`, so external references (HUD, required-status-checks) keep matching `manywheel-py3_10-cuda12_6-build`-style names.

## Test plan

- [ ] `ciflow/binaries_wheel/*` tag push triggers all eight workflows with the expected matrix cell counts.
- [ ] lint workflow-checks job passes (`generate_ci_workflows.py` produces a clean diff).
- [ ] Adding a CUDA version to `CUDA_ARCHES` + running `regenerate.sh` adds new matrix entries to all generated workflows.

Authored with Claude.
Pull Request resolved: pytorch#181586
Approved by: https://github.com/malfet
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ch#181599)

Replace the docker-in-docker dance in the matrix-driven Linux binary
workflows with GitHub Actions' native `container:` directive. Each
matrix-cell job now starts directly inside the build container — the
existing .ci/* shell scripts read the same env vars (PYTORCH_ROOT,
PYTORCH_FINAL_PACKAGE_DIR, BINARY_ENV_FILE, ...) and run unchanged.

_binary-build-linux.yml and _binary-test-linux.yml are converted in
place: `runs-on: <runner>` + `container: image: <image>:<tag>`. The
CUDA test job adds `--gpus all -e NVIDIA_DRIVER_CAPABILITIES=...` via
container.options. _binary-test-rocm-linux.yml and
_binary-test-xpu-linux.yml get the same treatment with their device
passthrough flags.

s390x carve-out: the s390x runners are self-hosted, only register
with the bare `linux.s390x` label, and lack a host-level docker CLI
compatible with GHA's container directive (they use podman). Two new
reusables, _binary-build-linux-s390x.yml and
_binary-test-linux-s390x.yml, hold the legacy `docker run`-from-step
flow for s390x; the template routes s390x to those and everything
else to the new container-based reusables.

Build scripts in .ci/* are unchanged.

Authored with Claude.
Pull Request resolved: pytorch#181599
Approved by: https://github.com/huydhn
ghstack dependencies: pytorch#181586
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…rch#182335)

## Summary

The Jinja refactor in pytorch#181586 collapsed the linux binary build workflows into a single matrix-driven job and dropped the per-config ROCm timeout that pytorch#179596 had set, so x86 ROCm manywheel builds regressed from `timeout-minutes: 420` to `common.timeout_minutes` (240).

Make the timeout per-matrix-entry: `420` for ROCm, otherwise the per-OS default (`common.timeout_minutes` for x86, `420` for aarch64/s390x). Pass `${{ matrix.timeout_minutes }}` into `_binary-build-linux.yml`.

Net effect:
- ROCm x86: 240 -> 420 (restores pytorch#179596)
- CUDA / CPU / XPU x86: stay 240
- aarch64, s390x: stay 420

## Test plan

- [ ] Regenerated workflow renders cleanly: each matrix entry in `generated-linux-binary-manywheel-nightly.yml` has a `timeout_minutes` field; the job-level `timeout-minutes` reads from `${{ matrix.timeout_minutes }}`.
- [ ] Aarch64 / s390x generated workflows show `timeout_minutes: 420` on every entry (no behavior change).
- [ ] Nightly ROCm manywheel builds no longer hit the 240-minute cap.

Authored with Claude.

Pull Request resolved: pytorch#182335
Approved by: https://github.com/huydhn
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…repair) (pytorch#182409)

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via pytorch#181586 (and follow-ups pytorch#181599, pytorch#182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.
Pull Request resolved: pytorch#182409
Approved by: https://github.com/seemethere, https://github.com/huydhn
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
…orch#181586)

## Summary

Refactor the linux + windows jinja templates to follow the slim pattern introduced for macOS in pytorch#181153: each template emits a single matrix-driven `build` / `test` / `upload` job whose `strategy.matrix.include` list is unrolled at template-generation time from the configs supplied by `generate_binary_build_matrix.py`.

Adding a new Python or CUDA / ROCm version is now a one-line edit to `FULL_PYTHON_VERSIONS` / `CUDA_ARCHES` / `ROCM_ARCHES` in `.github/scripts/generate_binary_build_matrix.py`, followed by a `.github/regenerate.sh` run.

## Templates touched

- `linux_binary_build_workflow.yml.j2` (4698 -> 1417 generated lines for x86)
  one matrix-driven `manywheel-build` job; `manywheel-test` for cpu/cuda; separate `manywheel-test-rocm` and `manywheel-test-xpu` matrix jobs that delegate to new reusable workflows so the rocm-/xpu-specific setup stays out of the main yaml.
- `windows_binary_build_workflow.yml.j2` (~8400 -> ~1100 generated lines for x86 wheel)
  one matrix-driven `wheel-build` / `wheel-test` / `wheel-upload` chain; arm64 keeps its `bootstrap_*.bat` steps in the same template path, selected via `{%- if os == "windows-arm64" %}`.
- `macos_binary_build_workflow.yml.j2` unchanged (already slim from pytorch#181153).

## New reusable workflows

- `.github/workflows/_binary-test-rocm-linux.yml`
- `.github/workflows/_binary-test-xpu-linux.yml`

Both replicate the legacy inline ROCm / XPU test logic (setup-rocm / setup-xpu, ECR docker pull, test-pytorch-binary), but as `uses:`-able workflows so the slim main template stays small.

## Generated outputs

| Workflow | Before | After |
|---|---:|---:|
| linux x86 manywheel | 4698 | 1417 |
| linux aarch64 manywheel | 2085 | 774 |
| linux s390x manywheel | 525 | 292 |
| windows x86 wheel | 8414 | 1128 |
| windows x86 libtorch-debug | 1020 | 387 |
| windows arm64 wheel | 554 | 325 |
| windows arm64 libtorch-debug | 209 | 242 |
| macos arm64 wheel | 270 | 270 |

All YAMLs ship with the standard `# @generated DO NOT EDIT MANUALLY` header and the regenerate-and-diff lint check enforces that the templates and the on-disk YAMLs stay in sync.

Job names in the GitHub UI are preserved via per-matrix-cell `name: ${{ matrix.build_name }}-build`, so external references (HUD, required-status-checks) keep matching `manywheel-py3_10-cuda12_6-build`-style names.

## Test plan

- [ ] `ciflow/binaries_wheel/*` tag push triggers all eight workflows with the expected matrix cell counts.
- [ ] lint workflow-checks job passes (`generate_ci_workflows.py` produces a clean diff).
- [ ] Adding a CUDA version to `CUDA_ARCHES` + running `regenerate.sh` adds new matrix entries to all generated workflows.

Authored with Claude.
Pull Request resolved: pytorch#181586
Approved by: https://github.com/malfet
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…ch#181599)

Replace the docker-in-docker dance in the matrix-driven Linux binary
workflows with GitHub Actions' native `container:` directive. Each
matrix-cell job now starts directly inside the build container — the
existing .ci/* shell scripts read the same env vars (PYTORCH_ROOT,
PYTORCH_FINAL_PACKAGE_DIR, BINARY_ENV_FILE, ...) and run unchanged.

_binary-build-linux.yml and _binary-test-linux.yml are converted in
place: `runs-on: <runner>` + `container: image: <image>:<tag>`. The
CUDA test job adds `--gpus all -e NVIDIA_DRIVER_CAPABILITIES=...` via
container.options. _binary-test-rocm-linux.yml and
_binary-test-xpu-linux.yml get the same treatment with their device
passthrough flags.

s390x carve-out: the s390x runners are self-hosted, only register
with the bare `linux.s390x` label, and lack a host-level docker CLI
compatible with GHA's container directive (they use podman). Two new
reusables, _binary-build-linux-s390x.yml and
_binary-test-linux-s390x.yml, hold the legacy `docker run`-from-step
flow for s390x; the template routes s390x to those and everything
else to the new container-based reusables.

Build scripts in .ci/* are unchanged.

Authored with Claude.
Pull Request resolved: pytorch#181599
Approved by: https://github.com/huydhn
ghstack dependencies: pytorch#181586
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…rch#182335)

## Summary

The Jinja refactor in pytorch#181586 collapsed the linux binary build workflows into a single matrix-driven job and dropped the per-config ROCm timeout that pytorch#179596 had set, so x86 ROCm manywheel builds regressed from `timeout-minutes: 420` to `common.timeout_minutes` (240).

Make the timeout per-matrix-entry: `420` for ROCm, otherwise the per-OS default (`common.timeout_minutes` for x86, `420` for aarch64/s390x). Pass `${{ matrix.timeout_minutes }}` into `_binary-build-linux.yml`.

Net effect:
- ROCm x86: 240 -> 420 (restores pytorch#179596)
- CUDA / CPU / XPU x86: stay 240
- aarch64, s390x: stay 420

## Test plan

- [ ] Regenerated workflow renders cleanly: each matrix entry in `generated-linux-binary-manywheel-nightly.yml` has a `timeout_minutes` field; the job-level `timeout-minutes` reads from `${{ matrix.timeout_minutes }}`.
- [ ] Aarch64 / s390x generated workflows show `timeout_minutes: 420` on every entry (no behavior change).
- [ ] Nightly ROCm manywheel builds no longer hit the 240-minute cap.

Authored with Claude.

Pull Request resolved: pytorch#182335
Approved by: https://github.com/huydhn
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…repair) (pytorch#182409)

Split the monolithic .ci/manywheel/build_cuda.sh and the duplicated
sections of build_cpu.sh / build_common.sh into focused, reusable
scripts:

- build_env_setup.sh    GPU/toolchain environment setup (CUDA, ROCm, XPU)
- build_install_deps.sh shared build-time dependency install
- build_wheel.sh        the actual wheel build (python -m build)
- repair_wheel.sh       auditwheel-style repair using the `wheel` python
                        package (unpack/pack/tags), bundling aarch64
                        BLAS/LAPACK/ACL when needed

Drops build_cuda.sh (its logic is now in build_env_setup.sh +
build_wheel.sh) and trims x86/aarch64-specific branches out of
build_cpu.sh / build_common.sh. The legacy entry point .ci/manywheel/build.sh
now dispatches x86/aarch64 cuda/cpu through the new chain
(set_desired_python -> build_env_setup -> build_install_deps -> build_wheel
-> repair_wheel) and keeps rocm/xpu/cpu-s390x on the legacy build_*.sh
helpers.

Also drops obsolete numpy version pins in .ci/pytorch/run_tests.sh.

The matching workflow / Jinja-template rework that originally lived in
this branch is no longer needed -- the matrix-driven binary workflows
already landed via pytorch#181586 (and follow-ups pytorch#181599, pytorch#182018), so the
new scripts plug into the existing _binary-build-linux.yml.

Authored with Claude.
Pull Request resolved: pytorch#182409
Approved by: https://github.com/seemethere, https://github.com/huydhn
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 Trigger all binary build and upload jobs on the PR Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants