diff --git a/.github/workflows/build-diffq.yml b/.github/workflows/build-diffq.yml new file mode 100644 index 000000000000..1d5b6cced636 --- /dev/null +++ b/.github/workflows/build-diffq.yml @@ -0,0 +1,110 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on: https://github.com/facebookresearch/diffq/blob/v0.2.4/.github/workflows/build.yml +name: Build diffq wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/diffq.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-diffq.yml' + - 'docs/packages/diffq.yaml' + push: + branches: [main] + paths: + - '.github/workflows/build-diffq.yml' + - 'docs/packages/diffq.yaml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: diffq + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + name: Build diffq ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + python: ["cp312", "cp313", "cp314", "cp314t"] + + env: + DIFFQ_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout diffq v${{ env.DIFFQ_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: facebookresearch/diffq + ref: v${{ env.DIFFQ_VERSION }} + persist-credentials: false + + - uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + only: ${{ matrix.python }}-manylinux_riscv64 + env: + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # diffq.bitpack is a plain Cython extension (no torch/CUDA headers at + # build time); torch is only a runtime import, needed for the tests. + CIBW_ENVIRONMENT: >- + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + PIP_ONLY_BINARY=Cython,numpy,torch + CIBW_TEST_SOURCES: diffq/tests + CIBW_TEST_REQUIRES: pytest torch + # diffq/tests lives inside the diffq package itself, so staging it + # alone leaves a diffq/ dir with no __init__.py in the test cwd, which + # pytest's rootdir insertion turns into a namespace package shadowing + # the installed wheel. Rebuild diffq/ from the installed wheel's own + # tree, then lay the tests back on top of it, before testing. + # test_torchscript_export needs torchvision, which we don't carry. + CIBW_TEST_COMMAND: >- + mv diffq diffq-tests-only && + python -c "import diffq, os, shutil; shutil.copytree(os.path.dirname(diffq.__file__), 'diffq')" && + cp -a diffq-tests-only/tests diffq/tests && + python -m pytest -v diffq/tests --deselect diffq/tests/test_diffq.py::TestDiffQ::test_torchscript_export + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: diffq-${{ env.DIFFQ_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish diffq ${{ matrix.version }} + needs: [setup, build_wheels] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + secrets: + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} + with: + artifact-pattern: diffq-${{ matrix.version }}-*-manylinux_riscv64 diff --git a/docs/packages/diffq.yaml b/docs/packages/diffq.yaml new file mode 100644 index 000000000000..44700e777d0d --- /dev/null +++ b/docs/packages/diffq.yaml @@ -0,0 +1,5 @@ +package-name: diffq +source-code: https://github.com/facebookresearch/diffq +license: Creative Commons Attribution-NonCommercial 4.0 International +versions: +- version: 0.2.4