Skip to content

Commit

Permalink
Adding steps to cache qutip wheel
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Pisal <spisal@nvidia.com>
  • Loading branch information
sacpis committed Dec 20, 2024
1 parent 1a4f99e commit 8046fe9
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
44 changes: 43 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,38 @@ 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: |
mkdir -p wheelhouse
python -m pip wheel qutip --wheel-dir=./wheelhouse
ls -lh ./wheelhouse
- name: Upload Wheel Artifact
uses: actions/upload-artifact@v4
with:
name: qutip-wheel-${{ matrix.platform }}
path: ./wheelhouse
retention-days: 7

docker_image:
name: Create Docker images
needs: config
needs: [config, cache_qutip_wheel]
strategy:
matrix:
platform: [amd64, arm64]
Expand All @@ -227,6 +256,19 @@ jobs:
devdeps_image: ${{ fromJson(needs.config.outputs.json).image_hash[format('{0}-gcc11', matrix.platform)] }}
devdeps_cache: ${{ fromJson(needs.config.outputs.json).cache_key[format('{0}-gcc11', matrix.platform)] }}
devdeps_archive: ${{ fromJson(needs.config.outputs.json).tar_archive[format('{0}-gcc11', matrix.platform)] }}
steps:
- name: Download Cached qutip Wheel
uses: actions/download-artifact@v4
with:
name: qutip-wheel-${{ matrix.platform }}
path: ./wheelhouse

- name: Build Docker Image
run: |
docker build \
--build-arg QUTIP_WHEEL=./wheelhouse/qutip*.whl \
--build-arg DEVDEPS_IMAGE=${{ fromJson(needs.config.outputs.json).image_hash[format('{0}-gcc11', matrix.platform)] }} \
--tag myrepo/cudaq:${{ matrix.platform }} .
python_wheels:
name: Create Python wheels
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ jobs:
org.opencontainers.image.title=cuda-quantum-dev
org.opencontainers.image.description=Dev environment for CUDA Quantum (debug build)
- name: Download Cached qutip Wheel
uses: actions/download-artifact@v4
with:
name: qutip-wheel-${{ inputs.platforms }}
path: ./wheelhouse

- name: Build cuda-quantum-dev image (debug)
id: docker_build
uses: docker/build-push-action@v5
Expand All @@ -329,6 +335,7 @@ jobs:
file: ./docker/build/cudaq.dev.Dockerfile
build-args: |
base_image=${{ steps.prereqs.outputs.base_image }}
QUTIP_WHEEL=./wheelhouse/qutip*.whl
install="CMAKE_BUILD_TYPE=Debug"
git_source_sha=${{ github.sha }}
tags: ${{ steps.metadata.outputs.tags }}
Expand Down Expand Up @@ -582,6 +589,12 @@ jobs:
run: |
docker run --privileged multiarch/qemu-user-static:latest --reset -p yes --credential yes
- name: Download Cached qutip Wheel
uses: actions/download-artifact@v4
with:
name: qutip-wheel-${{ inputs.platforms }}
path: ./wheelhouse

- name: Build cuda-quantum image
id: cudaq_build
if: success() && !cancelled()
Expand All @@ -592,6 +605,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=./wheelhouse/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 "$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 "$QUTIP_WHEEL"; \
else \
pip install qutip; \
fi

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

ARG release_version=
Expand Down

0 comments on commit 8046fe9

Please sign in to comment.