Skip to content

[BE] Build all aarch64 + x86 CPU wheels on a single runner - #183931

Closed
malfet wants to merge 2 commits into
gh/malfet/905/basefrom
gh/malfet/905/head
Closed

malfet wants to merge 2 commits into
gh/malfet/905/basefrom
gh/malfet/905/head

Conversation

@malfet

@malfet malfet commented May 15, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Mirrors #181171 (macOS) for linux CPU: one job per gpu_arch_type (cpu and cpu-aarch64) loops over all CPython versions in DESIRED_PYTHONS and reuses build/ across iterations. libtorch_cpu (Python-ABI-free) is shared; only libtorch_python + _C are recompiled per interpreter, leveraging the cmake.py cache-invalidation fix from #181147.

Template's unified_arch_types = ['cpu', 'cpu-aarch64'] is the partition switch -- add more entries (e.g. cuda variants) to fold them into the same pattern. CUDA, ROCm, and XPU stay on the per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Authored with Claude.

Before vs after

Comparing nightly 2026-05-15 08:28 UTC (per-Python matrix) to PR run at 18:46 UTC (unified build):

Workflow Stage Before After Δ
linux-aarch64-binary-manywheel Build runner-minutes (linux.arm64.r7g.12xlarge.memory) 244 (6 × ~40m) 104 (1 × 104m) −57%
linux-aarch64-binary-manywheel Build wall-clock ~41m ~104m +2.5×
linux-binary-manywheel (x86) Build runner-minutes (linux.12xlarge.memory.ephemeral) 294 (6 × ~49m) 111 (1 × 111m) −62%
linux-binary-manywheel (x86) Build wall-clock ~49m ~111m +2.2×

TTS — full CPU pipeline (build → upload, aarch64)

Phase Nightly (before) PR (after)
Build starts 08:30:58 18:50:34
Build ends 09:12:35 (last) 20:34:47
Test starts 10:58:31 (queue ≈ 1h46m) 21:15:20 (queue ≈ 41m)
Test ends 11:06:10 (last) 21:24:40
Upload ends 11:08:41 (last) 21:27:53
Total TTS ~2h37m ~2h37m

~57–62% runner-minute reduction on the expensive build runners (~140m aarch64 / ~183m x86 saved per nightly). Build wall-clock ~2.2–2.5× longer, but end-to-end TTS unchanged on aarch64 because test queueing dominated under the old layout. x86 test+upload data pending the in-progress PR run.

Data: aarch64 nightly 25908164878, aarch64 PR 25935357837, x86 nightly 25908164859, x86 PR 25935357836.

[ghstack-poisoned]
@malfet
malfet requested a review from a team as a code owner May 15, 2026 17:38
@pytorch-bot pytorch-bot Bot added the release notes: releng release notes category label May 15, 2026
@pytorch-bot

pytorch-bot Bot commented May 15, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

❌ 1 Unclassified Failure

As of commit eee327f with merge base 9df9278 (image):

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

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

malfet added a commit that referenced this pull request May 15, 2026
Mirrors #181171 (macOS) for linux-aarch64 CPU: one `linux.arm64.r7g.12xlarge.memory` job loops over all CPython versions in `DESIRED_PYTHONS` and reuses `build/` across iterations. libtorch_cpu (Python-ABI-free) is shared; only libtorch_python + `_C` are recompiled per interpreter, leveraging the cmake.py cache-invalidation fix from #181147.

cuda-aarch64 keeps its existing per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Easy to extend later to (gpu_arch_type, desired_cuda) grouping for CUDA-aarch64 and x86 by adding more partitions to the template.

Authored with Claude.


