Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/190887
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Unclassified FailureAs of commit 602f297 with merge base 7610a3a ( 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. |
|
|
|
Replaces #182278. |
|
cc @zxiiro @Skylion007 @ezyang I needed to close and reopen this PR because the stale "request changes" is blocking the merge bot from merging. |
This is used as part of the riseproject-dev out-of-tree CI [1] [2], to get us closer to having native builds of PyTorch on RISC-V. [1]: https://github.com/risepytorch-dev/pytorch [2]: https://github.com/pytorch/pytorch/blob/01bcbb4c83936f38c54a35abcef28a052bc25f83/.github/allowlist.yml#L40
8d958b7 to
346fcf0
Compare
|
@pytorchmergebot merge |
Merge failedReason: Approvers from one of the following sets are needed:
|
| if [[ "$(uname -m)" == "riscv64" ]]; then | ||
| # Rust's riscv64 arch is riscv64gc | ||
| ARCH=riscv64gc | ||
| # sccache-dist is not available on riscv64, so we only install sccache |
There was a problem hiding this comment.
We add scache-dist support for aarch, we should try to upstream this. It actually was a pretty simple PR. We actually build from source and enabled it with a quick patch before. Should add an upstream PR for RISCV: mozilla/sccache#2668
There was a problem hiding this comment.
I'll get that done in mozilla/sccache following same steps as mozilla/sccache#2668 with 1 as well. Would you be ok merging this PR before we land the sccache-dist support upstream? There currently is no use of sccache-dist on riscv64 as pytorch/pytorch doesn't build riscv64 and the downstream that builds it 2 doesn't depend on it.
I have a strong track record of working to minimize the diff for riscv64 for PyTorch so please be assured I'll work on getting upstream support done for sccache and come back here when it's done and released.
There was a problem hiding this comment.
|
@claude review this PR |
|
Claude finished @Skylion007's task in 2m 20s —— View job PR Review: #190887 — Add native build image for linux-riscv64One-sentence summary: This adds a native (QEMU-emulated) Full review detailsSummaryConfig-only change for out-of-tree RISC-V CI. No production code paths are touched; the native image tag is intentionally not wired into Security
Code Quality
Notes (not blocking)
RecommendationApprove — config-only, arch-gated, no impact on other platforms. Please confirm the trust boundary of the |
|
linux-jammy-py3.10-clang18-asan / test (default, 5, 18, lf-l-x86iavx512-16-128) is a spurious failure. Every other tests that have to do with platforms that may have been impacted by these changes (aarch64 mostly) are green. |
| fi | ||
|
|
||
| if [[ "$(uname -m)" == "riscv64" ]]; then | ||
| valgrind="" # it's not available on riscv64 yet |
There was a problem hiding this comment.
It actually is available on riscv64, but it's very recent. Not sure if it needs a PPA to backport to Ubuntu
There was a problem hiding this comment.
It's available starting Ubuntu 26.04 on riscv64: https://packages.ubuntu.com/resolute/valgrind. Once we bump to Ubuntu 26.04 (which will bring both GCC 15 and valgrind) we can remove these two workarounds.
|
@pytorchmergebot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
@zxiiro @Skylion007 could you please re-run https://github.com/pytorch/pytorch/actions/runs/30107072884/job/89542635561?pr=190887, the failure isn't related to the changes here. Thank you! 🙏 |
|
@zxiiro looking through https://github.com/pytorch/pytorch/actions/workflows/docker-builds.yml, it doesn't even build EDIT: |
|
@pytorchmergebot merge -i |
|
|
|
@pytorchmergebot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: pull / linux-jammy-cuda13.2-cudnn9-py3.10-clang18 / build Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
This is used as part of the riseproject-dev out-of-tree CI [1] [2], to get us closer to having native builds of PyTorch on RISC-V. [1]: https://github.com/risepytorch-dev/pytorch [2]: https://github.com/pytorch/pytorch/blob/01bcbb4c83936f38c54a35abcef28a052bc25f83/.github/allowlist.yml#L40 Pull Request resolved: pytorch#190887 Approved by: https://github.com/zxiiro, https://github.com/Skylion007
This is used as part of the riseproject-dev out-of-tree CI [1] [2], to get us closer to having native builds of PyTorch on RISC-V. [1]: https://github.com/risepytorch-dev/pytorch [2]: https://github.com/pytorch/pytorch/blob/01bcbb4c83936f38c54a35abcef28a052bc25f83/.github/allowlist.yml#L40 Pull Request resolved: pytorch#190887 Approved by: https://github.com/zxiiro, https://github.com/Skylion007
…rements
With the routing fixed, the riscv64 cross job reaches the build and stops at
`python -m build`: the crossenv is provisioned with `setuptools pyyaml
typing_extensions wheel`, which was enough for `setup.py bdist_wheel` but not for
the scikit-build-core front end and backend. Run 32955566963 ends at
/opt/riscv-cross-env/cross/bin/python3: No module named build
Install the missing pieces into the crossenv. What goes where follows from what
crossenv actually is: its `cross` interpreter is the host CPython with sysconfig
patched to report the target's values, not a riscv64 binary -- the error above is
an x86_64 process raising a Python error. So pure-Python build tooling (build,
scikit-build-core, packaging, six) installs into the cross environment and runs
there natively, and it has to be reachable from that interpreter specifically:
driving the build from the host environment would hand the backend the host
sysconfig and produce a host-tagged wheel. cmake and ninja stay where they are,
on the host, because they are executed rather than imported; installing them into
the cross environment would fetch riscv64 wheels the host cannot run.
numpy is the exception that needs a target wheel, and PyPI has none for riscv64.
The RISE project index does, and it is already a trusted host here -- pytorch#190887
wired it into the native riscv64 image the same way. 1.26.4 is chosen on two
counts: it matches the Python 3.12 pin in .ci/docker/requirements-ci.txt, and it
is the newest numpy published there under a plain linux_riscv64 tag, so it does
not depend on crossenv resolving manylinux glibc tags for the target. The pin is
load-bearing in a second way: with an extra index pip resolves the highest
version across both, and every newer numpy exists on PyPI without a riscv64
wheel, so leaving it unpinned would silently cross-build numpy from an sdist.
Provisioning belongs in the image rather than in this script, and moving it to
.ci/docker/ubuntu-cross-riscv/Dockerfile is the intended end state. It is
deliberately not done here: the job has been red since 2025-10 and there is
almost certainly more breakage past this point, while any change under .ci/docker
rehashes the directory and rebuilds every CI image. Doing that once, when the
whole path is known green, is cheaper than doing it per iteration.
Note that numpy may still not end up enabled. It satisfies the build-requires
check, which `build` performs through importlib.metadata rather than by importing
(build/_util.py), but FindPython's NumPy component discovers its include
directory by running `import numpy; numpy.get_include()`, and a riscv64 extension
module cannot be imported on an x86_64 host. FindPython swallows that in a bare
`except: pass`, so the expected outcome is a "NumPy could not be found" warning
from Dependencies.cmake and USE_NUMPY off -- no worse than the status quo. If
numpy is wanted for real, the follow-up is to set Python_NumPy_INCLUDE_DIR
directly instead of letting FindPython probe.
This commit was authored with the assistance of an AI coding assistant.
Test Plan:
Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.
The previous run on this branch
(https://github.com/pytorch/pytorch/actions/runs/32955566963) established the
starting point -- the guard now resolves and the crossenv activates:
```
+ [[ linux-noble-riscv64-py3.12-gcc14-cross-build == *riscv64*cross* ]]
+ source /opt/riscv-cross-env/bin/activate
+ export CMAKE_CROSSCOMPILING=TRUE
```
Confirmed the RISE project index actually serves the wheel this pins, via the
simple repository API:
```
curl -sS https://pypi.riseproject.dev/simple/numpy/ \
| grep -o 'numpy-[^<]*cp312[^<]*\.whl' | sort -u
```
which lists numpy-1.26.4-cp312-cp312-linux_riscv64.whl among 16 cp312 riscv64
wheels; everything from 2.3.1 onward is published only under
manylinux_2_38/manylinux_2_39 tags. The same query against the index root shows
it carries numpy, pyyaml, ninja and cmake but not build, scikit-build-core,
packaging or six, which is why PyPI stays the primary index and this is an
--extra-index-url rather than an --index-url.
Checked that PIP_EXTRA_INDEX_URL is not already in effect for this image, so the
flag is not redundant: .ci/docker/build.sh sets it only for the native
pytorch-linux-noble-riscv64-py3.12-gcc14 tag, ubuntu-cross-riscv/Dockerfile
declares no matching ARG, and no PIP_* variable appears in the container
environment dumped by the run above.
Lint:
```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
…rements
With the routing fixed, the riscv64 cross job reaches the build and stops at
`python -m build`: the crossenv is provisioned with `setuptools pyyaml
typing_extensions wheel`, which was enough for `setup.py bdist_wheel` but not for
the scikit-build-core front end and backend. Run 32955566963 ends at
/opt/riscv-cross-env/cross/bin/python3: No module named build
Install the missing pieces into the crossenv. What goes where follows from what
crossenv actually is: its `cross` interpreter is the host CPython with sysconfig
patched to report the target's values, not a riscv64 binary -- the error above is
an x86_64 process raising a Python error. So pure-Python build tooling (build,
scikit-build-core, packaging, six) installs into the cross environment and runs
there natively, and it has to be reachable from that interpreter specifically:
driving the build from the host environment would hand the backend the host
sysconfig and produce a host-tagged wheel. cmake and ninja stay where they are,
on the host, because they are executed rather than imported; installing them into
the cross environment would fetch riscv64 wheels the host cannot run.
The install has to sit after the chown loop rather than beside the other exports.
The crossenv is root-owned in the image while the container runs as jenkins, so
until `sudo chown -R jenkins /opt/riscv-cross-env` has run the cross interpreter
cannot read `cross/pyvenv.cfg` and dies during startup, before `site` is
imported. Nothing else in the script makes that dependency visible -- the
existing `python -m build` call is far enough down that it never noticed -- so it
is called out in a comment.
numpy is the exception that needs a target wheel, and PyPI has none for riscv64.
The RISE project index does, and it is already a trusted host here -- pytorch#190887
wired it into the native riscv64 image the same way. 1.26.4 is chosen on two
counts: it matches the Python 3.12 pin in .ci/docker/requirements-ci.txt, and it
is the newest numpy published there under a plain linux_riscv64 tag, so it does
not depend on crossenv resolving manylinux glibc tags for the target. The pin is
load-bearing in a second way: with an extra index pip resolves the highest
version across both, and every newer numpy exists on PyPI without a riscv64
wheel, so leaving it unpinned would silently cross-build numpy from an sdist.
Provisioning belongs in the image rather than in this script, and moving it to
.ci/docker/ubuntu-cross-riscv/Dockerfile is the intended end state. It is
deliberately not done here: the job has been red since 2025-10 and there is
almost certainly more breakage past this point, while any change under .ci/docker
rehashes the directory and rebuilds every CI image. Doing that once, when the
whole path is known green, is cheaper than doing it per iteration.
Note that numpy may still not end up enabled. It satisfies the build-requires
check, which `build` performs through importlib.metadata rather than by importing
(build/_util.py), but FindPython's NumPy component discovers its include
directory by running `import numpy; numpy.get_include()`, and a riscv64 extension
module cannot be imported on an x86_64 host. FindPython swallows that in a bare
`except: pass`, so the expected outcome is a "NumPy could not be found" warning
from Dependencies.cmake and USE_NUMPY off -- no worse than the status quo. If
numpy is wanted for real, the follow-up is to set Python_NumPy_INCLUDE_DIR
directly instead of letting FindPython probe.
This commit was authored with the assistance of an AI coding assistant.
Test Plan:
Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.
Two runs on this branch informed this change.
32955566963 established the starting point -- the guard from the previous commit
resolves, the crossenv activates, and the build stops on the missing front end:
```
+ [[ linux-noble-riscv64-py3.12-gcc14-cross-build == *riscv64*cross* ]]
+ source /opt/riscv-cross-env/bin/activate
+ export CMAKE_CROSSCOMPILING=TRUE
...
+ python -m build --wheel --no-isolation
/opt/riscv-cross-env/cross/bin/python3: No module named build
```
32971278636 ran this install from the wrong place, before the chown, and is what
established the ownership constraint above:
```
Fatal Python error: init_import_site: Failed to import the site module
PermissionError: [Errno 13] Permission denied: '/opt/riscv-cross-env/cross/pyvenv.cfg'
```
Confirmed the RISE project index actually serves the wheel this pins, via the
simple repository API:
```
curl -sS https://pypi.riseproject.dev/simple/numpy/ \
| grep -o 'numpy-[^<]*cp312[^<]*\.whl' | sort -u
```
which lists numpy-1.26.4-cp312-cp312-linux_riscv64.whl among 16 cp312 riscv64
wheels; everything from 2.3.1 onward is published only under
manylinux_2_38/manylinux_2_39 tags. The same query against the index root shows
it carries numpy, pyyaml, ninja and cmake but not build, scikit-build-core,
packaging or six, which is why PyPI stays the primary index and this is an
--extra-index-url rather than an --index-url.
Checked that PIP_EXTRA_INDEX_URL is not already in effect for this image, so the
flag is not redundant: .ci/docker/build.sh sets it only for the native
pytorch-linux-noble-riscv64-py3.12-gcc14 tag, ubuntu-cross-riscv/Dockerfile
declares no matching ARG, and no PIP_* variable appears in the container
environment dumped by those runs.
Lint:
```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
The riscv64 cross build has not taken its own code path since pytorch#187821. That PR renamed the docker image to pytorch-linux-noble-riscv64-py3.12-gcc14-cross-build and narrowed the guards from *riscv* to *riscv*cross*, but the guards in .ci/docker/build.sh test the image name while the ones in .ci/pytorch/build.sh test BUILD_ENVIRONMENT -- and only the image name gained the "cross" marker. BUILD_ENVIRONMENT stayed linux-noble-riscv64-py3.12-gcc14, so `[[ "$BUILD_ENVIRONMENT" == *riscv64*cross* ]]` has been false ever since. Everything in that block is skipped as a result: the crossenv at /opt/riscv-cross-env is never activated, so the build runs against the host interpreter; CMAKE_CROSSCOMPILING, CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR are never exported, so CMake never enters cross mode even though CC/CXX point at the riscv64 toolchain; and SLEEF_TARGET_EXEC_USE_QEMU and the workspace chown are missed too. pytorch#190887 later added an `elif *riscv64*` arm for the new native image, which is the branch this job has been taking. Aligning BUILD_ENVIRONMENT with the image name is the smaller of the two possible fixes and matches the intent of pytorch#187821. Widening the guards back to *riscv64* would work for this job but would pull the native image, which is genuinely named linux-noble-riscv64-py3.12-gcc14, onto the cross path -- and that path exits 1 when /opt/riscv-cross-env is absent. The string is only consumed as $BUILD_ENVIRONMENT and as the build artifact name, so renaming it is contained; no other pattern in .ci/pytorch/build.sh matches the added "-cross-build". This commit was authored with the assistance of an AI coding assistant. Test Plan: The job is opt-in, so this needs a ciflow/riscv64 run to verify. It has been red since 2025-10 and the last run predates both pytorch#190887 and the scikit-build-core migration, so this is expected to uncover further breakage rather than turn the job green on its own -- in particular the crossenv is provisioned with `setuptools pyyaml typing_extensions wheel` only, while the build now invokes `python -m build --wheel --no-isolation`. Fixing that needs to be informed by a real run, since crossenv splits host and target environments and build backends belong in the host one. Root cause confirmed from the last run's log (https://github.com/pytorch/pytorch/actions/runs/28817304405), which shows the guard evaluating false: ``` + [[ linux-noble-riscv64-py3.12-gcc14 == *riscv64*cross* ]] + [[ linux-noble-riscv64-py3.12-gcc14 == *vulkan* ]] ``` Checked that no other BUILD_ENVIRONMENT pattern in the build script starts matching once "-cross-build" is appended: ``` grep -on 'BUILD_ENVIRONMENT" [!=]= \*[^]]*\*' .ci/pytorch/build.sh \ | sed 's/.*== //;s/.*!= //' | sort -u ``` yields *aarch64* *clang* *-clang*-asan* *client* *cuda* *cuda13* *-debug* *-full-debug* *full-debug* *libtorch* *riscv64* *riscv64*cross* *rocm* *-tsan* *vulkan* *xla* *xpu*, of which only the two riscv64 patterns match, both intentionally. Lint: ``` lintrunner --paths-cmd='git diff --name-only origin/viable/strict' ```
…rements
With the routing fixed, the riscv64 cross job reaches the build and stops at
`python -m build`: the crossenv is provisioned with `setuptools pyyaml
typing_extensions wheel`, which was enough for `setup.py bdist_wheel` but not for
the scikit-build-core front end and backend. Run 32955566963 ends at
/opt/riscv-cross-env/cross/bin/python3: No module named build
Install the missing pieces into the crossenv. What goes where follows from what
crossenv actually is: its `cross` interpreter is the host CPython with sysconfig
patched to report the target's values, not a riscv64 binary -- the error above is
an x86_64 process raising a Python error. So pure-Python build tooling (build,
scikit-build-core, packaging, six) installs into the cross environment and runs
there natively, and it has to be reachable from that interpreter specifically:
driving the build from the host environment would hand the backend the host
sysconfig and produce a host-tagged wheel. cmake and ninja stay where they are,
on the host, because they are executed rather than imported; installing them into
the cross environment would fetch riscv64 wheels the host cannot run.
The install has to sit after the chown loop rather than beside the other exports.
The crossenv is root-owned in the image while the container runs as jenkins, so
until `sudo chown -R jenkins /opt/riscv-cross-env` has run the cross interpreter
cannot read `cross/pyvenv.cfg` and dies during startup, before `site` is
imported. Nothing else in the script makes that dependency visible -- the
existing `python -m build` call is far enough down that it never noticed -- so it
is called out in a comment.
numpy is the exception that needs a target wheel, and PyPI has none for riscv64.
The RISE project index does, and it is already a trusted host here -- pytorch#190887
wired it into the native riscv64 image the same way. 1.26.4 is chosen on two
counts: it matches the Python 3.12 pin in .ci/docker/requirements-ci.txt, and it
is the newest numpy published there under a plain linux_riscv64 tag, so it does
not depend on crossenv resolving manylinux glibc tags for the target. The pin is
load-bearing in a second way: with an extra index pip resolves the highest
version across both, and every newer numpy exists on PyPI without a riscv64
wheel, so leaving it unpinned would silently cross-build numpy from an sdist.
Provisioning belongs in the image rather than in this script, and moving it to
.ci/docker/ubuntu-cross-riscv/Dockerfile is the intended end state. It is
deliberately not done here: the job has been red since 2025-10 and there is
almost certainly more breakage past this point, while any change under .ci/docker
rehashes the directory and rebuilds every CI image. Doing that once, when the
whole path is known green, is cheaper than doing it per iteration.
Note that numpy may still not end up enabled. It satisfies the build-requires
check, which `build` performs through importlib.metadata rather than by importing
(build/_util.py), but FindPython's NumPy component discovers its include
directory by running `import numpy; numpy.get_include()`, and a riscv64 extension
module cannot be imported on an x86_64 host. FindPython swallows that in a bare
`except: pass`, so the expected outcome is a "NumPy could not be found" warning
from Dependencies.cmake and USE_NUMPY off -- no worse than the status quo. If
numpy is wanted for real, the follow-up is to set Python_NumPy_INCLUDE_DIR
directly instead of letting FindPython probe.
This commit was authored with the assistance of an AI coding assistant.
Test Plan:
Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.
Two runs on this branch informed this change.
32955566963 established the starting point -- the guard from the previous commit
resolves, the crossenv activates, and the build stops on the missing front end:
```
+ [[ linux-noble-riscv64-py3.12-gcc14-cross-build == *riscv64*cross* ]]
+ source /opt/riscv-cross-env/bin/activate
+ export CMAKE_CROSSCOMPILING=TRUE
...
+ python -m build --wheel --no-isolation
/opt/riscv-cross-env/cross/bin/python3: No module named build
```
32971278636 ran this install from the wrong place, before the chown, and is what
established the ownership constraint above:
```
Fatal Python error: init_import_site: Failed to import the site module
PermissionError: [Errno 13] Permission denied: '/opt/riscv-cross-env/cross/pyvenv.cfg'
```
Confirmed the RISE project index actually serves the wheel this pins, via the
simple repository API:
```
curl -sS https://pypi.riseproject.dev/simple/numpy/ \
| grep -o 'numpy-[^<]*cp312[^<]*\.whl' | sort -u
```
which lists numpy-1.26.4-cp312-cp312-linux_riscv64.whl among 16 cp312 riscv64
wheels; everything from 2.3.1 onward is published only under
manylinux_2_38/manylinux_2_39 tags. The same query against the index root shows
it carries numpy, pyyaml, ninja and cmake but not build, scikit-build-core,
packaging or six, which is why PyPI stays the primary index and this is an
--extra-index-url rather than an --index-url.
Checked that PIP_EXTRA_INDEX_URL is not already in effect for this image, so the
flag is not redundant: .ci/docker/build.sh sets it only for the native
pytorch-linux-noble-riscv64-py3.12-gcc14 tag, ubuntu-cross-riscv/Dockerfile
declares no matching ARG, and no PIP_* variable appears in the container
environment dumped by those runs.
Lint:
```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
The riscv64 cross build has not taken its own code path since pytorch#187821. That PR renamed the docker image to pytorch-linux-noble-riscv64-py3.12-gcc14-cross-build and narrowed the guards from *riscv* to *riscv*cross*, but the guards in .ci/docker/build.sh test the image name while the ones in .ci/pytorch/build.sh test BUILD_ENVIRONMENT -- and only the image name gained the "cross" marker. BUILD_ENVIRONMENT stayed linux-noble-riscv64-py3.12-gcc14, so `[[ "$BUILD_ENVIRONMENT" == *riscv64*cross* ]]` has been false ever since. Everything in that block is skipped as a result: the crossenv at /opt/riscv-cross-env is never activated, so the build runs against the host interpreter; CMAKE_CROSSCOMPILING, CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR are never exported, so CMake never enters cross mode even though CC/CXX point at the riscv64 toolchain; and SLEEF_TARGET_EXEC_USE_QEMU and the workspace chown are missed too. pytorch#190887 later added an `elif *riscv64*` arm for the new native image, which is the branch this job has been taking. Aligning BUILD_ENVIRONMENT with the image name is the smaller of the two possible fixes and matches the intent of pytorch#187821. Widening the guards back to *riscv64* would work for this job but would pull the native image, which is genuinely named linux-noble-riscv64-py3.12-gcc14, onto the cross path -- and that path exits 1 when /opt/riscv-cross-env is absent. The string is only consumed as $BUILD_ENVIRONMENT and as the build artifact name, so renaming it is contained; no other pattern in .ci/pytorch/build.sh matches the added "-cross-build". This commit was authored with the assistance of an AI coding assistant. Test Plan: The job is opt-in, so this needs a ciflow/riscv64 run to verify. It has been red since 2025-10 and the last run predates both pytorch#190887 and the scikit-build-core migration, so this is expected to uncover further breakage rather than turn the job green on its own -- in particular the crossenv is provisioned with `setuptools pyyaml typing_extensions wheel` only, while the build now invokes `python -m build --wheel --no-isolation`. Fixing that needs to be informed by a real run, since crossenv splits host and target environments and build backends belong in the host one. Root cause confirmed from the last run's log (https://github.com/pytorch/pytorch/actions/runs/28817304405), which shows the guard evaluating false: ``` + [[ linux-noble-riscv64-py3.12-gcc14 == *riscv64*cross* ]] + [[ linux-noble-riscv64-py3.12-gcc14 == *vulkan* ]] ``` Checked that no other BUILD_ENVIRONMENT pattern in the build script starts matching once "-cross-build" is appended: ``` grep -on 'BUILD_ENVIRONMENT" [!=]= \*[^]]*\*' .ci/pytorch/build.sh \ | sed 's/.*== //;s/.*!= //' | sort -u ``` yields *aarch64* *clang* *-clang*-asan* *client* *cuda* *cuda13* *-debug* *-full-debug* *full-debug* *libtorch* *riscv64* *riscv64*cross* *rocm* *-tsan* *vulkan* *xla* *xpu*, of which only the two riscv64 patterns match, both intentionally. Lint: ``` lintrunner --paths-cmd='git diff --name-only origin/viable/strict' ```
…rements
With the routing fixed, the riscv64 cross job reaches the build and stops at
`python -m build`: the crossenv is provisioned with `setuptools pyyaml
typing_extensions wheel`, which was enough for `setup.py bdist_wheel` but not for
the scikit-build-core front end and backend. Run 32955566963 ends at
/opt/riscv-cross-env/cross/bin/python3: No module named build
Install the missing pieces into the crossenv. What goes where follows from what
crossenv actually is: its `cross` interpreter is the host CPython with sysconfig
patched to report the target's values, not a riscv64 binary -- the error above is
an x86_64 process raising a Python error. So pure-Python build tooling (build,
scikit-build-core, packaging, six) installs into the cross environment and runs
there natively, and it has to be reachable from that interpreter specifically:
driving the build from the host environment would hand the backend the host
sysconfig and produce a host-tagged wheel. cmake and ninja stay where they are,
on the host, because they are executed rather than imported; installing them into
the cross environment would fetch riscv64 wheels the host cannot run.
The install has to sit after the chown loop rather than beside the other exports.
The crossenv is root-owned in the image while the container runs as jenkins, so
until `sudo chown -R jenkins /opt/riscv-cross-env` has run the cross interpreter
cannot read `cross/pyvenv.cfg` and dies during startup, before `site` is
imported. Nothing else in the script makes that dependency visible -- the
existing `python -m build` call is far enough down that it never noticed -- so it
is called out in a comment.
numpy is the exception that needs a target wheel, and PyPI has none for riscv64.
The RISE project index does, and it is already a trusted host here -- pytorch#190887
wired it into the native riscv64 image the same way. 1.26.4 is chosen on two
counts: it matches the Python 3.12 pin in .ci/docker/requirements-ci.txt, and it
is the newest numpy published there under a plain linux_riscv64 tag, so it does
not depend on crossenv resolving manylinux glibc tags for the target. The pin is
load-bearing in a second way: with an extra index pip resolves the highest
version across both, and every newer numpy exists on PyPI without a riscv64
wheel, so leaving it unpinned would silently cross-build numpy from an sdist.
Provisioning belongs in the image rather than in this script, and moving it to
.ci/docker/ubuntu-cross-riscv/Dockerfile is the intended end state. It is
deliberately not done here: the job has been red since 2025-10 and there is
almost certainly more breakage past this point, while any change under .ci/docker
rehashes the directory and rebuilds every CI image. Doing that once, when the
whole path is known green, is cheaper than doing it per iteration.
Note that numpy may still not end up enabled. It satisfies the build-requires
check, which `build` performs through importlib.metadata rather than by importing
(build/_util.py), but FindPython's NumPy component discovers its include
directory by running `import numpy; numpy.get_include()`, and a riscv64 extension
module cannot be imported on an x86_64 host. FindPython swallows that in a bare
`except: pass`, so the expected outcome is a "NumPy could not be found" warning
from Dependencies.cmake and USE_NUMPY off -- no worse than the status quo. If
numpy is wanted for real, the follow-up is to set Python_NumPy_INCLUDE_DIR
directly instead of letting FindPython probe.
This commit was authored with the assistance of an AI coding assistant.
Test Plan:
Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.
Two runs on this branch informed this change.
32955566963 established the starting point -- the guard from the previous commit
resolves, the crossenv activates, and the build stops on the missing front end:
```
+ [[ linux-noble-riscv64-py3.12-gcc14-cross-build == *riscv64*cross* ]]
+ source /opt/riscv-cross-env/bin/activate
+ export CMAKE_CROSSCOMPILING=TRUE
...
+ python -m build --wheel --no-isolation
/opt/riscv-cross-env/cross/bin/python3: No module named build
```
32971278636 ran this install from the wrong place, before the chown, and is what
established the ownership constraint above:
```
Fatal Python error: init_import_site: Failed to import the site module
PermissionError: [Errno 13] Permission denied: '/opt/riscv-cross-env/cross/pyvenv.cfg'
```
Confirmed the RISE project index actually serves the wheel this pins, via the
simple repository API:
```
curl -sS https://pypi.riseproject.dev/simple/numpy/ \
| grep -o 'numpy-[^<]*cp312[^<]*\.whl' | sort -u
```
which lists numpy-1.26.4-cp312-cp312-linux_riscv64.whl among 16 cp312 riscv64
wheels; everything from 2.3.1 onward is published only under
manylinux_2_38/manylinux_2_39 tags. The same query against the index root shows
it carries numpy, pyyaml, ninja and cmake but not build, scikit-build-core,
packaging or six, which is why PyPI stays the primary index and this is an
--extra-index-url rather than an --index-url.
Checked that PIP_EXTRA_INDEX_URL is not already in effect for this image, so the
flag is not redundant: .ci/docker/build.sh sets it only for the native
pytorch-linux-noble-riscv64-py3.12-gcc14 tag, ubuntu-cross-riscv/Dockerfile
declares no matching ARG, and no PIP_* variable appears in the container
environment dumped by those runs.
Lint:
```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
The riscv64 cross build has not taken its own code path since pytorch#187821. That PR renamed the docker image to pytorch-linux-noble-riscv64-py3.12-gcc14-cross-build and narrowed the guards from *riscv* to *riscv*cross*, but the guards in .ci/docker/build.sh test the image name while the ones in .ci/pytorch/build.sh test BUILD_ENVIRONMENT -- and only the image name gained the "cross" marker. BUILD_ENVIRONMENT stayed linux-noble-riscv64-py3.12-gcc14, so `[[ "$BUILD_ENVIRONMENT" == *riscv64*cross* ]]` has been false ever since. Everything in that block is skipped as a result: the crossenv at /opt/riscv-cross-env is never activated, so the build runs against the host interpreter; CMAKE_CROSSCOMPILING, CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR are never exported, so CMake never enters cross mode even though CC/CXX point at the riscv64 toolchain; and SLEEF_TARGET_EXEC_USE_QEMU and the workspace chown are missed too. pytorch#190887 later added an `elif *riscv64*` arm for the new native image, which is the branch this job has been taking. Aligning BUILD_ENVIRONMENT with the image name is the smaller of the two possible fixes and matches the intent of pytorch#187821. Widening the guards back to *riscv64* would work for this job but would pull the native image, which is genuinely named linux-noble-riscv64-py3.12-gcc14, onto the cross path -- and that path exits 1 when /opt/riscv-cross-env is absent. The string is only consumed as $BUILD_ENVIRONMENT and as the build artifact name, so renaming it is contained; no other pattern in .ci/pytorch/build.sh matches the added "-cross-build". This commit was authored with the assistance of an AI coding assistant. Test Plan: The job is opt-in, so this needs a ciflow/riscv64 run to verify. It has been red since 2025-10 and the last run predates both pytorch#190887 and the scikit-build-core migration, so this is expected to uncover further breakage rather than turn the job green on its own -- in particular the crossenv is provisioned with `setuptools pyyaml typing_extensions wheel` only, while the build now invokes `python -m build --wheel --no-isolation`. Fixing that needs to be informed by a real run, since crossenv splits host and target environments and build backends belong in the host one. Root cause confirmed from the last run's log (https://github.com/pytorch/pytorch/actions/runs/28817304405), which shows the guard evaluating false: ``` + [[ linux-noble-riscv64-py3.12-gcc14 == *riscv64*cross* ]] + [[ linux-noble-riscv64-py3.12-gcc14 == *vulkan* ]] ``` Checked that no other BUILD_ENVIRONMENT pattern in the build script starts matching once "-cross-build" is appended: ``` grep -on 'BUILD_ENVIRONMENT" [!=]= \*[^]]*\*' .ci/pytorch/build.sh \ | sed 's/.*== //;s/.*!= //' | sort -u ``` yields *aarch64* *clang* *-clang*-asan* *client* *cuda* *cuda13* *-debug* *-full-debug* *full-debug* *libtorch* *riscv64* *riscv64*cross* *rocm* *-tsan* *vulkan* *xla* *xpu*, of which only the two riscv64 patterns match, both intentionally. Lint: ``` lintrunner --paths-cmd='git diff --name-only origin/viable/strict' ```
…rements
With the routing fixed, the riscv64 cross job reaches the build and stops at
`python -m build`: the crossenv is provisioned with `setuptools pyyaml
typing_extensions wheel`, which was enough for `setup.py bdist_wheel` but not for
the scikit-build-core front end and backend. Run 32955566963 ends at
/opt/riscv-cross-env/cross/bin/python3: No module named build
Install the missing pieces into the crossenv. What goes where follows from what
crossenv actually is: its `cross` interpreter is the host CPython with sysconfig
patched to report the target's values, not a riscv64 binary -- the error above is
an x86_64 process raising a Python error. So pure-Python build tooling (build,
scikit-build-core, packaging, six) installs into the cross environment and runs
there natively, and it has to be reachable from that interpreter specifically:
driving the build from the host environment would hand the backend the host
sysconfig and produce a host-tagged wheel. cmake and ninja stay where they are,
on the host, because they are executed rather than imported; installing them into
the cross environment would fetch riscv64 wheels the host cannot run.
The install has to sit after the chown loop rather than beside the other exports.
The crossenv is root-owned in the image while the container runs as jenkins, so
until `sudo chown -R jenkins /opt/riscv-cross-env` has run the cross interpreter
cannot read `cross/pyvenv.cfg` and dies during startup, before `site` is
imported. Nothing else in the script makes that dependency visible -- the
existing `python -m build` call is far enough down that it never noticed -- so it
is called out in a comment.
numpy is the exception that needs a target wheel, and PyPI has none for riscv64.
The RISE project index does, and it is already a trusted host here -- pytorch#190887
wired it into the native riscv64 image the same way. 1.26.4 is chosen on two
counts: it matches the Python 3.12 pin in .ci/docker/requirements-ci.txt, and it
is the newest numpy published there under a plain linux_riscv64 tag, so it does
not depend on crossenv resolving manylinux glibc tags for the target. The pin is
load-bearing in a second way: with an extra index pip resolves the highest
version across both, and every newer numpy exists on PyPI without a riscv64
wheel, so leaving it unpinned would silently cross-build numpy from an sdist.
Provisioning belongs in the image rather than in this script, and moving it to
.ci/docker/ubuntu-cross-riscv/Dockerfile is the intended end state. It is
deliberately not done here: the job has been red since 2025-10 and there is
almost certainly more breakage past this point, while any change under .ci/docker
rehashes the directory and rebuilds every CI image. Doing that once, when the
whole path is known green, is cheaper than doing it per iteration.
Note that numpy may still not end up enabled. It satisfies the build-requires
check, which `build` performs through importlib.metadata rather than by importing
(build/_util.py), but FindPython's NumPy component discovers its include
directory by running `import numpy; numpy.get_include()`, and a riscv64 extension
module cannot be imported on an x86_64 host. FindPython swallows that in a bare
`except: pass`, so the expected outcome is a "NumPy could not be found" warning
from Dependencies.cmake and USE_NUMPY off -- no worse than the status quo. If
numpy is wanted for real, the follow-up is to set Python_NumPy_INCLUDE_DIR
directly instead of letting FindPython probe.
This commit was authored with the assistance of an AI coding assistant.
Test Plan:
Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.
Two runs on this branch informed this change.
32955566963 established the starting point -- the guard from the previous commit
resolves, the crossenv activates, and the build stops on the missing front end:
```
+ [[ linux-noble-riscv64-py3.12-gcc14-cross-build == *riscv64*cross* ]]
+ source /opt/riscv-cross-env/bin/activate
+ export CMAKE_CROSSCOMPILING=TRUE
...
+ python -m build --wheel --no-isolation
/opt/riscv-cross-env/cross/bin/python3: No module named build
```
32971278636 ran this install from the wrong place, before the chown, and is what
established the ownership constraint above:
```
Fatal Python error: init_import_site: Failed to import the site module
PermissionError: [Errno 13] Permission denied: '/opt/riscv-cross-env/cross/pyvenv.cfg'
```
Confirmed the RISE project index actually serves the wheel this pins, via the
simple repository API:
```
curl -sS https://pypi.riseproject.dev/simple/numpy/ \
| grep -o 'numpy-[^<]*cp312[^<]*\.whl' | sort -u
```
which lists numpy-1.26.4-cp312-cp312-linux_riscv64.whl among 16 cp312 riscv64
wheels; everything from 2.3.1 onward is published only under
manylinux_2_38/manylinux_2_39 tags. The same query against the index root shows
it carries numpy, pyyaml, ninja and cmake but not build, scikit-build-core,
packaging or six, which is why PyPI stays the primary index and this is an
--extra-index-url rather than an --index-url.
Checked that PIP_EXTRA_INDEX_URL is not already in effect for this image, so the
flag is not redundant: .ci/docker/build.sh sets it only for the native
pytorch-linux-noble-riscv64-py3.12-gcc14 tag, ubuntu-cross-riscv/Dockerfile
declares no matching ARG, and no PIP_* variable appears in the container
environment dumped by those runs.
Lint:
```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
) The riscv64 cross build has not taken its own code path since #187821. That PR renamed the docker image to pytorch-linux-noble-riscv64-py3.12-gcc14-cross-build and narrowed the guards from *riscv* to *riscv*cross*, but the guards in .ci/docker/build.sh test the image name while the ones in .ci/pytorch/build.sh test BUILD_ENVIRONMENT -- and only the image name gained the "cross" marker. BUILD_ENVIRONMENT stayed linux-noble-riscv64-py3.12-gcc14, so `[[ "$BUILD_ENVIRONMENT" == *riscv64*cross* ]]` has been false ever since. Everything in that block is skipped as a result: the crossenv at /opt/riscv-cross-env is never activated, so the build runs against the host interpreter; CMAKE_CROSSCOMPILING, CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR are never exported, so CMake never enters cross mode even though CC/CXX point at the riscv64 toolchain; and SLEEF_TARGET_EXEC_USE_QEMU and the workspace chown are missed too. #190887 later added an `elif *riscv64*` arm for the new native image, which is the branch this job has been taking. Aligning BUILD_ENVIRONMENT with the image name is the smaller of the two possible fixes and matches the intent of #187821. Widening the guards back to *riscv64* would work for this job but would pull the native image, which is genuinely named linux-noble-riscv64-py3.12-gcc14, onto the cross path -- and that path exits 1 when /opt/riscv-cross-env is absent. The string is only consumed as $BUILD_ENVIRONMENT and as the build artifact name, so renaming it is contained; no other pattern in .ci/pytorch/build.sh matches the added "-cross-build". This commit was authored with the assistance of an AI coding assistant. Test Plan: The job is opt-in, so this needs a ciflow/riscv64 run to verify. It has been red since 2025-10 and the last run predates both #190887 and the scikit-build-core migration, so this is expected to uncover further breakage rather than turn the job green on its own -- in particular the crossenv is provisioned with `setuptools pyyaml typing_extensions wheel` only, while the build now invokes `python -m build --wheel --no-isolation`. Fixing that needs to be informed by a real run, since crossenv splits host and target environments and build backends belong in the host one. Root cause confirmed from the last run's log (https://github.com/pytorch/pytorch/actions/runs/28817304405), which shows the guard evaluating false: ``` + [[ linux-noble-riscv64-py3.12-gcc14 == *riscv64*cross* ]] + [[ linux-noble-riscv64-py3.12-gcc14 == *vulkan* ]] ``` Checked that no other BUILD_ENVIRONMENT pattern in the build script starts matching once "-cross-build" is appended: ``` grep -on 'BUILD_ENVIRONMENT" [!=]= \*[^]]*\*' .ci/pytorch/build.sh \ | sed 's/.*== //;s/.*!= //' | sort -u ``` yields *aarch64* *clang* *-clang*-asan* *client* *cuda* *cuda13* *-debug* *-full-debug* *full-debug* *libtorch* *riscv64* *riscv64*cross* *rocm* *-tsan* *vulkan* *xla* *xpu*, of which only the two riscv64 patterns match, both intentionally. Lint: ``` lintrunner --paths-cmd='git diff --name-only origin/viable/strict' ``` Pull Request resolved: #194880 Approved by: https://github.com/isuruf, https://github.com/atalman
This is used as part of the riseproject-dev out-of-tree CI 1 2, to get us closer to having native builds of PyTorch on RISC-V.