Skip to content

Add RISC-V smoke test on QEMU#19399

Open
luhenry wants to merge 9 commits into
pytorch:mainfrom
riseproject-dev:riscv-testing
Open

Add RISC-V smoke test on QEMU#19399
luhenry wants to merge 9 commits into
pytorch:mainfrom
riseproject-dev:riscv-testing

Conversation

@luhenry
Copy link
Copy Markdown

@luhenry luhenry commented May 8, 2026

Summary

Implements Phase 1 of the RISC-V Support RFC: cross-compile executor_runner for riscv64-linux-gnu, run a small BundledProgram under qemu-user-static on a x86_64 runner, and assert the standard "Test_result: PASS" marker that the portable executor_runner already emits via the bundled-IO comparison path (examples/portable/executor_runner/executor_runner.cpp:646 1).

The riscv64-linux preset mirrors arm-ethosu-linux. The only deviation is glibc instead of musl to avoid the MUSL_TOOLCHAIN_ROOT tarball setup.

The reusable _test_riscv.yml workflow is is triggered via pull.yml on every pull request.

Test plan

Ran locally, and integration to CI for automated testing.

cc @GregoryComer @digantdesai @cbilgin @psiddh @AdrianLundell @rascani @mergennachin

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 8, 2026

🔗 Helpful Links

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

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:

❌ 2 New Failures, 1 Unrelated Failure

As of commit 6fbf6d7 with merge base 9889c7c (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

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

@luhenry luhenry changed the title Add RISC-V Phase 1 smoke test on QEMU Add RISC-V smoke test on QEMU May 8, 2026
Comment thread .github/workflows/_test_riscv.yml Outdated
luhenry added 2 commits May 9, 2026 01:18
Implements Phase 1 of the RISC-V Support RFC (pytorch#18991):
cross-compile executor_runner for riscv64-linux-gnu, run a small
BundledProgram under qemu-user-static on a stock x86_64 GitHub runner,
and assert the standard "Test_result: PASS" marker that the portable
executor_runner already emits via the bundled-IO comparison path
(examples/portable/executor_runner/executor_runner.cpp:646).

The riscv64-linux preset mirrors arm-ethosu-linux: same Linux
cross-compile shape, same standard executor_runner, same filesystem
.pte, same option set with EXECUTORCH_ENABLE_BUNDLE_IO added so the
runner self-checks. Single deviation is glibc-via-apt instead of musl
to avoid the MUSL_TOOLCHAIN_ROOT tarball setup. The reusable
_test_riscv.yml workflow is wired into pull.yml on every PR.
luhenry added 2 commits May 9, 2026 17:27
The error we would get on CI is:
```
/usr/bin/riscv64-linux-gnu-gcc --sysroot=/usr/riscv64-linux-gnu    -o CMakeFiles/cmTC_eb936.dir/testCCompiler.c.o -c /pytorch/executorch/cmake-out/CMakeFiles/CMakeScratch/TryCompile-o3upsB/testCCompiler.c
Linking C executable cmTC_eb936
/opt/conda/envs/py_3.10/lib/python3.10/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/cmTC_eb936.dir/link.txt --verbose=1
/usr/lib/gcc-cross/riscv64-linux-gnu/11/../../../../riscv64-linux-gnu/bin/ld: cannot find /usr/riscv64-linux-gnu/lib/libc.so.6 inside /usr/riscv64-linux-gnu
/usr/lib/gcc-cross/riscv64-linux-gnu/11/../../../../riscv64-linux-gnu/bin/ld: cannot find /usr/riscv64-linux-gnu/lib/libc_nonshared.a inside /usr/riscv64-linux-gnu
/usr/lib/gcc-cross/riscv64-linux-gnu/11/../../../../riscv64-linux-gnu/bin/ld: cannot find /usr/riscv64-linux-gnu/lib/ld-linux-riscv64-lp64d.so.1 inside /usr/riscv64-linux-gnu
collect2: error: ld returned 1 exit status
```
Comment thread .github/workflows/pull.yml Outdated
Comment thread examples/riscv/run.sh Outdated
Comment thread examples/riscv/run.sh Outdated
luhenry added 4 commits May 11, 2026 22:34
It is to not mark it as viable/strict to a release and pull request, until we can prove point its stability
It didn't need to be that complicated
@GregoryComer
Copy link
Copy Markdown
Member

Thanks, I just re-triggered CI.

Comment thread examples/riscv/README.md
Comment on lines +19 to +20
examples/riscv/setup.sh # apt: gcc-riscv64-linux-gnu, qemu-user-static
examples/riscv/run.sh # export, cross-compile, run under qemu-user
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.

nice

"""AOT export for the RISC-V Phase 1.0 smoke test.

Exports a trivial ``torch.add`` module to a BundledProgram (.bpte) that the
portable executor_runner can load on a riscv64 target and verify against the
Copy link
Copy Markdown
Contributor

@digantdesai digantdesai May 12, 2026

Choose a reason for hiding this comment

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

Nit, perhaps we should plan to add riscv32 support in the future, even if we don't add it now, and not assume march too tightly. I am thinking about embedded uscases.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Absolutely. I don’t have direct input on customers asking for it, but the current scripts can easily be extended to test on qemu-static-riscv32.

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.

Filed #19531 on the Embedded backlog to follow up on this. Will probably wait until @luhenry has paved the way a bit more with rv64. :)

@luhenry
Copy link
Copy Markdown
Author

luhenry commented May 12, 2026

I've got changes for enabling XNNPACK, mobilenetv2 and mobilebert at riseproject-dev/executorch@riscv-testing...riseproject-dev:executorch:riscv-testing-mobilenetv2 once this PR is merged. It's all incremental, other than needing to add the executorch-ubuntu-24.04-gcc14 image (which I can break out in a different PR as well).

@luhenry
Copy link
Copy Markdown
Author

luhenry commented May 12, 2026

I just submitted #19521 to add a executorch-ubuntu-24.04-gcc14 build image that's necessary to have a newer gcc version that supports RVV (aka vectorization) which is necessary for XNNPACK

@rascani rascani mentioned this pull request May 13, 2026
@rascani
Copy link
Copy Markdown
Contributor

rascani commented May 13, 2026

@luhenry - Can you fix up the lints? I think that is the last merge blocker.

@luhenry
Copy link
Copy Markdown
Author

luhenry commented May 13, 2026

@luhenry - Can you fix up the lints? I think that is the last merge blocker.

I ran lintrunner -a locally and committed the changes.

Also submitted #19521 in preparation of adding XNNPACK as a test case. XNNPACK requires GCC14+ for RVV (vector/simd extension).

@rascani
Copy link
Copy Markdown
Contributor

rascani commented May 13, 2026

lintrunner-mypy failure looks pre-existing.

@luhenry
Copy link
Copy Markdown
Author

luhenry commented May 13, 2026

lintrunner-mypy failure looks pre-existing.

They are in backends/arm/ files which this PR doesn’t touch, so my expectations is that it’s also on main

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants