Skip to content

Commit 668805f

Browse files
committed
[Compat] Compat with PaddlePaddle
1 parent 0eb33f2 commit 668805f

File tree

16 files changed

+569
-56
lines changed

16 files changed

+569
-56
lines changed

.github/workflows/ci-paddle.yml

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

.github/workflows/dist-paddle.yml

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
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+
24+
jobs:
25+
build-sdist:
26+
name: Build SDist
27+
runs-on: macos-latest
28+
timeout-minutes: 30
29+
env:
30+
# `NO_VERSION_LABEL=ON` disables embedding the toolchain / git commit hash in version metadata.
31+
# Otherwise, the version of the SDist has a git hash suffix (e.g., 0.1.0+gitabcdef12),
32+
# but the package built from the SDist has no way to get the git hash (it is not a git repo),
33+
# leading to inconsistent versions between SDist and built packages (+gitabcdef12 vs. +gitunknown).
34+
NO_VERSION_LABEL: "ON"
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v5
39+
with:
40+
fetch-depth: 1
41+
submodules: recursive
42+
43+
- name: Setup Python and uv with caching
44+
id: setup-uv
45+
uses: astral-sh/setup-uv@v7
46+
with:
47+
python-version: "3.12"
48+
activate-environment: true
49+
50+
- name: Build SDist
51+
run: |
52+
uv run --no-project --with=build -m -- build --sdist --outdir=dist
53+
54+
- name: Setup ccache
55+
uses: hendrikmuhs/ccache-action@v1
56+
with:
57+
create-symlink: true
58+
evict-old-files: "7d"
59+
append-timestamp: false
60+
key: sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }}
61+
restore-keys: |
62+
sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }}
63+
sdist-${{ runner.os }}-${{ runner.arch }}
64+
${{ runner.os }}-${{ runner.arch }}
65+
66+
- name: Test SDist buildable
67+
run: |
68+
TEMP_DIR="$(mktemp -d -t tilelang-sdist-test)"
69+
cp -r dist "${TEMP_DIR}/dist"
70+
cd "${TEMP_DIR}"
71+
uv pip install -v dist/*.tar.gz
72+
# python3 -c "import tilelang; print(tilelang.__version__)"
73+
74+
- name: Upload SDist
75+
# Not PR to save artifact storage, as SDist is only needed for releases.
76+
uses: actions/upload-artifact@v5
77+
with:
78+
name: sdist
79+
path: dist/*.tar.gz
80+
if-no-files-found: error
81+
82+
build-wheels:
83+
name: Build wheels for Python ${{ matrix.python-version }} on ${{ matrix.target.runner }} with ${{ matrix.target.toolkit }}
84+
strategy:
85+
matrix:
86+
target:
87+
- { runner: ubuntu-latest, toolkit: "CUDA-12.1" }
88+
- { runner: ubuntu-24.04-arm, toolkit: "CUDA-12.8" }
89+
- { runner: macos-latest, toolkit: "Metal" }
90+
python-version:
91+
# Wheels are built with Python 3.8 Limited API, they should work with all Python >= 3.8.
92+
# Only build wheels against Python 3.8 Limited API to save CI resources.
93+
- "3.9"
94+
fail-fast: false
95+
timeout-minutes: 120
96+
runs-on: ${{ matrix.target.runner }}
97+
env:
98+
NO_VERSION_LABEL: ${{ github.event_name == 'release' && 'OFF' || 'ON' }}
99+
100+
steps:
101+
- name: Checkout repository
102+
uses: actions/checkout@v5
103+
with:
104+
fetch-depth: 1
105+
submodules: recursive
106+
107+
- name: Setup ccache
108+
uses: hendrikmuhs/ccache-action@v1
109+
with:
110+
create-symlink: true
111+
evict-old-files: "7d"
112+
append-timestamp: false
113+
key: wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}-${{ hashFiles('**/*.cc') }}
114+
restore-keys: |
115+
wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}-${{ hashFiles('**/*.cc') }}
116+
wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}
117+
wheel-${{ runner.os }}-${{ runner.arch }}
118+
${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}
119+
${{ runner.os }}-${{ runner.arch }}
120+
121+
- name: Set CIBW_BUILD
122+
run: |
123+
PYTHON_VERSION="${{ matrix.python-version }}"
124+
PYTHON_VERSION_MAJMIN="$(echo "${PYTHON_VERSION}" | cut -d '.' -f-2)"
125+
PYTHON_VERSION_MAJMIN_NODOT="${PYTHON_VERSION_MAJMIN//./}"
126+
echo "CIBW_BUILD=cp${PYTHON_VERSION_MAJMIN_NODOT}-*" | tee -a "${GITHUB_ENV}"
127+
128+
if [[ "${{ matrix.target.toolkit }}" == *"CUDA"* ]]; then
129+
CUDA_VERSION="${{ matrix.target.toolkit }}"
130+
CUDA_VERSION="${CUDA_VERSION#CUDA-}"
131+
echo "CUDA_VERSION=${CUDA_VERSION}" | tee -a "${GITHUB_ENV}"
132+
fi
133+
134+
if [[ "${{ runner.os }}" == "Linux" ]]; then
135+
HOST_CCACHE_DIR="$(ccache --get-config cache_dir)"
136+
echo "CIBW_BEFORE_BUILD_LINUX=yum install -y ccache && ccache -o cache_dir=/host${HOST_CCACHE_DIR}" | tee -a "${GITHUB_ENV}"
137+
fi
138+
139+
- name: Build wheels
140+
uses: pypa/cibuildwheel@v3.2
141+
with:
142+
package-dir: .
143+
output-dir: wheelhouse
144+
config-file: "{package}/pyproject.toml"
145+
146+
- name: Upload wheels
147+
# Not PR to save artifact storage, as wheels are only needed for releases.
148+
uses: actions/upload-artifact@v5
149+
with:
150+
name: wheels-${{ matrix.python-version }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}
151+
path: wheelhouse/*.whl
152+
if-no-files-found: error
153+
154+
list-artifacts:
155+
name: List artifacts
156+
# Not PR to save artifact storage, as artifacts are only needed for releases.
157+
runs-on: ubuntu-latest
158+
needs: [build-sdist, build-wheels]
159+
timeout-minutes: 15
160+
steps:
161+
- name: Download built SDist
162+
uses: actions/download-artifact@v6
163+
with:
164+
# unpacks default artifact into dist/
165+
# if `name: artifact` is omitted, the action will create extra parent dir
166+
name: sdist
167+
path: dist
168+
169+
- name: Download built wheels
170+
uses: actions/download-artifact@v6
171+
with:
172+
pattern: wheels-*
173+
path: dist
174+
merge-multiple: true
175+
176+
- name: List distributions
177+
run: ls -lh dist/*
178+
179+
- name: Upload artifacts
180+
uses: actions/upload-artifact@v5
181+
with:
182+
name: artifacts
183+
path: dist/*
184+
if-no-files-found: error
185+
186+
publish-pypi:
187+
runs-on: ubuntu-latest
188+
name: Publish to PyPI
189+
if: "startsWith(github.ref, 'refs/tags/')"
190+
needs:
191+
- list-artifacts
192+
permissions:
193+
id-token: write
194+
195+
steps:
196+
- name: Retrieve release distributions
197+
uses: actions/download-artifact@v6
198+
with:
199+
name: artifacts
200+
path: dist/
201+
202+
- name: Publish release distributions to PyPI
203+
uses: pypa/gh-action-pypi-publish@release/v1
204+
205+
publish-release:
206+
runs-on: ubuntu-latest
207+
name: Publish to GitHub
208+
if: "startsWith(github.ref, 'refs/tags/')"
209+
needs:
210+
- list-artifacts
211+
permissions:
212+
contents: write
213+
steps:
214+
- uses: actions/download-artifact@v6
215+
with:
216+
name: artifacts
217+
path: dist/
218+
- name: Get tag name
219+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
220+
- name: Publish to GitHub
221+
uses: softprops/action-gh-release@v2
222+
with:
223+
draft: true
224+
files: dist/*
225+
tag_name: ${{ env.RELEASE_VERSION }}

0 commit comments

Comments
 (0)