ghstack-source-id: 0c35203
Pull-Request: #183931
[ghstack-poisoned]
@malfet malfet changed the title [BE] Build all aarch64 CPU wheels on a single runner [BE] Build all aarch64 + x86 CPU wheels on a single runner May 15, 2026
malfet added a commit that referenced this pull request May 15, 2026
Mirrors #181171 (macOS) for linux CPU: one job per gpu_arch_type (cpu and cpu-aarch64) loops over all CPython versions in `DESIRED_PYTHONS` and reuses `build/` across iterations. libtorch_cpu (Python-ABI-free) is shared; only libtorch_python + `_C` are recompiled per interpreter, leveraging the cmake.py cache-invalidation fix from #181147.

Template's `unified_arch_types = ['cpu', 'cpu-aarch64']` is the partition switch -- add more entries (e.g. cuda variants) to fold them into the same pattern. CUDA, ROCm, and XPU stay on the per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Authored with Claude.

ghstack-source-id: 618c3dd
Pull-Request: #183931
@malfet malfet added topic: not user facing topic category ciflow/binaries Trigger all binary build and upload jobs on the PR labels May 15, 2026

@huydhn huydhn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@malfet

malfet commented May 16, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge -f "Builds + tests 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

malfet added a commit that referenced this pull request May 16, 2026
Extends #183931 to CUDA: `unified_arch_types` now includes `cuda` and `cuda-aarch64`, and the template groups by `(gpu_arch_type, desired_cuda)` so each (arch, cuda) variant gets one build job that loops over all CPython versions. libtorch_cuda is Python-ABI-free and shared across iterations alongside libtorch_cpu.

Job names: `manywheel-cuda-cu126-build`, `manywheel-cuda-aarch64-cu130-build`, etc. CPU job names (`manywheel-cpu-build`, `manywheel-cpu-aarch64-build`) stay unchanged. Per-group env now also carries `GPU_ARCH_VERSION` and `PYTORCH_EXTRA_INSTALL_REQUIREMENTS` (constant within a group). `BUILD_NAME_SUFFIX` is derived from the first config's build_name instead of hardcoded so it picks up the cuda-version part automatically.

ROCm and XPU stay on the per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Authored with Claude.


ghstack-source-id: 881b0ae
Pull-Request: #184045
pytorchmergebot pushed a commit that referenced this pull request May 18, 2026
Extends #183931 to CUDA: `unified_arch_types` now includes `cuda` and `cuda-aarch64`, and the template groups by `(gpu_arch_type, desired_cuda)` so each (arch, cuda) variant gets one build job that loops over all CPython versions. libtorch_cuda is Python-ABI-free and shared across iterations alongside libtorch_cpu.

Job names: `manywheel-cuda-cu126-build`, `manywheel-cuda-aarch64-cu130-build`, etc. CPU job names (`manywheel-cpu-build`, `manywheel-cpu-aarch64-build`) stay unchanged. Per-group env now also carries `GPU_ARCH_VERSION` and `PYTORCH_EXTRA_INSTALL_REQUIREMENTS` (constant within a group). `BUILD_NAME_SUFFIX` is derived from the first config's build_name instead of hardcoded so it picks up the cuda-version part automatically.

ROCm and XPU stay on the per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Authored with Claude.

## Before vs after

Comparing 2026-05-17 nightly (per-Python CUDA matrix) to this PR's [aarch64 run 25974013813](https://github.com/pytorch/pytorch/actions/runs/25974013813) and [x86 run 25974013818](https://github.com/pytorch/pytorch/actions/runs/25974013818):

### CUDA build runner-minutes

Representative "before" links go to the **py3_10** matrix entry of each variant; the matrix had 5 more identically-shaped entries (py3_11..py3_14t).

| Arch | Variant | Before (per-Python matrix, 6 jobs) | After (1 unified job) | Δ |
|---|---|---:|---:|---:|
| linux-aarch64 | cu126 | 6 × ~78m = **468m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390578)) | **148m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905733)) | −68% |
| linux-aarch64 | cu130 | 6 × ~136m = **814m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390569)) | **203m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905740)) | −75% |
| linux-aarch64 | cu132 | 6 × ~140m = **841m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390541)) | **210m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905728)) | −75% |
| linux-aarch64 | **CUDA total** | **2123m** | **561m** | **−74%** |
| linux-x86 | cu126 | 6 × ~137m = **822m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382391975)) | **225m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906051)) | −73% |
| linux-x86 | cu130 | 6 × ~160m = **962m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382391995)) | **230m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906044)) | −76% |
| linux-x86 | cu132 | 6 × ~167m = **1004m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382392005)) | **237m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906050)) | −76% |
| linux-x86 | **CUDA total** | **2787m** | **692m** | **−75%** |

