Skip to content

Commit f618f30

Browse files
committed
[Compat] Compat with PaddlePaddle
1 parent 41b2552 commit f618f30

File tree

16 files changed

+896
-76
lines changed

16 files changed

+896
-76
lines changed

.github/workflows/ci-paddle.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: CI 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+
jobs:
18+
test:
19+
name: Test
20+
runs-on:
21+
group: H20
22+
timeout-minutes: 30
23+
env:
24+
container_name: tilelang-paddle-test-${{ github.run_id }}
25+
steps:
26+
- name: Check docker image and run container
27+
env:
28+
FLAGS_fraction_of_gpu_memory_to_use: 0.15
29+
CTEST_PARALLEL_LEVEL: 2
30+
WITH_GPU: "ON"
31+
CUDA_ARCH_NAME: Hopper
32+
WITH_AVX: "ON"
33+
PY_VERSION: "3.10"
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
GPU_DEVICES: 3
36+
no_proxy: "bcebos.com,apiin.im.baidu.com,gitee.com,aliyun.com,.baidu.com,.tuna.tsinghua.edu.cn"
37+
run: |
38+
docker_image=ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddle:cuda129-coverage-test
39+
docker run -d -t --gpus device=${GPU_DEVICES} --name ${{ env.container_name }} \
40+
-v "/dev/shm:/dev/shm" \
41+
-v ${{ github.workspace }}/../../..:${{ github.workspace }}/../../.. \
42+
-v ${{ github.workspace }}:/workspace \
43+
-e FLAGS_fraction_of_gpu_memory_to_use \
44+
-e CTEST_PARALLEL_LEVEL \
45+
-e WITH_GPU \
46+
-e CUDA_ARCH_NAME \
47+
-e WITH_AVX \
48+
-e PY_VERSION \
49+
-e GITHUB_TOKEN \
50+
-e no_proxy \
51+
-w /workspace \
52+
--network host \
53+
${docker_image}
54+
55+
- name: Checkout repository
56+
run: |
57+
docker exec -t ${{ env.container_name }} /bin/bash -c '
58+
set -e
59+
source ${{ github.workspace }}/../../../proxy
60+
git config --global --add safe.directory "*"
61+
# Clean workspace
62+
find . -maxdepth 1 ! -name "." -exec rm -rf {} +
63+
# Checkout
64+
git init
65+
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
66+
git fetch origin ${{ github.ref }} --depth=1
67+
git checkout FETCH_HEAD
68+
git submodule update --init --recursive
69+
'
70+
71+
- name: Install dependencies
72+
run: |
73+
docker exec -t ${{ env.container_name }} /bin/bash -c '
74+
set -e
75+
source ${{ github.workspace }}/../../../proxy
76+
77+
# Install uv
78+
curl -LsSf https://astral.sh/uv/install.sh | sh
79+
source $HOME/.local/bin/env
80+
81+
# Create and activate virtual environment
82+
uv venv .venv --seed
83+
source .venv/bin/activate
84+
85+
# Install paddle
86+
uv pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu129/
87+
88+
# Install project and minimal test runner
89+
uv pip install pytest
90+
uv pip install -e .
91+
'
92+
93+
- name: Run tests
94+
run: |
95+
docker exec -t ${{ env.container_name }} /bin/bash -c '
96+
set -e
97+
source .venv/bin/activate
98+
pytest tests_paddle/
99+
'
100+
101+
- name: Terminate and delete the container
102+
if: always()
103+
run: |
104+
set +e
105+
docker stop ${{ env.container_name }}
106+
docker rm ${{ env.container_name }}

.github/workflows/dist-paddle.yml

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
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

Comments
 (0)