Skip to content

[BE] Build all XPU wheels on a single runner - #188136

Closed
chuanqi129 wants to merge 1 commit into
pytorch:mainfrom
chuanqi129:xpu-unified-wheel-build
Closed

chuanqi129 wants to merge 1 commit into
pytorch:mainfrom
chuanqi129:xpu-unified-wheel-build

Conversation

@chuanqi129

@chuanqi129 chuanqi129 commented Jun 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Extend the unified single-runner wheel build pattern (from #184045 for CUDA and #183931 for CPU) to XPU nightly wheel builds.

  • Instead of spawning 8 separate runners (one per Python version), a single manywheel-xpu-build job loops over all CPython versions sequentially, reusing build/ across iterations
  • After the first full build, only libtorch_python + _C are recompiled per interpreter via the cmake.py cache invalidation
  • XPU build failure is isolated from CPU/CUDA tests (manywheel-test does NOT depend on XPU build)
  • Unified XPU job gets 420-minute timeout to accommodate all Python versions sequentially

Dependency chain

manywheel-xpu-build  -->  manywheel-test-xpu  -->  manywheel-upload
                                                       ^
manywheel-cpu-build  \                                 |
manywheel-cuda-*     --> manywheel-test  ---------------+
manywheel-build (ROCm) --> manywheel-test-rocm ---------+

Test Plan

Regenerated workflow via:

python .github/scripts/generate_ci_workflows.py

Verified:

  • manywheel-xpu-build job generated with correct container, env, and artifact upload steps for all 8 Python versions
  • XPU entries removed from manywheel-build matrix (ROCm-only now)
  • manywheel-test-xpu depends on manywheel-xpu-build
  • manywheel-test does NOT depend on XPU (isolation preserved)
  • manywheel-upload includes manywheel-xpu-build in its needs
  • Other workflows (aarch64, s390x, macOS, Windows) unchanged

cc @gujinghui @PenghuiCheng @XiaobingSuper @jianyuh @jgong5 @mingfeima @sanchitintel @ashokei @jingxu10 @min-jean-cho @yanbing-j @Guobing-Chen @Xia-Weiwen @snadampal

@chuanqi129
chuanqi129 requested a review from a team as a code owner June 25, 2026 06:12
@pytorch-bot

pytorch-bot Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 11 Unclassified Failures

As of commit 2ae6280 with merge base c9fded8 (image):

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

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

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Jun 25, 2026
@chuanqi129 chuanqi129 added the ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR label Jun 25, 2026
@huydhn
huydhn requested a review from atalman June 25, 2026 06:18
@chuanqi129
chuanqi129 marked this pull request as draft June 25, 2026 14:37
@chuanqi129

Copy link
Copy Markdown
Collaborator Author

Current it will timeout, need to figure out it

@pytorch-bot pytorch-bot Bot added the module: mkldnn Related to Intel IDEEP or oneDNN (a.k.a. mkldnn) integration label Jul 1, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions Bot added the Stale label Aug 30, 2026
Add XPU to the unified wheel build path so all Python versions are built
sequentially on one runner, reusing build/ across iterations. This matches
the existing CPU/CUDA unified build pattern.

The ExternalProject for oneDNN XPU (xpu_mkldnn_proj) is expensive (~1h24m)
and would be re-cloned and rebuilt on every cmake reconfigure triggered by
Python version switches. FindMKLDNN.cmake now detects an existing build and
skips ExternalProject_Add on subsequent iterations.

Template changes:
- Add 'xpu' to unified_arch_types
- XPU build gets 420-minute timeout (vs default 240)
- XPU test jobs use _binary-test-xpu-linux.yml (separate from standard tests)
- Per-group upload so XPU does not block CPU/CUDA uploads

Test Plan:

CI on this PR will exercise the unified XPU build with all Python versions
on a single runner:
```
git push origin xpu-unified-wheel-build
```

Co-authored-by: AI assistant (Claude)
@chuanqi129

Copy link
Copy Markdown
Collaborator Author

Close it due to #195699

@chuanqi129 chuanqi129 closed this Sep 14, 2026
pytorchmergebot pushed a commit that referenced this pull request Sep 16, 2026
Take over #188136.

Builds all Linux XPU manywheel variants in one job, reusing ABI-independent C++/SYCL artifacts across Python versions while rebuilding Python-bound artifacts per interpreter.

## Before vs after

Comparing the eight XPU matrix builds from [#195438 run 33729050328](https://github.com/pytorch/pytorch/actions/runs/33729050328) with the unified build from [this PR, run 34123506914](https://github.com/pytorch/pytorch/actions/runs/34123506914):

### Linux XPU build runner-minutes

| Before (per-Python matrix, 8 jobs) | After (1 unified job) | Delta |
|---|---:|---:|
| 8 x ~78m = **623m** ([matrix jobs](https://github.com/pytorch/pytorch/actions/runs/33729050328)) | **139m** ([unified job](https://github.com/pytorch/pytorch/actions/runs/34123506914/job/101746866663)) | **-78%** |

This saves approximately **484 runner-minutes per XPU manywheel build**.

### Per-Python build breakdown

- First Python (cp310): **~74m** from a clean build.
- Following seven Pythons (cp311 through cp315t): **~7m each** on average.
- The unified job produced all eight XPU wheel artifacts successfully.

The first build establishes the shared XPU backend. Subsequent interpreters reuse the SYCL kernel objects and device link, rebuilding only Python-ABI-bound components.

### Fix for SYCL reuse

The earlier PATH-only tool pin did not prevent scikit-build-core from selecting the importable CMake/Ninja packages in each Python environment. The final implementation explicitly sets `CMAKE_EXECUTABLE` and passes the shared Ninja path through `CMAKE_ARGS`, keeping CMake's generated SYCL depfile commands stable across the loop.

Local Python 3.10 then Python 3.11 XPU builds confirmed **zero SYCL object recompilations** and **zero XPU device relinks** on the second build.

> AI-assisted drafting; CI measurements and implementation reviewed by the PR author.

Pull Request resolved: #195699
Approved by: https://github.com/chuanqi129, https://github.com/atalman

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR module: mkldnn Related to Intel IDEEP or oneDNN (a.k.a. mkldnn) integration open source Stale topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants