diff --git a/.github/workflows/Dockerfile.manylinux_2_28 b/.github/workflows/Dockerfile.manylinux_2_28 new file mode 100644 index 000000000..84fc6fe8d --- /dev/null +++ b/.github/workflows/Dockerfile.manylinux_2_28 @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 FlyDSL Project Contributors +# +# Multi-stage Dockerfile for building manylinux_2_28 wheels with ROCm support. +# Strategy (same as pytorch/manylinux2_28-builder:rocm*): +# Stage 1: Copy Python interpreters from quay.io/pypa/manylinux_2_28_x86_64 +# Stage 2: Use rocm/dev-almalinux-8 (AlmaLinux 8 = glibc 2.28) with full ROCm SDK +# Merge: Python toolchains + ROCm + build deps in one image +# +# Build: +# docker build \ +# --build-arg ROCM_VERSION=7.2 \ +# -t flydsl/manylinux_2_28:rocm7.2 \ +# - < .github/workflows/Dockerfile.manylinux_2_28 +# +# Supported ROCm versions: 7.0, 7.1, 7.2 + +ARG ROCM_VERSION=7.2 + +# --------------------------------------------------------------------------- +# Stage 1: Grab pre-built CPython interpreters from the official manylinux image +# --------------------------------------------------------------------------- +FROM quay.io/pypa/manylinux_2_28_x86_64 AS python-source + +# --------------------------------------------------------------------------- +# Stage 2: ROCm + AlmaLinux 8 (glibc 2.28) +# --------------------------------------------------------------------------- +FROM rocm/dev-almalinux-8:${ROCM_VERSION}-complete + +# /opt/python/cpXYZ-cpXYZ are symlinks to /opt/_internal/cpython-X.Y.Z +# and pip shebangs point to /opt/_internal/... paths, so copy both. +COPY --from=python-source /opt/_internal /opt/_internal +COPY --from=python-source /opt/python /opt/python +# Copy patchelf binary (statically linked, required by auditwheel) +COPY --from=python-source /usr/local/bin/patchelf /usr/local/bin/patchelf + +# Install build dependencies +RUN dnf install -y \ + ninja-build \ + gcc \ + gcc-c++ \ + make \ + git \ + zlib-devel \ + openssl-devel \ + libffi-devel \ + && dnf clean all + +# Install cmake and ninja via pip (dnf versions are too old for LLVM) +RUN /opt/python/cp312-cp312/bin/pip install cmake ninja + +# Put python3.12 and cmake on PATH +ENV PATH="/opt/python/cp312-cp312/bin:${PATH}" + +WORKDIR /workspace + +LABEL maintainer="FlyDSL Contributors" +LABEL description="manylinux_2_28 + ROCm wheel builder for FlyDSL" diff --git a/.github/workflows/build-whl.yaml b/.github/workflows/build-whl.yaml index 059ad2702..ffb66e2cb 100644 --- a/.github/workflows/build-whl.yaml +++ b/.github/workflows/build-whl.yaml @@ -7,10 +7,6 @@ on: description: 'Release type determines target S3 bucket (devreleases, nightlies, release)' type: string required: true - docker_image: - description: 'Docker base image for build' - type: string - required: true upload_s3_staging: description: 'Upload built wheels to the S3 staging bucket' type: boolean @@ -35,6 +31,21 @@ jobs: with: path: flydsl + - name: Build manylinux Docker image + run: | + ROCM_VERSION=7.2 + IMAGE="flydsl/manylinux_2_28:rocm${ROCM_VERSION}" + if docker image inspect "${IMAGE}" >/dev/null 2>&1; then + echo "Reusing existing image: ${IMAGE}" + else + # The Dockerfile is self-contained, so avoid sending the full repo as build context. + docker build \ + --build-arg ROCM_VERSION="${ROCM_VERSION}" \ + -t "${IMAGE}" \ + - < flydsl/.github/workflows/Dockerfile.manylinux_2_28 + fi + echo "MANYLINUX_IMAGE=${IMAGE}" >> $GITHUB_ENV + - name: Start build container run: | docker run -dt --network=host --user root \ @@ -42,14 +53,24 @@ jobs: --ipc=host --shm-size 16g \ -w /flydsl \ --name flydsl_build \ - ${{ inputs.docker_image }} + "${MANYLINUX_IMAGE}" - name: Install build dependencies run: | - docker exec flydsl_build bash -c "apt-get update && apt-get install -y cmake build-essential patchelf software-properties-common" - docker exec flydsl_build bash -c "add-apt-repository -y ppa:deadsnakes/ppa && apt-get update && apt-get install -y python3.12 python3.12-dev python3.12-venv" - docker exec flydsl_build bash -c "python3 -m pip install -U pip setuptools wheel" - docker exec flydsl_build bash -c "python3 -m pip install ninja>=1.11.1" + # Create pythonX.Y symlinks so build_wheels.sh can find them. + # Skip free-threaded builds (cpXYZt) — they would overwrite the normal symlink. + docker exec flydsl_build bash -c ' + for d in /opt/python/cp*; do + case "${d}" in *t) continue ;; esac + py="${d}/bin/python" + [ -x "${py}" ] || continue + ver=$("${py}" -c "import sys; print(f\"{sys.version_info.major}.{sys.version_info.minor}\")") + ln -sf "${py}" "/usr/local/bin/python${ver}" + echo " python${ver} -> ${py}" + done + ln -sf /usr/local/bin/python3.12 /usr/local/bin/python3 + ' + docker exec flydsl_build bash -c "python3 -m pip install -q nanobind" docker exec flydsl_build bash -c "git config --global --add safe.directory '*'" - name: Restore cached MLIR install tarball @@ -57,7 +78,7 @@ jobs: uses: actions/cache@v4 with: path: mlir_install.tgz - key: mlir-install-${{ hashFiles('flydsl/thirdparty/llvm-hash.txt', 'flydsl/scripts/build_llvm.sh', 'flydsl/CMakeLists.txt', 'flydsl/.github/workflows/build-whl.yaml') }} + key: mlir-install-manylinux228-${{ hashFiles('flydsl/thirdparty/llvm-hash.txt', 'flydsl/scripts/build_llvm.sh', 'flydsl/CMakeLists.txt') }} - name: Use cached MLIR install tarball if: steps.mlir-cache.outputs.cache-hit == 'true' @@ -74,7 +95,12 @@ jobs: - name: Build wheels run: | - docker exec flydsl_build bash -c "export MLIR_PATH=/llvm-project/mlir_install && export EXPECTED_GLIBC=2.35 && export FLYDSL_RELEASE_TYPE=${{ inputs.release_type }} && cd /flydsl && bash scripts/build_wheels.sh" + docker exec \ + -e MLIR_PATH=/llvm-project/mlir_install \ + -e EXPECTED_GLIBC=2.28 \ + -e FLYDSL_RELEASE_TYPE=${{ inputs.release_type }} \ + -e "FLYDSL_PACKAGE_VERSION_OVERRIDE=${PACKAGE_VERSION_OVERRIDE}" \ + flydsl_build bash -c "cd /flydsl && bash scripts/build_wheels.sh" docker cp flydsl_build:/flydsl/dist ./dist docker cp flydsl_build:/flydsl/build-fly/build_py312/bin/fly-opt ./dist/fly-opt @@ -97,7 +123,7 @@ jobs: - name: Build summary if: always() env: - SUMMARY_DOCKER_IMAGE: ${{ inputs.docker_image }} + SUMMARY_DOCKER_IMAGE: ${{ env.MANYLINUX_IMAGE }} SUMMARY_LLVM_COMMIT: $(cat flydsl/thirdparty/llvm-hash.txt | tr -d '[:space:]') SUMMARY_MLIR_CACHE: ${{ steps.mlir-cache.outputs.cache-hit == 'true' && 'Hit' || 'Miss (rebuilt)' }} SUMMARY_RELEASE_TYPE: ${{ inputs.release_type }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a5b43001f..b5153f0ff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ on: type: boolean default: false docker_image: - description: 'Docker base image for build and test' + description: 'Docker base image for test' type: string default: "rocm/pytorch:rocm7.2_ubuntu22.04_py3.10_pytorch_release_2.8.0" concurrency: @@ -26,7 +26,6 @@ jobs: uses: ./.github/workflows/build-whl.yaml with: release_type: ${{ github.event_name == 'schedule' && 'nightlies' || 'devreleases' }} - docker_image: ${{ inputs.docker_image || 'rocm/pytorch:rocm7.2_ubuntu22.04_py3.10_pytorch_release_2.8.0' }} permissions: id-token: write contents: read diff --git a/.github/workflows/publish-pypi.yaml b/.github/workflows/publish-pypi.yaml index 9588656d8..277189662 100644 --- a/.github/workflows/publish-pypi.yaml +++ b/.github/workflows/publish-pypi.yaml @@ -45,7 +45,6 @@ jobs: uses: ./.github/workflows/build-whl.yaml with: release_type: release - docker_image: rocm/pytorch:rocm7.2_ubuntu22.04_py3.10_pytorch_release_2.8.0 upload_s3_staging: false permissions: id-token: write diff --git a/python/flydsl/__init__.py b/python/flydsl/__init__.py index 872aa58f2..7bbd0360c 100644 --- a/python/flydsl/__init__.py +++ b/python/flydsl/__init__.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2025 FlyDSL Project Contributors -__version__ = "0.1.4" +__version__ = "0.1.4.post1" # FFM simulator compatibility shim (no-op outside simulator sessions). from ._compat import _maybe_preload_system_comgr # noqa: E402 diff --git a/scripts/build_llvm.sh b/scripts/build_llvm.sh index b4ac575e7..8e262c294 100755 --- a/scripts/build_llvm.sh +++ b/scripts/build_llvm.sh @@ -85,7 +85,6 @@ cmake -G "$GENERATOR" \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_INSTALL_UTILS=ON \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ - -DMLIR_ENABLE_ROCM_RUNNER=ON \ -DMLIR_BINDINGS_PYTHON_NB_DOMAIN=mlir \ -DPython3_EXECUTABLE=$(which python3) \ -Dnanobind_DIR="$NANOBIND_DIR" \