Skip to content

workflows: add build-torchaudio.yml for riscv64 wheels - #285

Open
luhenry wants to merge 2 commits into
mainfrom
torchaudio
Open

workflows: add build-torchaudio.yml for riscv64 wheels#285
luhenry wants to merge 2 commits into
mainfrom
torchaudio

Conversation

@luhenry

@luhenry luhenry commented Aug 20, 2026

Copy link
Copy Markdown
Member

What

Adds .github/workflows/build-torchaudio.yml to build riscv64 wheels for torchaudio and publish them to pypi.riseproject.dev.

Relates to #228

Approach

torchaudio 2.11 is in maintenance phase — a plain setuptools build whose only real dependency is torch itself. It ships no PyPI sdist, and its setup.py does import torch at module top with no [build-system] table. So this is a build-from-checkout workflow (like build-onnx.yml): checkout pytorch/audio at the tag, then cibuildwheel on the native ubuntu-24.04-riscv runner.

Key specifics:

  • --no-build-isolation (CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation") with torch preinstalled in CIBW_BEFORE_BUILD, since setup.py imports torch directly.
  • torch (+ its deps) resolve from our registry — public PyPI has no riscv64 torch wheel. --only-binary=:all: prevents any source fallback.
  • Built against torch 2.13.0+cpu; torchaudio 2.11 targets the stable libtorch ABI (TORCH_TARGET_VERSION) and is forward-compatible with any torch ≥ 2.11, pinning no torch version at runtime.
  • auditwheel repair excludes the torch-owned libs (libtorch*, libc10, libgomp, libgfortran, libopenblas) so libtorch is not vendored — the wheel is 1.2 MB, not ~130 MB. This mirrors how upstream torchaudio wheels are built.
  • Test step runs torchaudio's own test/smoke_test/smoke_test.py against the built wheel.
  • Matrix cp312/cp313/cp314/cp314t matches torch's riscv64 matrix on the registry.

Validation

Locally under QEMU (host is aarch64 + qemu-riscv64 binfmt) for cp313:

  • ✅ Wheel builds: torchaudio-2.11.0+cpu-cp313-cp313-manylinux_2_39_riscv64.whl (1.2 MB)
  • ✅ Runtime import + upstream smoke test pass (torch from registry, all subpackages import)

Draft to get CI build results across the full matrix. The publish job dry-runs off main, so it's safe on this PR branch.

🤖 Generated with Claude Code

luhenry and others added 2 commits August 20, 2026 14:14
torchaudio (github.com/pytorch/audio) is in maintenance phase: a plain
setuptools build whose only real dependency is torch itself. It ships no
PyPI sdist and its setup.py imports torch at module top with no
[build-system] table, so we build from an upstream checkout (like
build-onnx.yml) with cibuildwheel + --no-build-isolation.

The build installs torch from our registry (public PyPI has no riscv64
torch wheel), builds against its stable libtorch ABI (torchaudio 2.11 is
forward-compatible with any torch >=2.11), and excludes the torch-owned
shared libs from the auditwheel repair so libtorch is not vendored into
the wheel - yielding a 1.2 MB wheel instead of ~130 MB. Verified locally
under QEMU (build + upstream smoke test) for cp313.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Resolve the build/test torch to the latest on the registry rather than a
hardcoded 2.13.0+cpu pin. torchaudio 2.11 targets the stable libtorch ABI
and pins no torch at runtime, so any torch >=2.11 works.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@luhenry
luhenry marked this pull request as ready for review August 20, 2026 12:32
@luhenry
luhenry requested review from justeph and threexc August 20, 2026 12:37
@luhenry

luhenry commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

@justeph @threexc this should be ready to review. Thanks!

UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
UV_INDEX_STRATEGY: unsafe-best-match
UV_ONLY_BINARY: ':all:'
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64

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.

don't set this, see comment in #299

USE_CUDA=0
BUILD_VERSION=${{ env.TORCHAUDIO_VERSION }}
PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
CIBW_ENVIRONMENT_PASS_LINUX: PIP_EXTRA_INDEX_URL

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.

this line is redundant with the line just above

- uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
env:
CIBW_BUILD: "cp${{ matrix.python-version }}-manylinux_riscv64"
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}

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.

drop this

Comment on lines +32 to +34
UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
UV_INDEX_STRATEGY: unsafe-best-match
UV_ONLY_BINARY: ':all:'

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.

uv is not used, so this can be dropped

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants