Fix sgl-deep-gemm release workflow (#24385)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Baizhou Zhang
2026-05-04 14:36:59 -07:00
committed by GitHub
co-authored by Claude Opus 4.7
parent 29dd3a36c0
commit f059e0264a
3 changed files with 117 additions and 43 deletions
+61 -2
View File
@@ -7,7 +7,10 @@
# 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.
# Writes:
# <DEEPGEMM_SRC>/dist/ — wheel(s) tagged +cu129 / +cu130 and manylinux
# <DEEPGEMM_SRC>/dist-pypi/ — cu130 only: same wheel(s) with +cu130 stripped
# (PyPI rejects local-version segments)
set -ex
if [ $# -lt 3 ]; then
@@ -20,6 +23,15 @@ CUDA_VERSION="$2"
DEEPGEMM_SRC="$(cd "$3" && pwd)"
ARCH="${4:-$(uname -i)}"
case "${CUDA_VERSION}" in
13.0) CU_TAG=cu130 ;;
12.9) CU_TAG=cu129 ;;
*)
echo "Unsupported CUDA_VERSION: ${CUDA_VERSION}" >&2
exit 1
;;
esac
if [ "${ARCH}" = "aarch64" ]; then
BASE_IMG="pytorch/manylinuxaarch64-builder"
else
@@ -31,12 +43,14 @@ 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"
RENAME_SCRIPT="${SCRIPT_DIR}/rename_sgl_deep_gemm_whl.sh"
DEPS_TAG="sgl-deep-gemm-deps:cuda${CUDA_VERSION}-${PY_TAG}-${ARCH}"
echo "----------------------------------------"
echo "PYTHON_VERSION: ${PYTHON_VERSION}"
echo "CUDA_VERSION: ${CUDA_VERSION}"
echo "CU_TAG: ${CU_TAG}"
echo "ARCH: ${ARCH}"
echo "BASE_IMG: ${BASE_IMG}"
echo "DEEPGEMM_SRC: ${DEEPGEMM_SRC}"
@@ -55,6 +69,7 @@ docker build \
mkdir -p "${DEEPGEMM_SRC}/dist"
# 1) Build the wheel inside the deps container.
docker run --rm \
--network=host \
-v "${DEEPGEMM_SRC}:/deepgemm" \
@@ -62,5 +77,49 @@ docker run --rm \
"${DEPS_TAG}" \
bash build_sgl_deep_gemm.sh
echo "Wheels written to ${DEEPGEMM_SRC}/dist:"
# 2) Rename inside the same image so we have a working pip / wheel CLI and can
# rewrite the root-owned wheel files written by the build container above.
docker run --rm \
-v "${DEEPGEMM_SRC}:/deepgemm" \
-v "${RENAME_SCRIPT}:/rename_sgl_deep_gemm_whl.sh:ro" \
-w /deepgemm \
"${DEPS_TAG}" \
bash /rename_sgl_deep_gemm_whl.sh dist "${CU_TAG}" "${ARCH}"
# 3) cu130 only: produce a sibling dist-pypi/ with the +cu130 local-version
# stripped (PyPI rejects local versions).
if [ "${CU_TAG}" = "cu130" ]; then
docker run --rm \
-v "${DEEPGEMM_SRC}:/deepgemm" \
-w /deepgemm \
"${DEPS_TAG}" \
bash -c '
set -eux
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/
'
fi
echo "Wheels in ${DEEPGEMM_SRC}/dist:"
ls -lh "${DEEPGEMM_SRC}/dist"/*.whl 2>/dev/null || true
if [ "${CU_TAG}" = "cu130" ]; then
echo "PyPI-ready wheels in ${DEEPGEMM_SRC}/dist-pypi:"
ls -lh "${DEEPGEMM_SRC}/dist-pypi"/*.whl 2>/dev/null || true
fi