Skip to content

Commit e66f53a

Browse files
authored
Merge pull request #5 from DangoSys/main
bump to latest version
2 parents e7cafa2 + 07f12b8 commit e66f53a

141 files changed

Lines changed: 12282 additions & 419 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/TestBuild.yml

Lines changed: 158 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,70 @@ name: test build process
22

33
on:
44
push:
5-
branches: [ main, ci ]
5+
branches: [ main, ci, ci-test ]
66
pull_request:
7-
branches: [ main, ci ]
7+
branches: [ main, ci, ci-test ]
88

99
jobs:
10-
build:
11-
runs-on: self-hosted
10+
test:
11+
name: Build (${{ matrix.arch }})
12+
timeout-minutes: 360
13+
continue-on-error: ${{ matrix.experimental }}
14+
15+
concurrency:
16+
group: buddy-mlir-${{ matrix.arch }}
17+
cancel-in-progress: true
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- arch: x64
24+
experimental: false
25+
- arch: riscv64
26+
experimental: true
27+
28+
runs-on:
29+
- self-hosted
30+
- ${{ matrix.arch }}
31+
1232
steps:
33+
- name: Print target
34+
run: |
35+
echo "Building on ${{ matrix.arch }}"
36+
echo "------ uname ------"
37+
uname -a
38+
1339
# 0. Install the Ninja build system.
1440
- name: Set up ninja
41+
if: matrix.arch == 'x64'
1542
uses: seanmiddleditch/gha-setup-ninja@master
1643

17-
# 1. Checkout the main repository without fetching submodules initially
44+
# 1A. Checkout the main repository without fetching submodules initially
1845
- name: Checkout main repository
46+
if: matrix.arch == 'x64'
1947
uses: actions/checkout@v4
2048
with:
2149
submodules: 'false'
2250

51+
# 1B. first clone from local gitea then update metedata from github
52+
- name: Checkout from local Gitea (riscv64)
53+
if: matrix.arch == 'riscv64'
54+
run: |
55+
git clone --no-checkout https://community-ci.openruyi.cn/RuyiAI-Stack/buddy-mlir .
56+
git remote add github https://github.com/buddy-compiler/buddy-mlir.git
57+
git fetch github ${{ github.sha }}
58+
git checkout ${{ github.sha }}
59+
2360
# 2. Retrieve the commit ID of the LLVM submodule.
2461
- name: Get LLVM submodule commit
2562
id: llvm-submodule-commit
2663
run: |
2764
echo "commit=$(git submodule status llvm | awk '{print $1;}')" >> $GITHUB_OUTPUT
2865
29-
# 3. Cache the LLVM submodule source code.
30-
- name: Cache LLVM source
66+
# 3. Cache the LLVM submodule source code (only for x86).
67+
- name: Cache LLVM source (x86)
68+
if: matrix.arch == 'x64'
3169
id: cache-llvm-source
3270
uses: actions/cache@v4
3371
with:
@@ -36,15 +74,16 @@ jobs:
3674
restore-keys: |
3775
llvm-source-
3876
39-
# 4. If the cache is not found, pull the LLVM submodule.
77+
# 4. If the cache is not found, pull the LLVM submodule. (x86, cache miss)
4078
- name: Checkout LLVM submodule
79+
if: matrix.arch == 'x64' && steps.cache-llvm-source.outputs.cache-hit != 'true'
4180
run: |
4281
rm -rf llvm
4382
git submodule update --init --recursive llvm
44-
if: steps.cache-llvm-source.outputs.cache-hit != 'true'
4583
4684
# 5. Cache the LLVM build directory.
4785
- name: Cache LLVM build directory
86+
if: matrix.arch == 'x64'
4887
id: cache-llvm-build-dir
4988
uses: actions/cache@v4
5089
with:
@@ -54,9 +93,9 @@ jobs:
5493
llvm-build-
5594
5695
# 6. Verify llvm-build when cached; build LLVM when no cache or verification fails.
57-
- name: Check LLVM cache
96+
- name: Check LLVM cache (x86)
5897
id: check-llvm-cache
59-
if: steps.cache-llvm-build-dir.outputs.cache-hit == 'true'
98+
if: matrix.arch == 'x64' && (steps.cache-llvm-build-dir.outputs.cache-hit == 'true')
6099
run: |
61100
for conda in ~/miniconda3/bin/activate ~/miniforge3/bin/activate; do
62101
[ -f "$conda" ] && source "$conda" buddy && break
@@ -72,8 +111,9 @@ jobs:
72111
fi
73112
continue-on-error: true
74113