**~3.6k runner-minutes saved per nightly on CUDA builds alone** (~74% reduction), on top of the ~320m/nightly already saved on CPU by #183931.

### Per-iteration breakdown (aarch64 cu132 unified job)

- First Python: ~140m (from-scratch build, matches nightly's matrix entry duration)
- Subsequent 5 Pythons: 70m / 5 ≈ **~14m each** (libtorch_cuda reused, only libtorch_python + `_C` rebuilt)
- Confirms the cmake.py cross-Python cache invalidation works for CUDA the same as it does for CPU.

### Wall-clock (cu132, the slowest variant)

| Arch | Before (matrix max) | After (unified) | Δ |
|---|---:|---:|---:|
| linux-aarch64 | ~142m | ~210m | +1.5× |
| linux-x86 | ~167m | ~237m | +1.4× |

## Binary-size sanity check

Spot-checking py3_10 and py3_14t artifacts of both runs to confirm CUDA wheels are actually produced and not accidentally CPU-only:

| Arch | Variant | Nightly py3_10 | PR py3_10 | Nightly py3_14t | PR py3_14t |
|---|---|---:|---:|---:|---:|
| aarch64 | cu126 | 327.85 MB | **327.80 MB** | 327.88 MB | **327.82 MB** |
| aarch64 | cu130 | 515.26 MB | **515.19 MB** | 515.27 MB | **515.21 MB** |
| aarch64 | cu132 | 525.04 MB | **524.97 MB** | 525.13 MB | **525.00 MB** |
| x86 | cu126 | 841.74 MB | **841.74 MB** | 841.76 MB | **841.69 MB** |
| x86 | cu130 | 615.60 MB | **615.54 MB** | 615.61 MB | **615.56 MB** |
| x86 | cu132 | 624.16 MB | **624.09 MB** | 624.17 MB | **624.11 MB** |

All deltas are within **0.05 MB** (~0.01%) — well within normal build-timestamp/dep-version variance. The CUDA payload (libtorch_cuda, cuDNN, NCCL, cuSPARSELt, etc.) is intact in every unified-build wheel.

Within a single unified job, sizes across Pythons are nearly identical (within ~10 KB) — exactly the expected shape: only `_C.so` varies per interpreter, while the multi-hundred-MB `libtorch_cuda.so` is reused.

Data: aarch64 nightly [25985669026](https://github.com/pytorch/pytorch/actions/runs/25985669026), x86 nightly [25985669024](https://github.com/pytorch/pytorch/actions/runs/25985669024), aarch64 PR [25974013813](https://github.com/pytorch/pytorch/actions/runs/25974013813), x86 PR [25974013818](https://github.com/pytorch/pytorch/actions/runs/25974013818).

Pull Request resolved: #184045
Approved by: https://github.com/Skylion007
ghstack dependencies: #183931
@github-actions
github-actions Bot deleted the gh/malfet/905/head branch June 15, 2026 02:29
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…83931)

Mirrors pytorch#181171 (macOS) for linux CPU: one job per gpu_arch_type (cpu and cpu-aarch64) loops over all CPython versions in `DESIRED_PYTHONS` and reuses `build/` across iterations. libtorch_cpu (Python-ABI-free) is shared; only libtorch_python + `_C` are recompiled per interpreter, leveraging the cmake.py cache-invalidation fix from pytorch#181147.

Template's `unified_arch_types = ['cpu', 'cpu-aarch64']` is the partition switch -- add more entries (e.g. cuda variants) to fold them into the same pattern. CUDA, ROCm, and XPU stay on the per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Authored with Claude.

## Before vs after

Comparing nightly 2026-05-15 08:28 UTC (per-Python matrix) to PR run at 18:46 UTC (unified build):

| Workflow | Stage | Before | After | Δ |
|---|---|---:|---:|---:|
| linux-aarch64-binary-manywheel | Build runner-minutes (`linux.arm64.r7g.12xlarge.memory`) | **244** (6 × ~40m) | **104** (1 × 104m) | **−57%** |
| linux-aarch64-binary-manywheel | Build wall-clock | ~41m | ~104m | +2.5× |
| linux-binary-manywheel (x86) | Build runner-minutes (`linux.12xlarge.memory.ephemeral`) | **294** (6 × ~49m) | **111** (1 × 111m) | **−62%** |
| linux-binary-manywheel (x86) | Build wall-clock | ~49m | ~111m | +2.2× |

### TTS — full CPU pipeline (build → upload, aarch64)

| Phase | Nightly (before) | PR (after) |
|---|---|---|
| Build starts | 08:30:58 | 18:50:34 |
| Build ends | 09:12:35 (last) | 20:34:47 |
| Test starts | 10:58:31 (queue ≈ 1h46m) | 21:15:20 (queue ≈ 41m) |
| Test ends | 11:06:10 (last) | 21:24:40 |
| Upload ends | 11:08:41 (last) | 21:27:53 |
| **Total TTS** | **~2h37m** | **~2h37m** |

~57–62% runner-minute reduction on the expensive build runners (~140m aarch64 / ~183m x86 saved per nightly). Build wall-clock ~2.2–2.5× longer, but end-to-end TTS unchanged on aarch64 because test queueing dominated under the old layout. x86 test+upload data pending the in-progress PR run.

Data: aarch64 nightly [25908164878](https://github.com/pytorch/pytorch/actions/runs/25908164878), aarch64 PR [25935357837](https://github.com/pytorch/pytorch/actions/runs/25935357837), x86 nightly [25908164859](https://github.com/pytorch/pytorch/actions/runs/25908164859), x86 PR [25935357836](https://github.com/pytorch/pytorch/actions/runs/25935357836).

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

Extends pytorch#183931 to CUDA: `unified_arch_types` now includes `cuda` and `cuda-aarch64`, and the template groups by `(gpu_arch_type, desired_cuda)` so each (arch, cuda) variant gets one build job that loops over all CPython versions. libtorch_cuda is Python-ABI-free and shared across iterations alongside libtorch_cpu.

Job names: `manywheel-cuda-cu126-build`, `manywheel-cuda-aarch64-cu130-build`, etc. CPU job names (`manywheel-cpu-build`, `manywheel-cpu-aarch64-build`) stay unchanged. Per-group env now also carries `GPU_ARCH_VERSION` and `PYTORCH_EXTRA_INSTALL_REQUIREMENTS` (constant within a group). `BUILD_NAME_SUFFIX` is derived from the first config's build_name instead of hardcoded so it picks up the cuda-version part automatically.

ROCm and XPU stay on the per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Authored with Claude.

## Before vs after

Comparing 2026-05-17 nightly (per-Python CUDA matrix) to this PR's [aarch64 run 25974013813](https://github.com/pytorch/pytorch/actions/runs/25974013813) and [x86 run 25974013818](https://github.com/pytorch/pytorch/actions/runs/25974013818):

### CUDA build runner-minutes

Representative "before" links go to the **py3_10** matrix entry of each variant; the matrix had 5 more identically-shaped entries (py3_11..py3_14t).

| Arch | Variant | Before (per-Python matrix, 6 jobs) | After (1 unified job) | Δ |
|---|---|---:|---:|---:|
| linux-aarch64 | cu126 | 6 × ~78m = **468m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390578)) | **148m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905733)) | −68% |
| linux-aarch64 | cu130 | 6 × ~136m = **814m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390569)) | **203m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905740)) | −75% |
| linux-aarch64 | cu132 | 6 × ~140m = **841m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390541)) | **210m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905728)) | −75% |
| linux-aarch64 | **CUDA total** | **2123m** | **561m** | **−74%** |
| linux-x86 | cu126 | 6 × ~137m = **822m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382391975)) | **225m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906051)) | −73% |
| linux-x86 | cu130 | 6 × ~160m = **962m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382391995)) | **230m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906044)) | −76% |
| linux-x86 | cu132 | 6 × ~167m = **1004m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382392005)) | **237m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906050)) | −76% |
| linux-x86 | **CUDA total** | **2787m** | **692m** | **−75%** |

