|
| 1 | +name: Dist Paddle |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [paddle] |
| 5 | + tags: ["v*"] |
| 6 | + pull_request: |
| 7 | + merge_group: |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +env: |
| 18 | + PYTHONDEVMODE: "1" |
| 19 | + PYTHONUNBUFFERED: "1" |
| 20 | + COLUMNS: "100" |
| 21 | + FORCE_COLOR: "1" |
| 22 | + CLICOLOR_FORCE: "1" |
| 23 | + UV_INDEX_STRATEGY: "unsafe-best-match" |
| 24 | + UV_HTTP_TIMEOUT: "600" |
| 25 | + XDG_CACHE_HOME: "${{ github.workspace }}/.cache" # to be updated |
| 26 | + PIP_CACHE_DIR: "${{ github.workspace }}/.cache/pip" # to be updated |
| 27 | + UV_CACHE_DIR: "${{ github.workspace }}/.cache/uv" # to be updated |
| 28 | + |
| 29 | +jobs: |
| 30 | + build-sdist: |
| 31 | + name: Build SDist |
| 32 | + runs-on: macos-latest |
| 33 | + timeout-minutes: 45 |
| 34 | + env: |
| 35 | + # `NO_VERSION_LABEL=ON` disables embedding the toolchain / git commit hash in version metadata. |
| 36 | + # Otherwise, the version of the SDist has a git hash suffix (e.g., 0.1.0+gitabcdef12), |
| 37 | + # but the package built from the SDist has no way to get the git hash (it is not a git repo), |
| 38 | + # leading to inconsistent versions between SDist and built packages (+gitabcdef12 vs. +gitunknown). |
| 39 | + NO_VERSION_LABEL: "ON" |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@v5 |
| 44 | + with: |
| 45 | + fetch-depth: 1 |
| 46 | + submodules: recursive |
| 47 | + |
| 48 | + - name: Setup Python and uv with caching |
| 49 | + id: setup-uv |
| 50 | + uses: astral-sh/setup-uv@v7 |
| 51 | + with: |
| 52 | + python-version: "3.12" |
| 53 | + activate-environment: true |
| 54 | + |
| 55 | + - name: Build SDist |
| 56 | + run: | |
| 57 | + uv run --no-project --with=build -m -- build --sdist --outdir=dist |
| 58 | +
|
| 59 | + - name: Setup ccache |
| 60 | + uses: hendrikmuhs/ccache-action@v1 |
| 61 | + with: |
| 62 | + max-size: "200MB" |
| 63 | + create-symlink: true |
| 64 | + evict-old-files: "7d" |
| 65 | + append-timestamp: false |
| 66 | + key: sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }} |
| 67 | + restore-keys: | |
| 68 | + sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }} |
| 69 | + sdist-${{ runner.os }}-${{ runner.arch }} |
| 70 | + ${{ runner.os }}-${{ runner.arch }} |
| 71 | +
|
| 72 | + - name: Test SDist buildable |
| 73 | + run: | |
| 74 | + TEMP_DIR="$(mktemp -d -t tilelang-sdist-test)" |
| 75 | + cp -r dist "${TEMP_DIR}/dist" |
| 76 | + cd "${TEMP_DIR}" |
| 77 | + uv pip install -v dist/*.tar.gz |
| 78 | + # python3 -c "import tilelang; print(tilelang.__version__)" |
| 79 | +
|
| 80 | + - name: Upload SDist |
| 81 | + # Not PR to save artifact storage, as SDist is only needed for releases. |
| 82 | + uses: actions/upload-artifact@v6 |
| 83 | + with: |
| 84 | + name: sdist |
| 85 | + path: dist/*.tar.gz |
| 86 | + if-no-files-found: error |
| 87 | + |
| 88 | + build-wheels: |
| 89 | + name: Build wheels for Python ${{ matrix.python-version }} on ${{ matrix.target.runner }} with ${{ matrix.target.toolkit }} |
| 90 | + strategy: |
| 91 | + matrix: |
| 92 | + target: |
| 93 | + - { runner: ubuntu-latest, toolkit: "CUDA-12.8", test_backends: "cu118 cu130" } |
| 94 | + - { runner: ubuntu-24.04-arm, toolkit: "CUDA-12.8", test_backends: "cu126 cu130" } |
| 95 | + - { runner: macos-latest, toolkit: "Metal" } |
| 96 | + python-version: |
| 97 | + # Build wheels for different Python ABIs |
| 98 | + - "3.9" |
| 99 | + # - "3.14t" # let user to build from source for now |
| 100 | + # TODO: Add cp315-abi3.abi3t after PEP 803 |
| 101 | + include: |
| 102 | + # map build version to test version |
| 103 | + # Python 3.9 implicitly restrict torch version (e.g. on arm64). |
| 104 | + # This test rely on torch to provide libnvrtc, so we need a rather new torch. |
| 105 | + - { python-version: "3.9", test-python-version: "3.12" } |
| 106 | + # - { python-version: "3.14t", test-python-version: "3.14t" } |
| 107 | + fail-fast: false |
| 108 | + timeout-minutes: 120 |
| 109 | + runs-on: ${{ matrix.target.runner }} |
| 110 | + env: |
| 111 | + IS_RELEASE: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, '[Release]') }} |
| 112 | + NO_VERSION_LABEL: "OFF" |
| 113 | + |
| 114 | + steps: |
| 115 | + - name: Checkout repository |
| 116 | + uses: actions/checkout@v5 |
| 117 | + with: |
| 118 | + fetch-depth: 1 |
| 119 | + submodules: recursive |
| 120 | + |
| 121 | + - name: Setup ccache |
| 122 | + uses: hendrikmuhs/ccache-action@v1 |
| 123 | + with: |
| 124 | + max-size: "200MB" |
| 125 | + create-symlink: true |
| 126 | + evict-old-files: "7d" |
| 127 | + append-timestamp: false |
| 128 | + key: wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}-${{ hashFiles('**/*.cc') }} |
| 129 | + restore-keys: | |
| 130 | + wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}-${{ hashFiles('**/*.cc') }} |
| 131 | + wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }} |
| 132 | + wheel-${{ runner.os }}-${{ runner.arch }} |
| 133 | +
|
| 134 | + - name: Set CIBW_BUILD |
| 135 | + run: | |
| 136 | + PYTHON_VERSION="${{ matrix.python-version }}" |
| 137 | + PYTHON_VERSION_MAJMIN="$(echo "${PYTHON_VERSION}" | cut -d '.' -f-2)" |
| 138 | + PYTHON_VERSION_MAJMIN_NODOT="${PYTHON_VERSION_MAJMIN//./}" |
| 139 | + echo "CIBW_BUILD=cp${PYTHON_VERSION_MAJMIN_NODOT}-*" | tee -a "${GITHUB_ENV}" |
| 140 | +
|
| 141 | + if [[ "${{ matrix.target.toolkit }}" == *"CUDA"* ]]; then |
| 142 | + CUDA_VERSION="${{ matrix.target.toolkit }}" |
| 143 | + CUDA_VERSION="${CUDA_VERSION##*-}" |
| 144 | + CUDA_VERSION_MAJMIN="$(echo ${CUDA_VERSION} | cut -d '.' -f-2)" |
| 145 | + CUDA_VERSION_MAJMIN_NODOT="${CUDA_VERSION_MAJMIN//./}" |
| 146 | + echo "UV_TORCH_BACKEND=cu${CUDA_VERSION_MAJMIN_NODOT}" | tee -a "${GITHUB_ENV}" |
| 147 | + fi |
| 148 | + if [[ "${{ env.IS_RELEASE }}" == "true" ]]; then |
| 149 | + echo "NO_VERSION_LABEL=ON" | tee -a "${GITHUB_ENV}" |
| 150 | + fi |
| 151 | + if [[ "${{ runner.os }}" == "Linux" ]]; then |
| 152 | + HOST_CCACHE_DIR="$(ccache --get-config cache_dir)" |
| 153 | + echo "CIBW_BEFORE_BUILD_LINUX=dnf install -y ccache && ccache -o cache_dir=/host${HOST_CCACHE_DIR}" | tee -a "${GITHUB_ENV}" |
| 154 | + fi |
| 155 | +
|
| 156 | + - name: Build wheels |
| 157 | + uses: pypa/cibuildwheel@v3.2 |
| 158 | + with: |
| 159 | + package-dir: . |
| 160 | + output-dir: wheelhouse |
| 161 | + config-file: "{package}/pyproject.toml" |
| 162 | + |
| 163 | + - name: Setup Python and uv with caching |
| 164 | + id: setup-uv |
| 165 | + uses: astral-sh/setup-uv@v7 |
| 166 | + with: |
| 167 | + python-version: ${{ matrix.python-version }} |
| 168 | + activate-environment: true |
| 169 | + |
| 170 | + - name: Test built wheels |
| 171 | + run: | |
| 172 | + for WHEEL in wheelhouse/*.whl; do |
| 173 | + echo "Testing wheel: ${WHEEL}" |
| 174 | + if [[ "${WHEEL}" == *"abi3"* ]]; then |
| 175 | + uvx abi3audit --verbose --strict "${WHEEL}" |
| 176 | + fi |
| 177 | + ( |
| 178 | + set -e |
| 179 | + uv venv test-venv |
| 180 | + source test-venv/bin/activate |
| 181 | + uv pip install -v "${WHEEL}" |
| 182 | + ( |
| 183 | + set -e |
| 184 | + cd / |
| 185 | + # uv run --no-project -- python -c "import tilelang; print(tilelang.__version__)" |
| 186 | + ) |
| 187 | + deactivate |
| 188 | + rm -rf test-venv |
| 189 | + ) |
| 190 | + done |
| 191 | +
|
| 192 | + - name: Upload wheels |
| 193 | + # Not PR to save artifact storage, as wheels are only needed for releases. |
| 194 | + uses: actions/upload-artifact@v6 |
| 195 | + with: |
| 196 | + name: wheels-${{ matrix.python-version }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }} |
| 197 | + path: wheelhouse/*.whl |
| 198 | + if-no-files-found: error |
| 199 | + |
| 200 | + list-artifacts: |
| 201 | + name: List artifacts |
| 202 | + # Not PR to save artifact storage, as artifacts are only needed for releases. |
| 203 | + runs-on: ubuntu-latest |
| 204 | + needs: [build-sdist, build-wheels] |
| 205 | + timeout-minutes: 15 |
| 206 | + steps: |
| 207 | + - name: Download built SDist |
| 208 | + uses: actions/download-artifact@v7 |
| 209 | + with: |
| 210 | + # unpacks default artifact into dist/ |
| 211 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 212 | + name: sdist |
| 213 | + path: dist |
| 214 | + |
| 215 | + - name: Download built wheels |
| 216 | + uses: actions/download-artifact@v7 |
| 217 | + with: |
| 218 | + pattern: wheels-* |
| 219 | + path: dist |
| 220 | + merge-multiple: true |
| 221 | + |
| 222 | + - name: List distributions |
| 223 | + run: ls -lh dist/* |
| 224 | + |
| 225 | + - name: Upload artifacts |
| 226 | + uses: actions/upload-artifact@v6 |
| 227 | + with: |
| 228 | + name: artifacts |
| 229 | + path: dist/* |
| 230 | + if-no-files-found: error |
| 231 | + |
| 232 | + publish-pypi: |
| 233 | + runs-on: ubuntu-latest |
| 234 | + name: Publish to PyPI |
| 235 | + if: "startsWith(github.ref, 'refs/tags/')" |
| 236 | + needs: |
| 237 | + - list-artifacts |
| 238 | + permissions: |
| 239 | + id-token: write |
| 240 | + |
| 241 | + steps: |
| 242 | + - name: Retrieve release distributions |
| 243 | + uses: actions/download-artifact@v7 |
| 244 | + with: |
| 245 | + name: artifacts |
| 246 | + path: dist/ |
| 247 | + |
| 248 | + - name: Publish release distributions to PyPI |
| 249 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 250 | + |
| 251 | + publish-release: |
| 252 | + runs-on: ubuntu-latest |
| 253 | + name: Publish to GitHub |
| 254 | + if: "startsWith(github.ref, 'refs/tags/')" |
| 255 | + needs: |
| 256 | + - list-artifacts |
| 257 | + permissions: |
| 258 | + contents: write |
| 259 | + steps: |
| 260 | + - uses: actions/download-artifact@v7 |
| 261 | + with: |
| 262 | + name: artifacts |
| 263 | + path: dist/ |
| 264 | + - name: Get tag name |
| 265 | + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 266 | + - name: Publish to GitHub |
| 267 | + uses: softprops/action-gh-release@v2 |
| 268 | + with: |
| 269 | + draft: true |
| 270 | + files: dist/* |
| 271 | + tag_name: ${{ env.RELEASE_VERSION }} |
0 commit comments