Skip to content

[CI] Add native build image for linux-riscv64 - #182278

Closed
luhenry wants to merge 31 commits into
pytorch:mainfrom
riseproject-dev:native-riscv64-ci
Closed

luhenry wants to merge 31 commits into
pytorch:mainfrom
riseproject-dev:native-riscv64-ci

Conversation

@luhenry

@luhenry luhenry commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

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.

@luhenry
luhenry requested review from a team and jeffdaily as code owners May 4, 2026 10:53
@pytorch-bot

pytorch-bot Bot commented May 4, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

❌ 4 Awaiting Approval, 1 Cancelled Job, 28 Unclassified Failures

As of commit 3ea503e with merge base 0545bb2 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

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:

CANCELLED JOB - The following job was cancelled. Please retry:

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

@pytorch-bot pytorch-bot Bot added the release notes: releng release notes category label May 4, 2026
@luhenry

luhenry commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

cc @fffrog @malfet

@luhenry
luhenry force-pushed the native-riscv64-ci branch 2 times, most recently from a283afb to 4ce545c Compare May 4, 2026 22:18
@luhenry

luhenry commented May 4, 2026 •

Copy link
Copy Markdown
Contributor Author

I'm verifying that everything works as expected at https://github.com/riseproject-dev/pytorch/actions/workflows/linux-riscv64.yml?query=branch%3Abuild-and-test-on-riscv64.

Once this PR is integrated, I'll be able to run out-of-tree CI OOTB without any more changes in PyTorch since all the next necessary changes are in .github/ and we don't need to rely on carrying patches in pytorch/pytorch for that. Having this PR also allows to have a common-base between any downstream/out-of-tree that tries to build PyTorch on RISC-V.

luhenry added a commit to riseproject-dev/pytorch-ci that referenced this pull request May 5, 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.

There are some changes clearly unrelated to RISCV, and some of them create a differentiation across the builds without clear explanation why this is necessary (for example, build OpenBLAS from source for aarch64, but download it from deb for RISCV)

Comment thread .ci/docker/common/install_base.sh Resolved
Comment thread .ci/docker/common/install_cache.sh Resolved
@malfet malfet added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: risc-v All issues related to RISC-V architecture labels May 5, 2026
Comment thread .ci/docker/ubuntu-xpu/Dockerfile Resolved
Comment thread .ci/docker/common/install_base.sh Resolved
@luhenry

luhenry commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

There are some changes clearly unrelated to RISCV

I'll minimize to changes specific to RISC-V and split out anything in common code in different PRs.

some of them create a differentiation across the builds without clear explanation why this is necessary (for example, build OpenBLAS from source for aarch64, but download it from deb for RISCV)

On OpenBLAS specifically, I tried compiling OpenBLAS from source for riscv64 as well, but on QEMU it takes a few hours (on my local MacBook Pro, so should be faster on the linux.12xlarge on CI). Without building OpenBLAS from source, it consistently takes ~40 minutes on ubuntu-latest.

On sccache, same thing, it just takes a long time to build when the "official" release is just very handy. We can switch aarch64 to using the builds from https://github.com/mozilla/sccache/releases as well.

@luhenry
luhenry force-pushed the native-riscv64-ci branch from 4ce545c to e6b1322 Compare May 6, 2026 12:41
@luhenry

luhenry commented May 6, 2026 •

Copy link
Copy Markdown
Contributor Author

I verified the latest change work locally and produce an image that can be used to build PyTorch locally as well.

I am currently building the image on CI. It'll get picked up automatically by RISE out-of-tree CI whenever it's available. I'll link a build from it as soon as it's done.

I've also validated that the previous version of the change (ca96d73) works as expected. The failure is due to applying this patch, which will go away as soon as this PR is merged.

UPDATE: the image was built successfully on CI. I'm now testing it on the latest pytorch/pytorch@main commit

@luhenry

luhenry commented May 7, 2026 •

Copy link
Copy Markdown
Contributor Author

The failure we see in the build is due to a wrong removal. I've fixed that in 732ced3

Triggering another build of the image at https://github.com/riseproject-dev/pytorch/actions/runs/25507704785. Will update once I've a pytorch/pytorch@main run using that image.

UPDATE: the image was built successfully on CI, and it's working for pytorch/pytorch@main. The failure is due to needing to apply a patch that will naturally go away once this PR is merged.

@luhenry
luhenry requested a review from malfet May 8, 2026 23:06
@luhenry

luhenry commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

https://github.com/pytorch/pytorch/actions/runs/25507708100/job/75118572887?pr=182278#step:7:252

#7 [base  2/27] RUN echo 'APT::Sandbox::User "root";' | tee -a /etc/apt/apt.conf.d/10sandbox
#7 0.435 exec /bin/sh: exec format error

