|
| 1 | +name: MLIR-TensorRT PyPI Release CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + confirm_publish_to_testpypi: |
| 7 | + description: 'I confirm that I have verified version to be published to test.pypi.org' |
| 8 | + required: false |
| 9 | + type: boolean |
| 10 | + default: false |
| 11 | + confirm_publish_to_pypi: |
| 12 | + description: 'I confirm that I have verified version to be published to pypi.org' |
| 13 | + required: false |
| 14 | + type: boolean |
| 15 | + default: false |
| 16 | + |
| 17 | +defaults: |
| 18 | + run: |
| 19 | + shell: bash |
| 20 | + |
| 21 | +jobs: |
| 22 | + generate-matrix: |
| 23 | + name: Generate Build Matrix (pypi-release) |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + matrix: ${{ steps.generate-matrix.outputs.matrix }} |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v6 |
| 29 | + with: |
| 30 | + fetch-depth: 5 |
| 31 | + - name: Generate Build Matrix |
| 32 | + id: generate-matrix |
| 33 | + run: | |
| 34 | + set -euo pipefail |
| 35 | + set -x |
| 36 | + MATRIX_BLOB="$(python3 ./.github/workflows/mlir-tensorrt/generate-matrix.py --channel pypi-release)" |
| 37 | + echo "${MATRIX_BLOB}" |
| 38 | + echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}" |
| 39 | +
|
| 40 | + pypi-release-wheels-build: |
| 41 | + name: ${{ matrix.arch }} - Build PyPI Release Wheels |
| 42 | + needs: |
| 43 | + - generate-matrix |
| 44 | + permissions: |
| 45 | + id-token: write |
| 46 | + packages: write |
| 47 | + contents: read |
| 48 | + strategy: |
| 49 | + matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} |
| 50 | + runs-on: ${{ matrix.github_runner }} |
| 51 | + env: |
| 52 | + MLIR_TRT_DOWNLOAD_TENSORRT_VERSION: ${{ matrix.trt }} |
| 53 | + CMAKE_PRESET: ${{ matrix.cmake_preset }} |
| 54 | + CCACHE_RESTORE_KEY: mlir-tensorrt-ccache-v1-${{ matrix.arch }}-${{ matrix.cmake_preset }} |
| 55 | + CPM_RESTORE_KEY: mlir-tensorrt-cpm-v1 |
| 56 | + timeout-minutes: 120 |
| 57 | + container: |
| 58 | + # pypi audit wheel repair requires rockylinux8 |
| 59 | + image: ${{ matrix.docker_image }} |
| 60 | + options: >- |
| 61 | + --gpus all |
| 62 | + --shm-size=1g |
| 63 | + steps: |
| 64 | + - name: Checkout TensorRT-Incubator |
| 65 | + uses: actions/checkout@v6 |
| 66 | + with: |
| 67 | + fetch-depth: 5 |
| 68 | + |
| 69 | + - name: Create Cache Folders |
| 70 | + run: | |
| 71 | + set -euo pipefail |
| 72 | + set -x |
| 73 | + export CPM_SOURCE_CACHE=${GITHUB_WORKSPACE}/mlir-tensorrt/.cache.cpm |
| 74 | + export CCACHE_DIR=${GITHUB_WORKSPACE}/mlir-tensorrt/ccache |
| 75 | +
|
| 76 | + echo "CPM_SOURCE_CACHE=$CPM_SOURCE_CACHE" >> "$GITHUB_ENV" |
| 77 | + echo "CCACHE_DIR=$CCACHE_DIR" >> "$GITHUB_ENV" |
| 78 | +
|
| 79 | + mkdir -p ${CCACHE_DIR} |
| 80 | + mkdir -p ${CPM_SOURCE_CACHE} |
| 81 | +
|
| 82 | + - name: Compute CCache Key |
| 83 | + id: ccache-key |
| 84 | + run: | |
| 85 | + hash=$( (find mlir-tensorrt/compiler \ |
| 86 | + mlir-tensorrt/common \ |
| 87 | + mlir-tensorrt/kernel \ |
| 88 | + mlir-tensorrt/tensorrt \ |
| 89 | + mlir-tensorrt/integrations \ |
| 90 | + mlir-tensorrt/executor \ |
| 91 | + -type f \( -name '*.cpp' -o -name '*.h' \) \ |
| 92 | + -exec sha256sum {} \; ; \ |
| 93 | + sha256sum mlir-tensorrt/DependencyProvider.cmake \ |
| 94 | + mlir-tensorrt/CMakeLists.txt) \ |
| 95 | + | sort | sha256sum | cut -d' ' -f1) |
| 96 | + echo "key=${{ env.CCACHE_RESTORE_KEY }}-${hash}" >> $GITHUB_OUTPUT |
| 97 | +
|
| 98 | + - name: Compute CPM Key |
| 99 | + id: cpm-key |
| 100 | + run: | |
| 101 | + hash=$(sha256sum mlir-tensorrt/DependencyProvider.cmake | cut -d' ' -f1) |
| 102 | + echo "key=${{ env.CPM_RESTORE_KEY }}-${hash}" >> $GITHUB_OUTPUT |
| 103 | +
|
| 104 | + - name: Restore CCache |
| 105 | + id: restore-ccache |
| 106 | + uses: actions/cache/restore@v4 |
| 107 | + with: |
| 108 | + key: ${{ steps.ccache-key.outputs.key }} |
| 109 | + restore-keys: | |
| 110 | + ${{ env.CCACHE_RESTORE_KEY }} |
| 111 | + path: | |
| 112 | + ${{ env.CCACHE_DIR }} |
| 113 | +
|
| 114 | + - name: Restore CPM cache |
| 115 | + id: restore-cpm |
| 116 | + uses: actions/cache/restore@v4 |
| 117 | + with: |
| 118 | + key: ${{ steps.cpm-key.outputs.key }} |
| 119 | + enableCrossOsArchive: true |
| 120 | + restore-keys: | |
| 121 | + ${{ env.CPM_RESTORE_KEY }} |
| 122 | + path: | |
| 123 | + mlir-tensorrt/.cache.cpm/* |
| 124 | + !mlir-tensorrt/.cache.cpm/tensorrt |
| 125 | + !mlir-tensorrt/.cache.cpm/tensorrt/** |
| 126 | +
|
| 127 | + - name: Build Wheels With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }} |
| 128 | + env: |
| 129 | + MLIR_TRT_DOWNLOAD_TENSORRT_VERSION: ${{ matrix.trt }} |
| 130 | + ARCH: ${{ matrix.arch }} |
| 131 | + CMAKE_PRESET: distribution-wheels |
| 132 | + run: | |
| 133 | + set -euo pipefail |
| 134 | + set -x |
| 135 | + cd mlir-tensorrt |
| 136 | + # Build only pjrt wheels for PyPI upload, with auditwheel repair |
| 137 | + # if you want to build for post version, set MLIR_TRT_PYPI_POST_VERSION=1 |
| 138 | + # MLIR_TRT_PYPI=1 MLIR_TRT_PYPI_POST_VERSION=1 PACKAGES="pjrt" VERBOSE=1 ./build_tools/scripts/cicd-build-wheels.sh |
| 139 | + MLIR_TRT_PYPI=1 PACKAGES="pjrt" VERBOSE=1 ./build_tools/scripts/cicd-build-wheels.sh |
| 140 | +
|
| 141 | + - name: Upload Wheels |
| 142 | + uses: actions/upload-artifact@v4 |
| 143 | + with: |
| 144 | + name: release-wheels-${{ matrix.arch }}-cu${{ matrix.cuda }}-trt${{ matrix.trt }} |
| 145 | + path: mlir-tensorrt/dist |
| 146 | + if-no-files-found: error |
| 147 | + |
| 148 | + pypi-release-wheels-smoke-test: |
| 149 | + name: ${{ matrix.arch }} - Smoke Test PyPI Release Wheels |
| 150 | + needs: |
| 151 | + - generate-matrix |
| 152 | + - pypi-release-wheels-build |
| 153 | + permissions: |
| 154 | + id-token: write |
| 155 | + packages: write |
| 156 | + contents: read |
| 157 | + strategy: |
| 158 | + matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} |
| 159 | + runs-on: ${{ matrix.github_runner }} |
| 160 | + timeout-minutes: 120 |
| 161 | + container: |
| 162 | + image: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda13.0-ubuntu24.04-0.1 |
| 163 | + options: >- |
| 164 | + --gpus all |
| 165 | + --shm-size=1g |
| 166 | + steps: |
| 167 | + - name: Checkout TensorRT-Incubator |
| 168 | + uses: actions/checkout@v6 |
| 169 | + with: |
| 170 | + fetch-depth: 5 |
| 171 | + - name: Download built wheels |
| 172 | + uses: actions/download-artifact@v4 |
| 173 | + with: |
| 174 | + pattern: release-wheels-* |
| 175 | + merge-multiple: true |
| 176 | + path: mlir-tensorrt/dist |
| 177 | + |
| 178 | + - name: Smoke Test Wheels With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }} |
| 179 | + run: | |
| 180 | + set -euo pipefail |
| 181 | + set -x |
| 182 | + cd mlir-tensorrt |
| 183 | + uv sync --python 3.12 --extra cu13 --extra flashinfer-cu13 |
| 184 | + source .venv/bin/activate |
| 185 | + ls -lart dist/ |
| 186 | + suffix="manylinux_2_28_${{ matrix.arch }}.whl" |
| 187 | + whl_file=$(find dist/ -name "mlir_tensorrt_jax-*-cp312-cp312-*${suffix}") |
| 188 | + echo "whl_file: ${whl_file}" |
| 189 | + uv pip install ${whl_file} |
| 190 | +
|
| 191 | + export JAX_PLATFORMS="mlir_tensorrt,cpu" |
| 192 | + python -m pytest integrations/PJRT/test/JAX/ -v |
| 193 | +
|
| 194 | + test-pypi-release-wheels-publish: |
| 195 | + name: Publish to TestPyPI |
| 196 | + if: ${{ inputs.confirm_publish_to_testpypi }} |
| 197 | + needs: |
| 198 | + - pypi-release-wheels-build |
| 199 | + - pypi-release-wheels-smoke-test |
| 200 | + runs-on: ubuntu-latest |
| 201 | + environment: |
| 202 | + name: testpypi |
| 203 | + url: https://test.pypi.org/project/mlir-tensorrt-jax/ |
| 204 | + permissions: |
| 205 | + id-token: write |
| 206 | + packages: write |
| 207 | + contents: read |
| 208 | + steps: |
| 209 | + - name: Download built wheels |
| 210 | + uses: actions/download-artifact@v4 |
| 211 | + with: |
| 212 | + pattern: release-wheels-* |
| 213 | + merge-multiple: true |
| 214 | + path: dist |
| 215 | + |
| 216 | + - name: Publish to TestPyPI |
| 217 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 218 | + with: |
| 219 | + skip-existing: true |
| 220 | + verbose: true |
| 221 | + repository-url: https://test.pypi.org/legacy/ |
| 222 | + |
| 223 | + pypi-release-wheels-publish: |
| 224 | + name: Publish to PyPI |
| 225 | + if: ${{ inputs.confirm_publish_to_pypi }} |
| 226 | + needs: |
| 227 | + - pypi-release-wheels-build |
| 228 | + - pypi-release-wheels-smoke-test |
| 229 | + runs-on: ubuntu-latest |
| 230 | + permissions: |
| 231 | + id-token: write |
| 232 | + packages: write |
| 233 | + contents: read |
| 234 | + steps: |
| 235 | + - name: Download built wheels |
| 236 | + uses: actions/download-artifact@v4 |
| 237 | + with: |
| 238 | + pattern: release-wheels-* |
| 239 | + merge-multiple: true |
| 240 | + path: dist |
| 241 | + |
| 242 | + - name: Publish to PyPI |
| 243 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 244 | + with: |
| 245 | + verbose: true |
| 246 | + skip-existing: true |
| 247 | + user: __token__ |
| 248 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 249 | + |
| 250 | +concurrency: |
| 251 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-mlir-tensorrt-pypi |
| 252 | + cancel-in-progress: true |
0 commit comments