Add release workflow for sgl-deep-gemm wheels (#24348)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
52b4609789
commit
de08c804c5
@@ -0,0 +1,196 @@
|
||||
name: Release sgl-deep-gemm
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Wheel version (e.g. 0.1.0, 0.1.1rc0)"
|
||||
type: string
|
||||
required: true
|
||||
target:
|
||||
type: choice
|
||||
description: "Build target (default: all)"
|
||||
required: false
|
||||
default: 'all'
|
||||
options:
|
||||
- 'all'
|
||||
- 'cu129'
|
||||
- 'cu130'
|
||||
branch:
|
||||
description: "DeepGEMM branch to build from (default: release-0426)"
|
||||
type: string
|
||||
required: false
|
||||
default: 'release-0426'
|
||||
|
||||
concurrency:
|
||||
group: release-sgl-deepgemm-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-cu129-matrix:
|
||||
if: |
|
||||
github.repository == 'sgl-project/sglang' &&
|
||||
(github.event.inputs.target == 'all' || github.event.inputs.target == 'cu129')
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10"]
|
||||
cuda-version: ["12.9"]
|
||||
arch: [x86_64, aarch64]
|
||||
include:
|
||||
- arch: x86_64
|
||||
runner: x64-kernel-build-node
|
||||
- arch: aarch64
|
||||
runner: arm-kernel-build-node
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Clean workspace (remove root-owned files from prior runs)
|
||||
run: |
|
||||
docker run --rm -v "${{ github.workspace }}:/workspace" alpine:3 \
|
||||
sh -c 'rm -rf /workspace/..?* /workspace/.[!.]* /workspace/*' || true
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout DeepGEMM
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: sgl-project/DeepGEMM
|
||||
ref: ${{ inputs.branch }}
|
||||
path: DeepGEMM
|
||||
submodules: recursive
|
||||
|
||||
- name: Set wheel version
|
||||
run: |
|
||||
echo -n "${{ inputs.version }}" > DeepGEMM/sgl_deep_gemm/VERSION
|
||||
cat DeepGEMM/sgl_deep_gemm/VERSION
|
||||
|
||||
- name: Build wheel
|
||||
run: |
|
||||
chmod +x ./scripts/build_sgl_deep_gemm.sh
|
||||
./scripts/build_sgl_deep_gemm.sh "${{ matrix.python-version }}" "${{ matrix.cuda-version }}" "${{ github.workspace }}/DeepGEMM" "${{ matrix.arch }}"
|
||||
|
||||
- name: Rename wheel
|
||||
run: |
|
||||
chmod +x ./scripts/rename_sgl_deep_gemm_whl.sh
|
||||
./scripts/rename_sgl_deep_gemm_whl.sh DeepGEMM/dist cu129 ${{ matrix.arch }}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: deepgemm-wheel-cuda${{ matrix.cuda-version }}-${{ matrix.arch }}
|
||||
path: DeepGEMM/dist/*.whl
|
||||
|
||||
release-cu129:
|
||||
needs: build-cu129-matrix
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: dist/
|
||||
merge-multiple: true
|
||||
pattern: deepgemm-wheel-cuda12.9-*
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: v${{ inputs.version }}
|
||||
repository: sgl-project/whl
|
||||
token: ${{ secrets.GH_PAT_FOR_WHL_RELEASE }}
|
||||
files: |
|
||||
dist/*
|
||||
|
||||
- name: Clone wheel index
|
||||
run: git clone https://oauth2:${WHL_TOKEN}@github.com/sgl-project/whl.git sgl-whl
|
||||
env:
|
||||
WHL_TOKEN: ${{ secrets.GH_PAT_FOR_WHL_RELEASE }}
|
||||
|
||||
- name: Update wheel index
|
||||
run: python3 scripts/update_deepgemm_whl_index.py --cuda 129
|
||||
|
||||
- name: Push wheel index
|
||||
run: |
|
||||
cd sgl-whl
|
||||
git config --local user.name "sglang-bot"
|
||||
git config --local user.email "sglangbot@gmail.com"
|
||||
git add -A
|
||||
git commit -m "update sgl-deep-gemm whl index for v${{ inputs.version }}"
|
||||
git push
|
||||
|
||||
build-cu130-matrix:
|
||||
if: |
|
||||
github.repository == 'sgl-project/sglang' &&
|
||||
(github.event.inputs.target == 'all' || github.event.inputs.target == 'cu130')
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10"]
|
||||
cuda-version: ["13.0"]
|
||||
arch: [x86_64, aarch64]
|
||||
include:
|
||||
- arch: x86_64
|
||||
runner: x64-kernel-build-node
|
||||
- arch: aarch64
|
||||
runner: arm-kernel-build-node
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Clean workspace (remove root-owned files from prior runs)
|
||||
run: |
|
||||
docker run --rm -v "${{ github.workspace }}:/workspace" alpine:3 \
|
||||
sh -c 'rm -rf /workspace/..?* /workspace/.[!.]* /workspace/*' || true
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout DeepGEMM
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: sgl-project/DeepGEMM
|
||||
ref: ${{ inputs.branch }}
|
||||
path: DeepGEMM
|
||||
submodules: recursive
|
||||
|
||||
- name: Set wheel version
|
||||
run: |
|
||||
echo -n "${{ inputs.version }}" > DeepGEMM/sgl_deep_gemm/VERSION
|
||||
cat DeepGEMM/sgl_deep_gemm/VERSION
|
||||
|
||||
- name: Build wheel
|
||||
run: |
|
||||
chmod +x ./scripts/build_sgl_deep_gemm.sh
|
||||
./scripts/build_sgl_deep_gemm.sh "${{ matrix.python-version }}" "${{ matrix.cuda-version }}" "${{ github.workspace }}/DeepGEMM" "${{ matrix.arch }}"
|
||||
|
||||
- name: Rename wheel
|
||||
run: |
|
||||
chmod +x ./scripts/rename_sgl_deep_gemm_whl.sh
|
||||
./scripts/rename_sgl_deep_gemm_whl.sh DeepGEMM/dist cu130 ${{ matrix.arch }}
|
||||
|
||||
- name: Strip +cu130 local version for PyPI upload
|
||||
working-directory: DeepGEMM
|
||||
run: |
|
||||
set -eux
|
||||
pip install wheel
|
||||
mkdir -p dist-pypi
|
||||
for w in dist/*.whl; do
|
||||
tmp=$(mktemp -d)
|
||||
python3 -m wheel unpack "$w" --dest "$tmp"
|
||||
unpacked=$(find "$tmp" -mindepth 1 -maxdepth 1 -type d | head -1)
|
||||
info=$(find "$unpacked" -maxdepth 1 -type d -name "*.dist-info" | head -1)
|
||||
meta="$info/METADATA"
|
||||
orig=$(grep '^Version:' "$meta" | head -1 | sed 's/^Version:[[:space:]]*//')
|
||||
new=$(echo "$orig" | sed 's/+cu[0-9]\+$//')
|
||||
if [ "$orig" != "$new" ]; then
|
||||
sed -i "s/^Version:.*/Version: ${new}/" "$meta"
|
||||
old_base=$(basename "$info")
|
||||
new_base="${old_base/${orig}/${new}}"
|
||||
mv "$info" "$(dirname "$info")/${new_base}"
|
||||
fi
|
||||
python3 -m wheel pack "$unpacked" --dest-dir dist-pypi
|
||||
rm -rf "$tmp"
|
||||
done
|
||||
ls -lh dist-pypi/
|
||||
|
||||
- name: Upload to PyPI
|
||||
working-directory: DeepGEMM
|
||||
run: |
|
||||
pip install twine
|
||||
python3 -m twine upload --skip-existing dist-pypi/* -u __token__ -p ${{ secrets.SGL_DEEP_GEMM_PYPI_TOKEN }}
|
||||
@@ -0,0 +1,35 @@
|
||||
ARG BASE_IMG=pytorch/manylinux2_28-builder
|
||||
ARG CUDA_VERSION=13.0
|
||||
|
||||
FROM ${BASE_IMG}:cuda${CUDA_VERSION}
|
||||
|
||||
ARG ARCH=x86_64
|
||||
ARG CUDA_VERSION=13.0
|
||||
ARG PYTHON_VERSION=3.10
|
||||
ARG PYTHON_TAG=cp310-cp310
|
||||
ARG TORCH_VER=2.11.0
|
||||
ARG TVM_FFI_VER=0.1.9
|
||||
ARG PIP_DEFAULT_INDEX=https://pypi.python.org/simple
|
||||
ARG PYTORCH_MIRROR=download.pytorch.org
|
||||
|
||||
ENV PYTHON_ROOT_PATH=/opt/python/${PYTHON_TAG}
|
||||
ENV PATH=${PYTHON_ROOT_PATH}/bin:${PATH}
|
||||
|
||||
RUN yum install -y --nogpgcheck git wget tar gcc gcc-c++ make \
|
||||
&& yum clean all && rm -rf /var/cache/yum
|
||||
|
||||
RUN set -eux; \
|
||||
if [ "${ARCH}" = "aarch64" ]; then _LIB=sbsa; else _LIB="${ARCH}"; fi; \
|
||||
mkdir -p /usr/lib/${ARCH}-linux-gnu/; \
|
||||
ln -sf /usr/local/cuda-${CUDA_VERSION}/targets/${_LIB}-linux/lib/stubs/libcuda.so /usr/lib/${ARCH}-linux-gnu/libcuda.so
|
||||
|
||||
RUN --mount=type=cache,id=sgl-deep-gemm-pip,target=/root/.cache/pip \
|
||||
set -eux; \
|
||||
case "${CUDA_VERSION}" in \
|
||||
13.0) CU_TAG=cu130 ;; \
|
||||
12.9) CU_TAG=cu129 ;; \
|
||||
*) CU_TAG=cu130 ;; \
|
||||
esac; \
|
||||
${PYTHON_ROOT_PATH}/bin/pip install torch==${TORCH_VER} --index-url https://${PYTORCH_MIRROR}/whl/${CU_TAG}; \
|
||||
${PYTHON_ROOT_PATH}/bin/pip install --index-url ${PIP_DEFAULT_INDEX} \
|
||||
ninja setuptools wheel build numpy apache-tvm-ffi==${TVM_FFI_VER}
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
# Build sgl-deep-gemm wheel inside a CUDA-versioned container.
|
||||
#
|
||||
# Usage: build_sgl_deep_gemm.sh <PYTHON_VERSION> <CUDA_VERSION> <DEEPGEMM_SRC> [ARCH]
|
||||
# PYTHON_VERSION: e.g. 3.10
|
||||
# CUDA_VERSION: e.g. 12.9 or 13.0
|
||||
# DEEPGEMM_SRC: path to a checkout of sgl-project/DeepGEMM
|
||||
# ARCH: x86_64 (default) or aarch64
|
||||
#
|
||||
# The wheel is written into <DEEPGEMM_SRC>/dist by build_sgl_deep_gemm.sh.
|
||||
set -ex
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage: $0 <PYTHON_VERSION> <CUDA_VERSION> <DEEPGEMM_SRC> [ARCH]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PYTHON_VERSION="$1"
|
||||
CUDA_VERSION="$2"
|
||||
DEEPGEMM_SRC="$(cd "$3" && pwd)"
|
||||
ARCH="${4:-$(uname -i)}"
|
||||
|
||||
if [ "${ARCH}" = "aarch64" ]; then
|
||||
BASE_IMG="pytorch/manylinuxaarch64-builder"
|
||||
else
|
||||
BASE_IMG="pytorch/manylinux2_28-builder"
|
||||
fi
|
||||
|
||||
PY_TAG="cp${PYTHON_VERSION//.}-cp${PYTHON_VERSION//.}"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
DOCKERFILE="${REPO_ROOT}/docker/sgl-deep-gemm.Dockerfile"
|
||||
|
||||
DEPS_TAG="sgl-deep-gemm-deps:cuda${CUDA_VERSION}-${PY_TAG}-${ARCH}"
|
||||
|
||||
echo "----------------------------------------"
|
||||
echo "PYTHON_VERSION: ${PYTHON_VERSION}"
|
||||
echo "CUDA_VERSION: ${CUDA_VERSION}"
|
||||
echo "ARCH: ${ARCH}"
|
||||
echo "BASE_IMG: ${BASE_IMG}"
|
||||
echo "DEEPGEMM_SRC: ${DEEPGEMM_SRC}"
|
||||
echo "DEPS_TAG: ${DEPS_TAG}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
docker build \
|
||||
-f "${DOCKERFILE}" "$(dirname "${DOCKERFILE}")" \
|
||||
--build-arg BASE_IMG="${BASE_IMG}" \
|
||||
--build-arg CUDA_VERSION="${CUDA_VERSION}" \
|
||||
--build-arg ARCH="${ARCH}" \
|
||||
--build-arg PYTHON_VERSION="${PYTHON_VERSION}" \
|
||||
--build-arg PYTHON_TAG="${PY_TAG}" \
|
||||
-t "${DEPS_TAG}" \
|
||||
--network=host
|
||||
|
||||
mkdir -p "${DEEPGEMM_SRC}/dist"
|
||||
|
||||
docker run --rm \
|
||||
--network=host \
|
||||
-v "${DEEPGEMM_SRC}:/deepgemm" \
|
||||
-w /deepgemm \
|
||||
"${DEPS_TAG}" \
|
||||
bash build_sgl_deep_gemm.sh
|
||||
|
||||
echo "Wheels written to ${DEEPGEMM_SRC}/dist:"
|
||||
ls -lh "${DEEPGEMM_SRC}/dist"/*.whl 2>/dev/null || true
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# Rename a freshly-built sgl-deep-gemm wheel so its filename, METADATA Version,
|
||||
# and WHEEL platform tag carry the +cuXXX local version and manylinux2014_<arch>
|
||||
# tag expected by the sgl-whl index and PyPI upload step.
|
||||
#
|
||||
# Input: dist/sgl_deep_gemm-<VERSION>-py3-none-any.whl
|
||||
# Output: dist/sgl_deep_gemm-<VERSION>+<CU_TAG>-py3-none-manylinux2014_<ARCH>.whl
|
||||
#
|
||||
# Usage: rename_wheels.sh <WHEEL_DIR> <CU_TAG> <ARCH>
|
||||
# WHEEL_DIR: directory containing the *.whl file (e.g. DeepGEMM/dist)
|
||||
# CU_TAG: cu129 | cu130
|
||||
# ARCH: x86_64 | aarch64
|
||||
set -ex
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage: $0 <WHEEL_DIR> <CU_TAG> <ARCH>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WHEEL_DIR="$1"
|
||||
CU_TAG="$2"
|
||||
ARCH="$3"
|
||||
PLAT_TAG="manylinux2014_${ARCH}"
|
||||
|
||||
PYTHON="${PYTHON:-python3}"
|
||||
"${PYTHON}" -m pip install --quiet wheel
|
||||
|
||||
shopt -s nullglob
|
||||
wheel_files=("${WHEEL_DIR}"/sgl_deep_gemm-*.whl)
|
||||
if [ ${#wheel_files[@]} -eq 0 ]; then
|
||||
echo "No sgl_deep_gemm wheel found under ${WHEEL_DIR}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for wheel in "${wheel_files[@]}"; do
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap 'rm -rf -- "$TMPDIR"' ERR
|
||||
|
||||
"${PYTHON}" -m wheel unpack "$wheel" --dest "$TMPDIR"
|
||||
UNPACKED=$(find "$TMPDIR" -mindepth 1 -maxdepth 1 -type d | head -1)
|
||||
DIST_INFO=$(find "$UNPACKED" -maxdepth 1 -type d -name "*.dist-info" | head -1)
|
||||
WHEEL_META="${DIST_INFO}/WHEEL"
|
||||
METADATA_FILE="${DIST_INFO}/METADATA"
|
||||
|
||||
# Replace the py3-none-any tag with a platform-specific one.
|
||||
sed -i "s/^Tag: py3-none-any$/Tag: py3-none-${PLAT_TAG}/" "$WHEEL_META"
|
||||
|
||||
ORIG_VERSION=$(grep '^Version:' "$METADATA_FILE" | head -1 | sed 's/^Version:[[:space:]]*//')
|
||||
if [[ "$ORIG_VERSION" == *"+${CU_TAG}"* ]]; then
|
||||
NEW_VERSION="$ORIG_VERSION"
|
||||
else
|
||||
NEW_VERSION="${ORIG_VERSION}+${CU_TAG}"
|
||||
sed -i "s/^Version:.*/Version: ${NEW_VERSION}/" "$METADATA_FILE"
|
||||
OLD_BASE=$(basename "$DIST_INFO")
|
||||
NEW_BASE="${OLD_BASE/${ORIG_VERSION}/${NEW_VERSION}}"
|
||||
mv "$DIST_INFO" "${UNPACKED}/${NEW_BASE}"
|
||||
fi
|
||||
|
||||
rm -f "$wheel"
|
||||
"${PYTHON}" -m wheel pack "$UNPACKED" --dest-dir "$WHEEL_DIR"
|
||||
rm -rf "$TMPDIR"
|
||||
trap - ERR
|
||||
done
|
||||
|
||||
echo "Renamed wheels in ${WHEEL_DIR}:"
|
||||
ls -lh "${WHEEL_DIR}"/*.whl
|
||||
@@ -0,0 +1,45 @@
|
||||
# Generates a PEP 503 simple index for sgl-deep-gemm wheels under
|
||||
# sgl-whl/cu<version>/sgl-deep-gemm/index.html. Mirrors the layout used by
|
||||
# update_kernel_whl_index.py so consumers can `pip install
|
||||
# sgl-deep-gemm --extra-index-url https://...whl/cu129`.
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
SUPPORTED_CUDA_VERSIONS = ["129", "130"]
|
||||
|
||||
|
||||
def update_wheel_index(cuda_version, wheel_dir):
|
||||
index_dir = pathlib.Path(f"sgl-whl/cu{cuda_version}/sgl-deep-gemm")
|
||||
index_dir.mkdir(exist_ok=True, parents=True)
|
||||
base_url = "https://github.com/sgl-project/whl/releases/download"
|
||||
|
||||
suffix = f"+cu{cuda_version}"
|
||||
for path in sorted(pathlib.Path(wheel_dir).glob("*.whl")):
|
||||
if suffix not in path.name:
|
||||
continue
|
||||
with open(path, "rb") as f:
|
||||
sha256 = hashlib.sha256(f.read()).hexdigest()
|
||||
match = re.match(r"sgl_deep_gemm-([0-9][^-+]*)(?:\+cu[0-9]+)?-", path.name)
|
||||
if not match:
|
||||
continue
|
||||
ver = match.group(1)
|
||||
full_url = f"{base_url}/v{ver}/{path.name}#sha256={sha256}"
|
||||
with (index_dir / "index.html").open("a") as f:
|
||||
f.write(f'<a href="{full_url}">{path.name}</a><br>\n')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--cuda", type=str, required=True, choices=SUPPORTED_CUDA_VERSIONS
|
||||
)
|
||||
parser.add_argument("--wheel-dir", type=str, default="dist")
|
||||
args = parser.parse_args()
|
||||
update_wheel_index(args.cuda, args.wheel_dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user