75-
- name: Configure and Build LLVM
76-
if: steps.cache-llvm-build-dir.outputs.cache-hit != 'true' || steps.check-llvm-cache.outputs.need-rebuild == 'true'
114+
- name: Configure and Build LLVM (x86)
115+
if: matrix.arch == 'x64' &&
116+
(steps.cache-llvm-build-dir.outputs.cache-hit != 'true' || steps.check-llvm-cache.outputs.need-rebuild == 'true')
77117
run: |
78118
for conda in ~/miniconda3/bin/activate ~/miniforge3/bin/activate; do
79119
[ -f "$conda" ] && source "$conda" buddy && break
@@ -94,8 +134,76 @@ jobs:
94134
-DPython3_EXECUTABLE=$(which python3)
95135
ninja check-clang check-mlir omp
96136
97-
# 7. Check buddy-mlir build.
98-
- name: Check buddy-mlir build
137+
- name: Enable ccache (riscv64)
138+
if: matrix.arch == 'riscv64'
139+
run: |
140+
echo "CCACHE_DIR=/home/jenkins/.ccache" >> $GITHUB_ENV
141+
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
142+
ccache -M 50G
143+
echo "CCACHE_MAXSIZE=50G" >> $GITHUB_ENV
144+
145+
- name: Setup LLVM build (riscv64)
146+
if: matrix.arch == 'riscv64'
147+
id: prepare-llvm-build
148+
run: |
149+
LLVM_SRC=/home/jenkins/src/llvm-project
150+
LLVM_BUILD_ROOT=/home/jenkins/llvm-cache
151+
LLVM_COMMIT=$(git ls-tree HEAD llvm | awk '{print $3}')
152+
LLVM_BUILD_DIR=$LLVM_BUILD_ROOT/$LLVM_COMMIT
153+
154+
mkdir -p $LLVM_BUILD_ROOT
155+
156+
# prepare source
157+
if [ ! -d "$LLVM_SRC" ]; then
158+
mkdir -p /home/jenkins/src
159+
git clone https://community-ci.openruyi.cn/toolchain/llvm-project.git $LLVM_SRC
160+
fi
161+
162+
git -C $LLVM_SRC fetch --all
163+
git -C $LLVM_SRC reset --hard
164+
git -C $LLVM_SRC clean -fdx
165+
git -C $LLVM_SRC checkout $LLVM_COMMIT
166+
167+
echo "LLVM_SRC=$LLVM_SRC" >> $GITHUB_ENV
168+
echo "LLVM_COMMIT=$LLVM_COMMIT" >> $GITHUB_ENV
169+
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV
170+
171+
if [ -f "$LLVM_BUILD_DIR/build/CMakeCache.txt" ] &&
172+
grep -q "$LLVM_SRC" "$LLVM_BUILD_DIR/build/CMakeCache.txt"; then
173+
echo "need-rebuild=false" >> $GITHUB_OUTPUT
174+
else
175+
echo "need-rebuild=true" >> $GITHUB_OUTPUT
176+
fi
177+
178+
- name: Configure and Build LLVM (riscv64)
179+
if: matrix.arch == 'riscv64'&&
180+
steps.prepare-llvm-build.outputs.need-rebuild == 'true'
181+
run: |
182+
source /home/jenkins/venv/bin/activate
183+
pip install -U pip setuptools wheel packaging
184+
sed -i \
185+
-e '1s/^/# /' \
186+
requirements.txt
187+
pip install -r requirements.txt
188+
rm -rf $LLVM_BUILD_DIR
189+
cmake -G Ninja -S $LLVM_SRC/llvm -B $LLVM_BUILD_DIR/build \
190+
-DLLVM_ENABLE_PROJECTS="mlir;clang;openmp" \
191+
-DLLVM_TARGETS_TO_BUILD="host;RISCV" \
192+
-DLLVM_ENABLE_ASSERTIONS=ON \
193+
-DCMAKE_BUILD_TYPE=RELEASE \
194+
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
195+
-DPython3_EXECUTABLE=$(which python3)
196+
ninja -C $LLVM_BUILD_DIR/build check-clang check-mlir omp -j$(nproc) || true
197+
deactivate
198+
199+
- name: Show ccache stats (riscv64)
200+
if: matrix.arch == 'riscv64'
201+
run: |
202+
ccache -s
203+
204+
# 7A. Check buddy-mlir build (x86).
205+
- name: Check buddy-mlir build (x86)
206+
if: matrix.arch == 'x64'
99207
run: |
100208
for conda in ~/miniconda3/bin/activate ~/miniforge3/bin/activate; do
101209
[ -f "$conda" ] && source "$conda" buddy && break
@@ -113,3 +221,38 @@ jobs:
113221
-DPython3_EXECUTABLE=$(which python3)
114222
ninja
115223
ninja check-buddy
224+
225+
# 7B. Check buddy-mlir build (riscv64).
226+
- name: Check buddy-mlir build (riscv64)
227+
if: matrix.arch == 'riscv64'
228+
run: |
229+
source /home/jenkins/venv/bin/activate
230+
echo "---- CHECK LOCAL SUBMODULE ----"
231+
ls -l llvm || true
232+
git submodule status || true
233+
rm -rf build
234+
mkdir build
235+
cd build
236+
237+
# It will fail to find source code if no -DLLVM_MAIN_SRC_DIR=$LLVM_SRC/llvm -DMLIR_MAIN_SRC_DIR=$LLVM_SRC/mlir
238+
cmake -G Ninja .. \
239+
-DMLIR_DIR=$LLVM_BUILD_DIR/build/lib/cmake/mlir \
240+
-DLLVM_DIR=$LLVM_BUILD_DIR/build/lib/cmake/llvm \
241+
-DLLVM_MAIN_SRC_DIR=$LLVM_SRC/llvm \
242+
-DMLIR_MAIN_SRC_DIR=$LLVM_SRC/mlir \
243+
-DLLVM_ENABLE_ASSERTIONS=ON \
244+
-DCMAKE_BUILD_TYPE=RELEASE \
245+
-DBUDDY_MLIR_ENABLE_PYTHON_PACKAGES=ON \
246+
-DPython3_EXECUTABLE=$(which python3)
247+
ninja -j$(nproc)
248+
ninja check-buddy -j$(nproc) || true
249+
deactivate
250+
251+
- name: Cleanup old LLVM build cache (riscv64)
252+
if: matrix.arch == 'riscv64'
253+
run: |
254+
CACHE_DIR=/home/jenkins/llvm-cache
255+
KEEP=3
256+
257+
cd $CACHE_DIR
258+
ls -1dt */ | tail -n +$((KEEP+1)) | xargs -r rm -rf
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: build-manylinux
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version tag (e.g., v0.1.0)"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
wheel:
16+
runs-on: ubuntu-22.04
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
python: ["3.10", "3.11", "3.12", "3.13"]
21+
torch_version: ["2.8"] # placeholder; not used in build, keeps matrix extensible
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
submodules: true
27+
28+
- name: Record LLVM submodule commit
29+
id: llvm_rev
30+
run: echo "sha=$(git -C llvm rev-parse HEAD)" >> "$GITHUB_OUTPUT"
31+
32+
- name: Cache LLVM build tree
33+
id: cache-llvm-build
34+
uses: actions/cache@v4
35+
with:
36+
path: llvm/build.docker
37+
key: llvm-${{ runner.os }}-${{ matrix.python }}-${{ steps.llvm_rev.outputs.sha }}
38+
39+
- name: Build manylinux wheel in container
40+
run: |
41+
set -euo pipefail
42+
PY_VER="${{ matrix.python }}"
43+
PY_NODOT="${PY_VER//./}"
44+
PY_TAG="cp${PY_NODOT}-cp${PY_NODOT}"
45+
export TORCH_VERSION="${{ matrix.torch_version }}"
46+
export LLVM_CACHE_HIT="${{ steps.cache-llvm-build.outputs.cache-hit }}"
47+
./scripts/release_wheel_manylinux.sh "${PY_TAG}"
48+
49+
- name: Upload wheels
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: wheels-py${{ matrix.python }}-torch${{ matrix.torch_version }}
53+
path: build.docker/dist/*.whl
54+
55+
release:
56+
needs: wheel
57+
runs-on: ubuntu-22.04
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v4
61+
62+
- name: Download wheels
63+
uses: actions/download-artifact@v4
64+
with:
65+
pattern: wheels-*
66+
path: dist
67+
merge-multiple: true
68+
69+
- name: Upload assets
70+
uses: softprops/action-gh-release@v2
71+
with:
72+
tag_name: ${{ inputs.version }}
73+
overwrite_files: true
74+
files: dist/*manylinux*.whl
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pre-commit.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: pre-commit
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.10"
18+
19+
- uses: pre-commit/action@v3.0.1
20+
with:
21+
extra_args: --show-diff-on-failure --color=always

0 commit comments

Comments
 (0)