**~3.6k runner-minutes saved per nightly on CUDA builds alone** (~74% reduction), on top of the ~320m/nightly already saved on CPU by pytorch#183931.

### Per-iteration breakdown (aarch64 cu132 unified job)

- First Python: ~140m (from-scratch build, matches nightly's matrix entry duration)
- Subsequent 5 Pythons: 70m / 5 ≈ **~14m each** (libtorch_cuda reused, only libtorch_python + `_C` rebuilt)
- Confirms the cmake.py cross-Python cache invalidation works for CUDA the same as it does for CPU.

### Wall-clock (cu132, the slowest variant)

| Arch | Before (matrix max) | After (unified) | Δ |
|---|---:|---:|---:|
| linux-aarch64 | ~142m | ~210m | +1.5× |
| linux-x86 | ~167m | ~237m | +1.4× |

## Binary-size sanity check

Spot-checking py3_10 and py3_14t artifacts of both runs to confirm CUDA wheels are actually produced and not accidentally CPU-only:

| Arch | Variant | Nightly py3_10 | PR py3_10 | Nightly py3_14t | PR py3_14t |
|---|---|---:|---:|---:|---:|
| aarch64 | cu126 | 327.85 MB | **327.80 MB** | 327.88 MB | **327.82 MB** |
| aarch64 | cu130 | 515.26 MB | **515.19 MB** | 515.27 MB | **515.21 MB** |
| aarch64 | cu132 | 525.04 MB | **524.97 MB** | 525.13 MB | **525.00 MB** |
| x86 | cu126 | 841.74 MB | **841.74 MB** | 841.76 MB | **841.69 MB** |
| x86 | cu130 | 615.60 MB | **615.54 MB** | 615.61 MB | **615.56 MB** |
| x86 | cu132 | 624.16 MB | **624.09 MB** | 624.17 MB | **624.11 MB** |

All deltas are within **0.05 MB** (~0.01%) — well within normal build-timestamp/dep-version variance. The CUDA payload (libtorch_cuda, cuDNN, NCCL, cuSPARSELt, etc.) is intact in every unified-build wheel.

Within a single unified job, sizes across Pythons are nearly identical (within ~10 KB) — exactly the expected shape: only `_C.so` varies per interpreter, while the multi-hundred-MB `libtorch_cuda.so` is reused.

Data: aarch64 nightly [25985669026](https://github.com/pytorch/pytorch/actions/runs/25985669026), x86 nightly [25985669024](https://github.com/pytorch/pytorch/actions/runs/25985669024), aarch64 PR [25974013813](https://github.com/pytorch/pytorch/actions/runs/25974013813), x86 PR [25974013818](https://github.com/pytorch/pytorch/actions/runs/25974013818).

Pull Request resolved: pytorch#184045
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#183931
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…83931)

Mirrors pytorch#181171 (macOS) for linux CPU: one job per gpu_arch_type (cpu and cpu-aarch64) loops over all CPython versions in `DESIRED_PYTHONS` and reuses `build/` across iterations. libtorch_cpu (Python-ABI-free) is shared; only libtorch_python + `_C` are recompiled per interpreter, leveraging the cmake.py cache-invalidation fix from pytorch#181147.

Template's `unified_arch_types = ['cpu', 'cpu-aarch64']` is the partition switch -- add more entries (e.g. cuda variants) to fold them into the same pattern. CUDA, ROCm, and XPU stay on the per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Authored with Claude.

## Before vs after

Comparing nightly 2026-05-15 08:28 UTC (per-Python matrix) to PR run at 18:46 UTC (unified build):

| Workflow | Stage | Before | After | Δ |
|---|---|---:|---:|---:|
| linux-aarch64-binary-manywheel | Build runner-minutes (`linux.arm64.r7g.12xlarge.memory`) | **244** (6 × ~40m) | **104** (1 × 104m) | **−57%** |
| linux-aarch64-binary-manywheel | Build wall-clock | ~41m | ~104m | +2.5× |
| linux-binary-manywheel (x86) | Build runner-minutes (`linux.12xlarge.memory.ephemeral`) | **294** (6 × ~49m) | **111** (1 × 111m) | **−62%** |
| linux-binary-manywheel (x86) | Build wall-clock | ~49m | ~111m | +2.2× |

### TTS — full CPU pipeline (build → upload, aarch64)

| Phase | Nightly (before) | PR (after) |
|---|---|---|
| Build starts | 08:30:58 | 18:50:34 |
| Build ends | 09:12:35 (last) | 20:34:47 |
| Test starts | 10:58:31 (queue ≈ 1h46m) | 21:15:20 (queue ≈ 41m) |
| Test ends | 11:06:10 (last) | 21:24:40 |
| Upload ends | 11:08:41 (last) | 21:27:53 |
| **Total TTS** | **~2h37m** | **~2h37m** |

~57–62% runner-minute reduction on the expensive build runners (~140m aarch64 / ~183m x86 saved per nightly). Build wall-clock ~2.2–2.5× longer, but end-to-end TTS unchanged on aarch64 because test queueing dominated under the old layout. x86 test+upload data pending the in-progress PR run.

Data: aarch64 nightly [25908164878](https://github.com/pytorch/pytorch/actions/runs/25908164878), aarch64 PR [25935357837](https://github.com/pytorch/pytorch/actions/runs/25935357837), x86 nightly [25908164859](https://github.com/pytorch/pytorch/actions/runs/25908164859), x86 PR [25935357836](https://github.com/pytorch/pytorch/actions/runs/25935357836).

Pull Request resolved: pytorch#183931
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
…ch#184045)

Extends pytorch#183931 to CUDA: `unified_arch_types` now includes `cuda` and `cuda-aarch64`, and the template groups by `(gpu_arch_type, desired_cuda)` so each (arch, cuda) variant gets one build job that loops over all CPython versions. libtorch_cuda is Python-ABI-free and shared across iterations alongside libtorch_cpu.

Job names: `manywheel-cuda-cu126-build`, `manywheel-cuda-aarch64-cu130-build`, etc. CPU job names (`manywheel-cpu-build`, `manywheel-cpu-aarch64-build`) stay unchanged. Per-group env now also carries `GPU_ARCH_VERSION` and `PYTORCH_EXTRA_INSTALL_REQUIREMENTS` (constant within a group). `BUILD_NAME_SUFFIX` is derived from the first config's build_name instead of hardcoded so it picks up the cuda-version part automatically.

ROCm and XPU stay on the per-Python matrix; test+upload stay per-Python so failure on one Python only blocks that Python's upload.

Authored with Claude.

## Before vs after

Comparing 2026-05-17 nightly (per-Python CUDA matrix) to this PR's [aarch64 run 25974013813](https://github.com/pytorch/pytorch/actions/runs/25974013813) and [x86 run 25974013818](https://github.com/pytorch/pytorch/actions/runs/25974013818):

### CUDA build runner-minutes

Representative "before" links go to the **py3_10** matrix entry of each variant; the matrix had 5 more identically-shaped entries (py3_11..py3_14t).

| Arch | Variant | Before (per-Python matrix, 6 jobs) | After (1 unified job) | Δ |
|---|---|---:|---:|---:|
| linux-aarch64 | cu126 | 6 × ~78m = **468m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390578)) | **148m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905733)) | −68% |
| linux-aarch64 | cu130 | 6 × ~136m = **814m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390569)) | **203m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905740)) | −75% |
| linux-aarch64 | cu132 | 6 × ~140m = **841m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669026/job/76382390541)) | **210m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013813/job/76350905728)) | −75% |
| linux-aarch64 | **CUDA total** | **2123m** | **561m** | **−74%** |
| linux-x86 | cu126 | 6 × ~137m = **822m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382391975)) | **225m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906051)) | −73% |
| linux-x86 | cu130 | 6 × ~160m = **962m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382391995)) | **230m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906044)) | −76% |
| linux-x86 | cu132 | 6 × ~167m = **1004m** ([py3_10](https://github.com/pytorch/pytorch/actions/runs/25985669024/job/76382392005)) | **237m** ([job](https://github.com/pytorch/pytorch/actions/runs/25974013818/job/76350906050)) | −76% |
| linux-x86 | **CUDA total** | **2787m** | **692m** | **−75%** |

**~3.6k runner-minutes saved per nightly on CUDA builds alone** (~74% reduction), on top of the ~320m/nightly already saved on CPU by pytorch#183931.

### Per-iteration breakdown (aarch64 cu132 unified job)

- First Python: ~140m (from-scratch build, matches nightly's matrix entry duration)
- Subsequent 5 Pythons: 70m / 5 ≈ **~14m each** (libtorch_cuda reused, only libtorch_python + `_C` rebuilt)
- Confirms the cmake.py cross-Python cache invalidation works for CUDA the same as it does for CPU.

### Wall-clock (cu132, the slowest variant)

| Arch | Before (matrix max) | After (unified) | Δ |
|---|---:|---:|---:|
| linux-aarch64 | ~142m | ~210m | +1.5× |
| linux-x86 | ~167m | ~237m | +1.4× |

## Binary-size sanity check

Spot-checking py3_10 and py3_14t artifacts of both runs to confirm CUDA wheels are actually produced and not accidentally CPU-only:

| Arch | Variant | Nightly py3_10 | PR py3_10 | Nightly py3_14t | PR py3_14t |
|---|---|---:|---:|---:|---:|
| aarch64 | cu126 | 327.85 MB | **327.80 MB** | 327.88 MB | **327.82 MB** |
| aarch64 | cu130 | 515.26 MB | **515.19 MB** | 515.27 MB | **515.21 MB** |
| aarch64 | cu132 | 525.04 MB | **524.97 MB** | 525.13 MB | **525.00 MB** |
| x86 | cu126 | 841.74 MB | **841.74 MB** | 841.76 MB | **841.69 MB** |
| x86 | cu130 | 615.60 MB | **615.54 MB** | 615.61 MB | **615.56 MB** |
| x86 | cu132 | 624.16 MB | **624.09 MB** | 624.17 MB | **624.11 MB** |

All deltas are within **0.05 MB** (~0.01%) — well within normal build-timestamp/dep-version variance. The CUDA payload (libtorch_cuda, cuDNN, NCCL, cuSPARSELt, etc.) is intact in every unified-build wheel.

Within a single unified job, sizes across Pythons are nearly identical (within ~10 KB) — exactly the expected shape: only `_C.so` varies per interpreter, while the multi-hundred-MB `libtorch_cuda.so` is reused.

Data: aarch64 nightly [25985669026](https://github.com/pytorch/pytorch/actions/runs/25985669026), x86 nightly [25985669024](https://github.com/pytorch/pytorch/actions/runs/25985669024), aarch64 PR [25974013813](https://github.com/pytorch/pytorch/actions/runs/25974013813), x86 PR [25974013818](https://github.com/pytorch/pytorch/actions/runs/25974013818).

Pull Request resolved: pytorch#184045
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#183931
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 release notes: releng release notes category topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants