Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding steps to cache qutip wheel #2486

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
29 changes: 28 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,36 @@ jobs:
devdeps_archive: ${{ fromJson(needs.config.outputs.json).tar_archive[format('{0}-{1}', matrix.platform, matrix.toolchain)] }}
export_environment: ${{ github.event_name == 'workflow_dispatch' && inputs.export_environment }}

cache_qutip_wheel:
name: Build and Cache qutip Wheel
runs-on: ubuntu-latest
strategy:
matrix:
platform: [amd64, arm64]
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Dependencies
run: |
python -m pip install --upgrade pip setuptools wheel

- name: Build qutip Wheel
run: |
python -m pip wheel "qutip<5" --wheel-dir=/tmp/wheels

- name: Upload Wheel Artifact
uses: actions/upload-artifact@v4
with:
name: qutip-wheel-linux-${{ matrix.platform }}
path: /tmp/wheels
retention-days: 7

docker_image:
name: Create Docker images
needs: config
needs: [config, cache_qutip_wheel]
strategy:
matrix:
platform: [amd64, arm64]
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,18 @@ jobs:
org.opencontainers.image.title=cuda-quantum-dev
org.opencontainers.image.description=Dev environment for CUDA Quantum (debug build)

- name: Transform Platform Name
id: transform_platform
run: |
transformed_platform=$(echo "${{ inputs.platforms }}" | sed 's/\//-/g')
echo "transformed_platform=$transformed_platform" >> $GITHUB_ENV

- name: Download Cached qutip Wheel
uses: actions/download-artifact@v4
with:
name: qutip-wheel-${{ env.transformed_platform }}
path: /tmp/wheels

- name: Build cuda-quantum-dev image (debug)
id: docker_build
uses: docker/build-push-action@v5
Expand All @@ -329,6 +341,7 @@ jobs:
file: ./docker/build/cudaq.dev.Dockerfile
build-args: |
base_image=${{ steps.prereqs.outputs.base_image }}
QUTIP_WHEEL=/tmp/wheels/qutip-*.whl
install="CMAKE_BUILD_TYPE=Debug"
git_source_sha=${{ github.sha }}
tags: ${{ steps.metadata.outputs.tags }}
Expand Down Expand Up @@ -582,6 +595,23 @@ jobs:
run: |
docker run --privileged multiarch/qemu-user-static:latest --reset -p yes --credential yes

- name: Transform Platform Name
id: transform_platform
run: |
transformed_platform=$(echo "${{ inputs.platforms }}" | sed 's/\//-/g')
echo "transformed_platform=$transformed_platform" >> $GITHUB_ENV

- name: Download Cached qutip Wheel
uses: actions/download-artifact@v4
with:
name: qutip-wheel-${{ env.transformed_platform }}
path: /tmp/wheels

- name: Extract qutip Wheel
run: |
mkdir -p /tmp/wheels
unzip /tmp/wheels/qutip-wheel-${{ env.transformed_platform }}.zip -d /tmp/wheels

- name: Build cuda-quantum image
id: cudaq_build
if: success() && !cancelled()
Expand All @@ -592,6 +622,7 @@ jobs:
build-args: |
cudaqdev_image=${{ steps.prereqs.outputs.dev_image_name }}@${{ steps.release_build.outputs.digest }}
base_image=${{ steps.prereqs.outputs.base_image }}
QUTIP_WHEEL=/tmp/wheels/qutip-*.whl
release_version=${{ steps.prereqs.outputs.image_tag }}
tags: ${{ steps.cudaq_metadata.outputs.tags }}
labels: ${{ steps.cudaq_metadata.outputs.labels }}
Expand Down
10 changes: 10 additions & 0 deletions docker/build/cudaq.dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ ARG destination="$CUDAQ_REPO_ROOT"
ADD "$workspace" "$destination"
WORKDIR "$destination"

# Accept QUTIP_WHEEL as a build argument
ARG QUTIP_WHEEL

# Install qutip from the wheel if provided
RUN if [ -n "$QUTIP_WHEEL" ]; then \
pip install $(echo $QUTIP_WHEEL); \
else \
pip install qutip; \
fi

# mpich or openmpi
ARG mpi=
RUN if [ -n "$mpi" ]; \
Expand Down
12 changes: 11 additions & 1 deletion docker/release/cudaq.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& ln -s /bin/python3 /bin/python
RUN apt-get update && apt-get install -y --no-install-recommends gcc g++ python3-dev \
# Ref: https://github.com/qutip/qutip/issues/2412
&& python3 -m pip install --no-cache-dir notebook==7.1.3 "qutip<5" matplotlib \
&& python3 -m pip install --no-cache-dir notebook==7.1.3 matplotlib \
&& apt-get remove -y gcc g++ python3-dev \
&& apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*

# Accept QUTIP_WHEEL as a build argument
ARG QUTIP_WHEEL

# Install qutip from the wheel if provided
RUN if [ -n "$QUTIP_WHEEL" ]; then \
pip install $(echo $QUTIP_WHEEL); \
else \
pip install qutip; \
fi

# Copy over the CUDA-Q installation, and the necessary compiler tools.

ARG release_version=
Expand Down
Loading