Skip to content

[ROCm][CI] Fix py3.15 ROCm manywheel numpy source build (pkg-config python3) - #189266

Closed
amdfaa wants to merge 2 commits into
pytorch:mainfrom
amdfaa:rocm-py315-numpy-pkgconfig
Closed

amdfaa wants to merge 2 commits into
pytorch:mainfrom
amdfaa:rocm-py315-numpy-pkgconfig

Conversation

@amdfaa

@amdfaa amdfaa commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Python 3.15 has no prebuilt numpy wheel on PyPI yet, so pip builds numpy from source for every arch. meson's Cython sanity check resolves the python3 pkg-config dependency to get Python include/link flags. The ROCm manylinux2_28-builder image ships the system Python 3.6 pkg-config file on the default search path, so pkg-config python3 returns Python 3.6 (-I/usr/include/python3.6m) and Cython aborts with #error Cython requires Python 3.8+.

CUDA/CPU/XPU manylinux images do not carry that system python3 pkg-config entry, so meson falls back to the correct interpreter and their py3.15 builds succeed. All ROCm builds for Python versions that ship a prebuilt numpy wheel (3.11-3.14) also succeed because numpy is never built from source there.

This shows up in two separate places, each fixed the same way (prepend the active interpreter's own pkgconfig directory, sysconfig LIBPC, to PKG_CONFIG_PATH before numpy is installed, so pkg-config python3 resolves to the interpreter being built for; no-op when numpy comes from a wheel):

  • Build stage (.ci/manywheel/build_install_deps.py): fixes manywheel-py3_15/py3_15t-rocm*-build.
  • Binary smoke-test stage (.ci/pytorch/binary_linux_test.sh): the smoke test runs a separate in-container script that re-installs numpy from source, so it hit the identical failure in manywheel-py3_15/py3_15t-rocm*-test (and flakily in a couple other rocm test shards) after the build was fixed.

Reference: original failing build job https://github.com/pytorch/pytorch/actions/runs/28734817308/job/85207010577 (numpy meson build, pkg-config --modversion python3 -> 3.6); failing smoke-test job https://github.com/pytorch/pytorch/actions/runs/28952344908/job/85981822513.

Test plan

Made with Cursor

Tracking issue: https://github.com/ROCm/frameworks-internal/issues/17233

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

… interpreter

Python 3.15 has no prebuilt numpy wheel on PyPI yet, so pip builds numpy
from source for every arch. During that source build meson's Cython sanity
check resolves the `python3` pkg-config dependency to obtain the Python
include/link flags. The ROCm manylinux image ships the system Python 3.6
pkg-config file on the default search path, so `pkg-config python3` returns
Python 3.6 (`/usr/include/python3.6m`) and Cython aborts with
"#error Cython requires Python 3.8+", failing the build.

CUDA/CPU/XPU manylinux images do not carry that system python3 pkg-config
entry, so meson falls back to the correct interpreter and their py3.15 builds
(and all ROCm builds for Python versions that have prebuilt numpy wheels,
i.e. 3.11-3.14) succeed.

Prepend the active interpreter's own pkgconfig directory (sysconfig LIBPC)
to PKG_CONFIG_PATH before installing build deps so `pkg-config python3`
resolves to the interpreter we are building for (3.15). This is a no-op for
Pythons whose numpy comes from a wheel (no source build) and harmless on the
non-ROCm images.

Test Plan:
- Nightly linux-binary-manywheel: manywheel-py3_15-rocm7_1-build /
  manywheel-py3_15-rocm7_2-build (and the py3_15t variants) previously failed
  at numpy source build; they should now build.
- Confirm py3.11-3.14 ROCm and CUDA/CPU/XPU builds remain green (unchanged
  behavior, wheel installs of numpy).

Made with Cursor
@amdfaa
amdfaa requested a review from a team as a code owner July 8, 2026 14:53
@pytorch-bot

pytorch-bot Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit b8e04c6 with merge base c24fd66 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Jul 8, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

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

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

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

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

@jithunnair-amd jithunnair-amd added the ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR label Jul 8, 2026
@janeyx99 janeyx99 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 8, 2026
…config python3)

PR pytorch#189266 fixed the py3.15 ROCm manywheel *build* by pointing pkg-config at the
build interpreter, but the binary *test* (Test PyTorch binary / smoke test) still
failed at the numpy install step. The smoke test runs a separate script
(`.ci/pytorch/binary_linux_test.sh`, executed inside the manylinux container) that
does `pip install -q numpy ...` in a fresh process, so the build-phase
`PKG_CONFIG_PATH` from `build_install_deps.py` does not carry over.

Root cause is identical: py3.15 has no prebuilt numpy wheel, so pip builds numpy
from source and meson's Cython sanity check resolves the `python3` pkg-config
dependency. The ROCm manylinux image ships the system Python 3.6 pkg-config file
on the default search path, so `pkg-config python3` returns Python 3.6
(`-I/usr/include/python3.6m`) and Cython aborts with
`sanity_check_for_cython.c: error: #error Cython requires Python 3.8+`, giving
`meson ... Compiler cython cannot compile programs` -> `metadata-generation-failed`.
This hit py3_15/py3_15t/py3_10/py3_14t rocm7_x test jobs.

Fix: mirror the build-phase helper in the generated smoke-test script. Before the
numpy pip install, prepend the active interpreter's own pkgconfig dir (its
`sysconfig` `LIBPC`) to `PKG_CONFIG_PATH` so `pkg-config python3` resolves to the
interpreter we are testing. It is a no-op for Pythons whose numpy comes from a
wheel (no source build) and harmless on CUDA/CPU/XPU images, which do not carry
the system `python3` pkg-config entry. The logic is inlined via a small `python`
one-liner rather than a shared module because the two callers live on either side
of a Python/bash boundary (Python build script vs. a bash-generated in-container
script); an inline mirror keeps the change local and readable.

Test Plan:

Verified the generated in-container script escapes correctly and prepends the
interpreter pkgconfig dir at runtime:

```
bash -x <generated ci_test_script.sh>
# numpy_libpc=<interpreter LIBPC>; export PKG_CONFIG_PATH=<LIBPC>:...
```

Shellcheck clean on the modified script:

```
shellcheck .ci/pytorch/binary_linux_test.sh
```

CI: re-approve `ciflow/binaries_wheel` on PR pytorch#189266 and confirm the previously
failing `manywheel-py3_15*-rocm7_x-test` (and py3_10/py3_14t) smoke jobs pass the
numpy install step on the new head SHA.

Made with Cursor
@pytorch-bot

pytorch-bot Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@jithunnair-amd jithunnair-amd added the ciflow/binaries Trigger all binary build and upload jobs on the PR label Jul 9, 2026
@amdfaa
amdfaa marked this pull request as draft July 9, 2026 16:54
@jithunnair-amd

Copy link
Copy Markdown
Collaborator

Closing in favor of #189722

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR ciflow/binaries Trigger all binary build and upload jobs on the PR module: rocm AMD GPU support for Pytorch open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants