Skip to content

Commit

Permalink
chore(ci): build wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdabcd987 committed Dec 22, 2023
1 parent aa07682 commit 69f5d4a
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build Wheel
on:
push:
branches:
- ci-wheel
tags:
- "v[0-9]+*"

env:
TORCH_CUDA_ARCH_LIST: "8.0 8.6 8.9+PTX" # Need fix for 9.0
PUNICA_CI_TORCH_VERSION: "2.1.0"

jobs:
build:
strategy:
fail-fast: false
matrix:
python: ["3.10"]
cuda: ["11.8", "12.1"]
runs-on: [self-hosted]
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build wheel
run: |
chown -R $CI_UID:$CI_GID "$GITHUB_WORKSPACE"
version="$(cat version.txt)"
docker run --rm -t \
-v "$CI_RUNNER_CACHE_DIR":/ci-cache \
-v "$GITHUB_WORKSPACE":/app \
-e PUNICA_CI_PYTHON_VERSION=${{ matrix.python }} \
-e PUNICA_CI_CUDA_VERSION=${{ matrix.cuda }} \
-e PUNICA_CI_TORCH_VERSION=$PUNICA_CI_TORCH_VERSION \
-e PUNICA_BUILD_VERSION=$version \
-e TORCH_CUDA_ARCH_LIST="$TORCH_CUDA_ARCH_LIST" \
--user $CI_UID:$CI_GID \
pytorch/manylinux-builder:cuda${{ matrix.cuda }} \
bash /app/ci/run-ci-build-wheel.bash
- run: du -h dist/*

- uses: actions/upload-artifact@v4
with:
name: wheel-python${{ matrix.python }}-cuda${{ matrix.cuda }}
path: dist/*
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include version.txt
include src/punica/_build_meta.py
recursive-include csrc *
recursive-include third_party/cutlass/include *
recursive-include third_party/flashinfer/include *
Expand Down
43 changes: 43 additions & 0 deletions ci/run-ci-build-wheel.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e

assert_env() {
local var_name="$1"
if [ -z "${!var_name}" ]; then
echo "Error: Environment variable '$var_name' is not set."
exit 1
fi
}

assert_env PUNICA_CI_PYTHON_VERSION
assert_env PUNICA_CI_TORCH_VERSION
assert_env PUNICA_CI_CUDA_VERSION
assert_env PUNICA_BUILD_VERSION
assert_env TORCH_CUDA_ARCH_LIST
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
export CONDA_pkgs_dirs=/ci-cache/conda-pkgs
export XDG_CACHE_HOME=/ci-cache/xdg-cache
mkdir -p "$CONDA_pkgs_dirs" "$XDG_CACHE_HOME"
export HOME=/tmp/home
mkdir -p $HOME
CUDA_MAJOR="${PUNICA_CI_CUDA_VERSION%.*}"
CUDA_MINOR="${PUNICA_CI_CUDA_VERSION#*.}"
PYVER="${PUNICA_CI_PYTHON_VERSION//./}"
export PATH="$HOME/.local/bin:$PATH"
export PATH="/opt/python/cp${PYVER}-cp${PYVER}/bin:$PATH"


echo "::group::Install PyTorch"
pip install torch==$PUNICA_CI_TORCH_VERSION --index-url "https://download.pytorch.org/whl/cu${CUDA_MAJOR}${CUDA_MINOR}"
echo "::endgroup::"

echo "::group::Install build system"
pip install ninja numpy
pip install --upgrade setuptools wheel build
echo "::endgroup::"


echo "::group::Build wheel for Punica"
cd "$PROJECT_ROOT"
python -m build --no-isolation
echo "::endgroup::"

0 comments on commit 69f5d4a

Please sign in to comment.