Wheels #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Wheels | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [release/**] | |
| pull_request: | |
| paths: | |
| - .github/workflows/wheels.yml | |
| - .github/workflows/build/wheels.Dockerfile | |
| - setup.py | |
| - pyproject.toml | |
| - version.txt | |
| - cmake/llvm-hash.txt | |
| - cmake/json-version.txt | |
| schedule: | |
| - cron: "0 8 * * *" | |
| concurrency: | |
| group: wheels-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: read-all | |
| jobs: | |
| Build-Wheels: | |
| name: Build wheels for ${{ matrix.config.arch }}-${{ matrix.python }}-${{ matrix.branch.tag }} | |
| runs-on: ${{ matrix.config.runs_on }} | |
| container: | |
| image: swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:9.0.0-a3-ubuntu22.04-py3.12 | |
| timeout-minutes: 360 | |
| strategy: | |
| fail-fast: false | |
| # Limit parallelism: wheel builds compile hundreds of C++ files on | |
| # memory-constrained workers; too many at once causes OOM kills and | |
| # buildkitd/SWR auth timeouts. | |
| max-parallel: 6 | |
| matrix: | |
| config: | |
| - {runs_on: 'linux-amd64-cpu-4', arch: 'x86_64'} | |
| - {runs_on: 'linux-aarch64-cpu-4', arch: 'aarch64'} | |
| python: ["cp310", "cp311", "cp312", "cp313"] | |
| branch: | |
| - {ref: 'main', tag: 'main', local: 'dev'} | |
| - {ref: 'release/3.2.2', tag: 'release-3.2.2', local: 'release'} | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Check for new commits | |
| if: github.event_name == 'push' | |
| id: new-commits | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| LAST_SHA=$(gh api \ | |
| "/repos/${{ github.repository }}/actions/workflows/wheels.yml/runs?branch=${{ github.ref_name }}&status=success&per_page=1" \ | |
| --jq '.workflow_runs[0].head_sha // empty') | |
| if [ "$LAST_SHA" = "${{ github.sha }}" ]; then | |
| echo "Current commit already has a successful wheel build. Skipping." | |
| echo "has_new_commits=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "New commits detected. Proceeding with wheel build." | |
| echo "has_new_commits=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| # PR: checkout the PR head, not the matrix.branch ref (main). | |
| # push/workflow_dispatch/schedule: use the matrix branch ref. | |
| ref: ${{ github.event_name != 'pull_request' && matrix.branch.ref || '' }} | |
| - name: Compute build variables | |
| id: vars | |
| shell: bash | |
| run: | | |
| NUM_PROCS=$(( $(nproc) / 6 )) | |
| if [ "$NUM_PROCS" -lt 1 ]; then NUM_PROCS=1; fi | |
| # Hard-cap at 8 to avoid OOM on memory-constrained buildkitd workers. | |
| if [ "$NUM_PROCS" -gt 8 ]; then NUM_PROCS=8; fi | |
| echo "max_jobs=${NUM_PROCS}" >> $GITHUB_OUTPUT | |
| BUILD_DATE=$(date -u +%Y%m%d) | |
| echo "build_date=${BUILD_DATE}" >> $GITHUB_OUTPUT | |
| - name: Build wheels | |
| if: github.event_name != 'push' || steps.new-commits.outputs.has_new_commits != 'false' | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: .github/workflows/build/wheels.Dockerfile | |
| build-args: | | |
| MANYLINUX_IMAGE=swr.cn-southwest-2.myhuaweicloud.com/modelfoundry/pypa/manylinux_2_28_${{ matrix.config.arch }}:latest | |
| PYTHON_VERSION=${{ matrix.python }} | |
| MAX_JOBS=${{ steps.vars.outputs.max_jobs }} | |
| TRITON_WHEEL_VERSION_SUFFIX=+${{ matrix.branch.local }} | |
| BUILD_DATE=${{ steps.vars.outputs.build_date }} | |
| outputs: type=local,dest=./wheelhouse | |
| - uses: actions/upload-artifact@v4 | |
| if: github.event_name != 'push' || steps.new-commits.outputs.has_new_commits != 'false' | |
| with: | |
| name: cibw-wheels-manylinux_2_28_${{ matrix.config.arch }}-${{ matrix.python }}-${{ matrix.branch.tag }}-wheels-upload | |
| path: ./wheelhouse/*.whl | |
| - name: Setup obsutil and upload to OBS | |
| if: github.event_name != 'pull_request' && (github.event_name != 'push' || steps.new-commits.outputs.has_new_commits != 'false') | |
| shell: bash | |
| env: | |
| AK: ${{ secrets.NIGHTLY_OBS_AK }} | |
| SK: ${{ secrets.NIGHTLY_OBS_SK }} | |
| ARCH: ${{ matrix.config.arch == 'x86_64' && 'amd64' || 'arm64' }} | |
| run: | | |
| set -eu | |
| if [ -z "${AK}" ] || [ -z "${SK}" ]; then | |
| echo "OBS credentials are empty." | |
| exit 1 | |
| fi | |
| curl -fL "https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_${ARCH}.tar.gz" -o obsutil.tar.gz | |
| gzip -t obsutil.tar.gz || { echo "obsutil.tar.gz is not a valid gzip"; exit 1; } | |
| tar xzf obsutil.tar.gz | |
| rm -f obsutil.tar.gz | |
| mv obsutil_linux_* obsutil | |
| obsutil/obsutil config -i="${AK}" -k="${SK}" -e=https://obs.cn-north-4.myhuaweicloud.com | |
| OBS_DIR="obs://ascend-artifcat-packages/pypi/packages/ascend/repos/pypi/nightly/triton-ascend/" | |
| obsutil/obsutil cp -u wheelhouse/*.whl "${OBS_DIR}" | |
| # Regenerate index.html from every .whl currently in the directory | |
| # (non-recursive, short format), keeping only the basenames. | |
| obsutil/obsutil ls "${OBS_DIR}" -d -s -limit=0 \ | |
| | grep -oE '[^/]+\.whl$' \ | |
| | sort -u > files.txt | |
| while IFS= read -r f; do | |
| printf "<a href='%s'>%s</a><br />\n" "$f" "$f" | |
| done < files.txt > index.html | |
| obsutil/obsutil cp index.html "${OBS_DIR}" |