diff --git a/.github/workflows/concrete_python_release_gpu.yml b/.github/workflows/concrete_python_release_gpu.yml new file mode 100644 index 0000000000..9c8fb56dc2 --- /dev/null +++ b/.github/workflows/concrete_python_release_gpu.yml @@ -0,0 +1,171 @@ +name: Concrete Python Release (GPU) + +on: + workflow_dispatch: + inputs: + instance_id: + description: 'Instance ID' + type: string + instance_image_id: + description: 'Instance AMI ID' + type: string + instance_type: + description: 'Instance product type' + type: string + runner_name: + description: 'Action runner name' + type: string + request_id: + description: 'Slab request ID' + type: string + user_inputs: + description: 'either "nightly" or "public" or "private" to specify the release type' + required: true + default: 'nightly' + type: string + +env: + DOCKER_IMAGE_TEST: ghcr.io/zama-ai/concrete-compiler + CUDA_PATH: /usr/local/cuda-12.3 + GCC_VERSION: 11 + GLIB_VER: 2_28 + RELEASE_TYPE: ${{ inputs.user_inputs }} + +jobs: + build-linux-x86: + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + + runs-on: ${{ github.event.inputs.runner_name }} + steps: + - name: Log instance configuration + run: | + echo "IDs: ${{ inputs.instance_id }}" + echo "AMI: ${{ inputs.instance_image_id }}" + echo "Type: ${{ inputs.instance_type }}" + echo "Request ID: ${{ inputs.request_id }}" + echo "User Inputs: ${{ inputs.user_inputs }}" + + - name: Set up GitHub environment + run: | + echo "HOME=/home/ubuntu" >> "${GITHUB_ENV}" + + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 + + - name: Set release version (nightly) + if: ${{ env.RELEASE_TYPE == 'nightly' }} + run: | + NIGHTLY_VERSION=$(date +"%Y.%m.%d") + NIGHTLY_VERSION_ONE_NUMBER=$(date +"%Y%m%d") + LATEST_RELEASE_VERSION=`git tag -l |grep "v.*" |sort |tail -n 1 | grep -e '[0-9].*' -o` + echo "__version__ = \"${LATEST_RELEASE_VERSION}-dev${NIGHTLY_VERSION_ONE_NUMBER}\"" >| frontends/concrete-python/version.txt + git tag nightly-$NIGHTLY_VERSION || true + git push origin nightly-$NIGHTLY_VERSION || true + + - name: Set release version (public) + if: ${{ env.RELEASE_TYPE == 'public' }} + run: echo "__version__ = \"`git describe --tags --abbrev=0 | grep -e '[0-9].*' -o`\"" >| frontends/concrete-python/version.txt + + - name: Expose release version from Python + run: cp frontends/concrete-python/version.txt frontends/concrete-python/concrete/fhe/version.py + + - name: Build wheel + uses: addnab/docker-run-action@v3 + id: build-compiler-bindings + with: + registry: ghcr.io + image: ${{ env.DOCKER_IMAGE_TEST }} + username: ${{ secrets.GHCR_LOGIN }} + password: ${{ secrets.GHCR_PASSWORD }} + options: >- + -v ${{ github.workspace }}:/concrete + -v ${{ github.workspace }}/build:/build + -v ${{ env.SSH_AUTH_SOCK }}:/ssh.socket + -e SSH_AUTH_SOCK=/ssh.socket + --gpus all + shell: bash + run: | + set -e + + rustup toolchain install nightly-2024-01-31 + rm -rf /build/* + + export PYTHON=${{ format('python{0}', matrix.python-version) }} + echo "Using $PYTHON" + + dnf -y install graphviz graphviz-devel + + cd /concrete/frontends/concrete-python + make PYTHON=$PYTHON venv + source .venv/bin/activate + + cd /concrete/compilers/concrete-compiler/compiler + make BUILD_DIR=/build CCACHE=ON DATAFLOW_EXECUTION_ENABLED=OFF Python3_EXECUTABLE=$(which python) \ + CUDA_SUPPORT=ON CUDA_PATH=${{ env.CUDA_PATH }} python-bindings + + echo "Debug: ccache statistics (after the build):" + ccache -s + + cd /concrete/frontends/concrete-python + + export COMPILER_BUILD_DIRECTORY="/build" + make whl + + deactivate + + - name: Upload wheel + uses: actions/upload-artifact@v4 + with: + name: ${{ format('wheel-{0}-linux-x86', matrix.python-version) }} + path: frontends/concrete-python/dist/*manylinux*.whl + retention-days: 3 + + + test-linux-x86: + needs: [build-linux-x86] + continue-on-error: true + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + runs-on: ${{ github.event.inputs.runner_name }} + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Download wheels + uses: actions/download-artifact@v4 + with: + name: ${{ format('wheel-{0}-linux-x86', matrix.python-version) }} + path: ${{ format('wheel-{0}-linux-x86', matrix.python-version) }} + - name: Checkout the repository + uses: actions/checkout@v3 + with: + submodules: recursive + path: repo + - name: Test wheel + run: | + WHEEL_DIR=$(pwd)/${{ format('wheel-{0}-linux-x86', matrix.python-version) }} + CONCRETE_PYTHON=$(pwd)/repo/frontends/concrete-python + + # Initialize an empty test environment + cd $(mktemp -d) + python -m venv .testenv && source .testenv/bin/activate + + # Install the concrete-python wheel + pip install $WHEEL_DIR/*.whl + + # Install extra requirements for tests + sudo apt update -y + sudo apt install -y graphviz libgraphviz-dev + pip install -r $CONCRETE_PYTHON/requirements.extra-full.txt + pip install -r $CONCRETE_PYTHON/requirements.dev.txt + + # Running tests + cd $CONCRETE_PYTHON + make pytest-gpu diff --git a/ci/slab.toml b/ci/slab.toml index 7edc563644..c7b1b2695a 100644 --- a/ci/slab.toml +++ b/ci/slab.toml @@ -105,3 +105,8 @@ check_run_name = "Concrete Python Tests (Linux Gpu)" workflow = "concrete_python_release.yml" profile = "m7i-cpu-test" check_run_name = "Concrete Python Release" + +[command.concrete-python-release-gpu] +workflow = "concrete_python_release_gpu.yml" +profile = "gpu-test" +check_run_name = "Concrete Python Release (GPU)"