This clearly indicates that the "Setup QEMU" step didn't work as expected, which is confirmed by Setup QEMU > Extracting available platforms which returns:

linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4,linux/386

As opposed to a more complete list:

linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/loong64,linux/arm/v7,linux/arm/v6

@malfet @jordanconway what machines are these? Are they the lf runners? Are there any specific restrictions on these? Are the runners inside a container that may explain why they can't install QEMU?

@luhenry
luhenry force-pushed the native-riscv64-ci branch from 6cd6580 to 4abd299 Compare May 10, 2026 16:51
@luhenry

luhenry commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@malfet @Skylion007 @zxiiro I got the diff to much smaller as it's not reusing most all of the existing infrastructure. There is still no building of the image on PyTorch's infra but it's built and used as Out-of-Tree CI at https://github.com/riseproject-dev/pytorch-ci

luhenry added 4 commits July 13, 2026 15:36
…debinfo.py

tools/build_with_debinfo.py depends on using ninja. It's possible ninja is installed but not used when setting `USE_NINJA=0`
@luhenry

luhenry commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

I removed most if platform_machine != "riscv64" from .ci/docker/requirements-ci.txt, only numba and librosa are left (they depend on llvmlite which depends on the conda ecosystem to be available, work in progress [1]).

@malfet @zxiiro @Skylion007 I would love to have your review on that now, it's in a much much better place than it was even just a few weeks ago. There has been a loot of work going on in dependencies to get there. It's not finished, we will continue reducing the diff going forward, I hope all the evolution on that PR to reduce the diff is a sign of good faith 🙂

gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
Bumps lintrunner to 0.13.0. That enables builds on RISC-V with minimal diff. Derived from pytorch#182278.
Pull Request resolved: pytorch#187791
Approved by: https://github.com/huydhn
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
Bumps numpy to 1.26.4. That enables builds on RISC-V with minimal diff. Derived from pytorch#182278.
Pull Request resolved: pytorch#187792
Approved by: https://github.com/huydhn
luhenry added a commit to riseproject-dev/pytorch-ci that referenced this pull request Jul 15, 2026
.ci/manywheel/build.sh only recognizes GPU_ARCH_TYPE=cpu-riscv64 after
merging riseproject-dev/pytorch:manywheel-riscv64 (commit 1deab4c5ec6). The
docker-builds job already merges that branch to build the builder image, but
linux-riscv64-binary-manywheel only merged pytorch/pytorch#182278 (which
doesn't touch build.sh), so it ran against unpatched code and failed with
"Un-recognized GPU_ARCH_TYPE 'cpu-riscv64', exiting...".

Merge the same branch in this job too, matching docker-builds.
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
Bumps lintrunner to 0.13.0. That enables builds on RISC-V with minimal diff. Derived from pytorch#182278.
Pull Request resolved: pytorch#187791
Approved by: https://github.com/huydhn
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
Bumps numpy to 1.26.4. That enables builds on RISC-V with minimal diff. Derived from pytorch#182278.
Pull Request resolved: pytorch#187792
Approved by: https://github.com/huydhn
zxiiro
zxiiro previously approved these changes Jul 17, 2026
@zxiiro
zxiiro requested a review from atalman July 17, 2026 13:26
@yuzibo

yuzibo commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@malfet @zxiiro @Skylion007 I would love to have your review on that now, it's in a much much better place than it was even just a few weeks ago. There has been a loot of work going on in dependencies to get there. It's not finished, we will continue reducing the diff going forward, I hope all the evolution on that PR to reduce the diff is a sign of good faith 🙂

Yes, the PR will help the local Jenkins jobfor PyTorch CI on riscv64 also to troubleshoot issues caused by troublesome dependencies.

@luhenry

luhenry commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchmergebot merge

@pytorch-bot

pytorch-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

This PR has pending changes requested. Please address the comments and update the PR before merging.

@luhenry luhenry closed this Jul 23, 2026
@luhenry luhenry reopened this Jul 23, 2026
@pytorch-bot
pytorch-bot Bot dismissed zxiiro’s stale review July 23, 2026 13:16

This PR was reopened (likely due to being reverted), so your approval was removed. Please request another review.

@luhenry luhenry closed this Jul 23, 2026
@luhenry

luhenry commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Opening into a new pull request as @malfet's stale change request is blocking the bot from merging.

aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
Bumps lintrunner to 0.13.0. That enables builds on RISC-V with minimal diff. Derived from pytorch#182278.
Pull Request resolved: pytorch#187791
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
Bumps numpy to 1.26.4. That enables builds on RISC-V with minimal diff. Derived from pytorch#182278.
Pull Request resolved: pytorch#187792
Approved by: https://github.com/huydhn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/docker module: risc-v All issues related to RISC-V architecture no-runner-experiments Bypass Meta/LF runner determinator open source release notes: releng release notes category 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.

6 participants