forked from NVIDIA/cudaqx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into first_shot_memory
- Loading branch information
Showing
9 changed files
with
324 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"cudaq": { | ||
"repository": "NVIDIA/cuda-quantum", | ||
"ref": "bd499151326950ffb163b2afb928ca882f926ab4" | ||
"ref": "d8930461128a9c564d636d7531d21f836eb1a59e" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
name: Build dev images | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
force_rebuild: | ||
type: boolean | ||
required: true | ||
description: 'Force rebuild even if image tags already exist' | ||
default: false | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-cudaqx-dev: | ||
name: Build CUDA-QX Dev Image | ||
if: ${{ github.repository == 'NVIDIA/cudaqx' }} | ||
strategy: | ||
matrix: | ||
platform: [amd64, arm64] | ||
fail-fast: false | ||
runs-on: linux-${{ matrix.platform }}-cpu8 | ||
steps: | ||
- name: Login to GitHub CR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ github.token }} | ||
|
||
- name: Get code | ||
uses: actions/checkout@v4 | ||
with: | ||
set-safe-directory: true | ||
|
||
- name: Get required CUDA-Q version | ||
id: get-cudaq-version | ||
uses: ./.github/actions/get-cudaq-version | ||
|
||
- name: Get additional metadata | ||
id: get-cudaq-version-short | ||
run: | | ||
shortref=$(echo "${{ steps.get-cudaq-version.outputs.ref }}" | head -c8) | ||
commit_date=$(curl -s "https://api.github.com/repos/NVIDIA/cuda-quantum/commits/${{ steps.get-cudaq-version.outputs.ref }}" | jq -r '.commit.committer.date' | cut -dT -f1) | ||
echo "shortref=$shortref" >> $GITHUB_OUTPUT | ||
echo "commit_date=$commit_date" >> $GITHUB_OUTPUT | ||
- name: Check if image already exists | ||
id: check-image | ||
run: | | ||
IMAGE_TAG="${{ steps.get-cudaq-version-short.outputs.commit_date }}-${{ steps.get-cudaq-version-short.outputs.shortref }}-${{ matrix.platform }}" | ||
CONTAINER_VERSION_METADATA=$(curl -s -L -H "Accept: applicat/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/orgs/NVIDIA/packages/container/cudaqx-dev/versions") | ||
CONTAINER_TAGS=$(echo $CONTAINER_VERSION_METADATA | jq -r '.[] | .metadata.container.tags[]') | ||
if echo "$CONTAINER_TAGS" | grep -qx "$IMAGE_TAG"; then | ||
echo "Image tag $IMAGE_TAG already exists. Skipping build." | ||
echo "IMAGE_EXISTS=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "Image tag $IMAGE_TAG does not exist. Proceeding with build." | ||
echo "IMAGE_EXISTS=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Set up context for buildx | ||
if: ${{ inputs.force_rebuild || steps.check-image.outputs.IMAGE_EXISTS == 'false' }} | ||
run: | | ||
docker context create builder_context | ||
shell: bash --noprofile --norc -euo pipefail {0} | ||
|
||
- name: Set up buildx runner | ||
if: ${{ inputs.force_rebuild ||steps.check-image.outputs.IMAGE_EXISTS == 'false' }} | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
endpoint: builder_context | ||
driver-opts: network=host | ||
|
||
- name: Build dev image | ||
if: ${{ inputs.force_rebuild ||steps.check-image.outputs.IMAGE_EXISTS == 'false' }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: ./docker/build_env/cudaqx.dev.Dockerfile | ||
tags: | | ||
ghcr.io/nvidia/cudaqx-dev:${{ steps.get-cudaq-version-short.outputs.commit_date }}-${{ steps.get-cudaq-version-short.outputs.shortref }}-${{ matrix.platform }} | ||
ghcr.io/nvidia/cudaqx-dev:${{ steps.get-cudaq-version-short.outputs.shortref }}-${{ matrix.platform }} | ||
ghcr.io/nvidia/cudaqx-dev:latest-${{ matrix.platform }} | ||
platforms: linux/${{ matrix.platform }} | ||
push: true | ||
|
||
build-cudaqx-pydev: | ||
name: Build CUDA-QX Python Dev Image | ||
if: ${{ github.repository == 'NVIDIA/cudaqx' }} | ||
strategy: | ||
matrix: | ||
python: ['3.10', '3.11', '3.12'] | ||
platform: ['amd64', 'arm64'] | ||
fail-fast: false | ||
runs-on: linux-${{ matrix.platform }}-cpu8 | ||
steps: | ||
- name: Login to GitHub CR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ github.token }} | ||
|
||
- name: Get code | ||
uses: actions/checkout@v4 | ||
with: | ||
set-safe-directory: true | ||
|
||
- name: Get required CUDA-Q version | ||
id: get-cudaq-version | ||
uses: ./.github/actions/get-cudaq-version | ||
|
||
- name: Get additional metadata | ||
id: get-cudaq-version-short | ||
run: | | ||
shortref=$(echo "${{ steps.get-cudaq-version.outputs.ref }}" | head -c8) | ||
commit_date=$(curl -s "https://api.github.com/repos/NVIDIA/cuda-quantum/commits/${{ steps.get-cudaq-version.outputs.ref }}" | jq -r '.commit.committer.date' | cut -dT -f1) | ||
echo "shortref=$shortref" >> $GITHUB_OUTPUT | ||
echo "commit_date=$commit_date" >> $GITHUB_OUTPUT | ||
- name: Check if image already exists | ||
id: check-image | ||
run: | | ||
IMAGE_TAG="${{ steps.get-cudaq-version-short.outputs.commit_date }}-${{ steps.get-cudaq-version-short.outputs.shortref }}-${{ matrix.platform }}" | ||
CONTAINER_VERSION_METADATA=$(curl -s -L -H "Accept: applicat/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/orgs/NVIDIA/packages/container/cudaqx-dev/versions") | ||
CONTAINER_TAGS=$(echo $CONTAINER_VERSION_METADATA | jq -r '.[] | .metadata.container.tags[]') | ||
if echo "$CONTAINER_TAGS" | grep -qx "$IMAGE_TAG"; then | ||
echo "Image tag $IMAGE_TAG already exists. Skipping build." | ||
echo "IMAGE_EXISTS=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "Image tag $IMAGE_TAG does not exist. Proceeding with build." | ||
echo "IMAGE_EXISTS=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Set up context for buildx | ||
if: ${{ inputs.force_rebuild ||steps.check-image.outputs.IMAGE_EXISTS == 'false' }} | ||
run: | | ||
docker context create builder_context | ||
shell: bash --noprofile --norc -euo pipefail {0} | ||
|
||
- name: Set up buildx runner | ||
if: ${{ inputs.force_rebuild ||steps.check-image.outputs.IMAGE_EXISTS == 'false' }} | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
endpoint: builder_context | ||
driver-opts: network=host | ||
|
||
- name: Build pydev image | ||
if: ${{ inputs.force_rebuild ||steps.check-image.outputs.IMAGE_EXISTS == 'false' }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: ./docker/build_env/cudaqx.wheel.Dockerfile | ||
build-args: | | ||
base_image=ghcr.io/nvidia/cuda-quantum-devdeps:manylinux-${{ matrix.platform }}-cu12.0-gcc11-main | ||
python_version=${{ matrix.python }} | ||
tags: | | ||
ghcr.io/nvidia/cudaqx-dev:${{ steps.get-cudaq-version-short.outputs.commit_date }}-${{ steps.get-cudaq-version-short.outputs.shortref }}-py${{ matrix.python }}-${{ matrix.platform }} | ||
ghcr.io/nvidia/cudaqx-dev:${{ steps.get-cudaq-version-short.outputs.shortref }}-py${{ matrix.python }}-${{ matrix.platform }} | ||
ghcr.io/nvidia/cudaqx-dev:latest-py${{ matrix.python }}-${{ matrix.platform }} | ||
platforms: linux/${{ matrix.platform }} | ||
push: true | ||
|
||
cleanup: | ||
name: Cleanup | ||
needs: [build-cudaqx-dev, build-cudaqx-pydev] | ||
runs-on: ubuntu-latest | ||
if: ${{ github.repository == 'NVIDIA/cudaqx' }} | ||
steps: | ||
- name: Delete untagged images | ||
uses: actions/delete-package-versions@v5 | ||
with: | ||
package-name: cudaqx-dev | ||
package-type: 'container' | ||
min-versions-to-keep: 0 | ||
delete-only-untagged-versions: 'true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# ============================================================================ # | ||
# Copyright (c) 2025 NVIDIA Corporation & Affiliates. # | ||
# All rights reserved. # | ||
# # | ||
# This source code and the accompanying materials are made available under # | ||
# the terms of the Apache License 2.0 which accompanies this distribution. # | ||
# ============================================================================ # | ||
|
||
FROM ghcr.io/nvidia/cuda-quantum-devdeps:ext-cu12.0-gcc11-main | ||
|
||
LABEL org.opencontainers.image.description="Dev tools for building and testing CUDA-QX libraries" | ||
LABEL org.opencontainers.image.source="https://github.com/NVIDIA/cudaqx" | ||
LABEL org.opencontainers.image.title="cuda-qx-dev" | ||
LABEL org.opencontainers.image.url="https://github.com/NVIDIA/cudaqx" | ||
|
||
RUN apt-get update && apt-get install -y gfortran libblas-dev jq cuda-nvtx-12-0 \ | ||
&& python3 -m pip install cmake --user \ | ||
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
COPY .cudaq_version /cudaq_version | ||
|
||
RUN mkdir -p /workspaces/cudaq && cd /workspaces/cudaq \ | ||
&& git init \ | ||
&& CUDAQ_REPO=$(jq -r '.cudaq.repository' /cudaq_version) \ | ||
&& CUDAQ_COMMIT=$(jq -r '.cudaq.ref' /cudaq_version) \ | ||
&& git remote add origin https://github.com/${CUDAQ_REPO} \ | ||
&& git fetch -q --depth=1 origin ${CUDAQ_COMMIT} \ | ||
&& git reset --hard FETCH_HEAD \ | ||
&& bash scripts/build_cudaq.sh -v \ | ||
&& rm -rf build | ||
|
||
#RUN mkdir -p /workspaces/cudaqx && cd /workspaces/cudaqx \ | ||
# && ~/.local/bin/cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCUDAQ_DIR=~/.cudaq/lib/cmake/cudaq .. \ | ||
# && ninja install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# ============================================================================ # | ||
# Copyright (c) 2025 NVIDIA Corporation & Affiliates. # | ||
# All rights reserved. # | ||
# # | ||
# This source code and the accompanying materials are made available under # | ||
# the terms of the Apache License 2.0 which accompanies this distribution. # | ||
# ============================================================================ # | ||
|
||
ARG base_image=ghcr.io/nvidia/cuda-quantum-devdeps:manylinux-amd64-cu12.0-gcc11-main | ||
FROM ${base_image} | ||
|
||
ARG python_version=3.10 | ||
|
||
LABEL org.opencontainers.image.description="Dev tools for building and testing CUDA-QX libraries" | ||
LABEL org.opencontainers.image.source="https://github.com/NVIDIA/cudaqx" | ||
LABEL org.opencontainers.image.title="cuda-qx-dev" | ||
LABEL org.opencontainers.image.url="https://github.com/NVIDIA/cudaqx" | ||
|
||
RUN dnf install -y jq | ||
RUN mkdir -p /workspaces/cudaqx | ||
COPY .cudaq_version /workspaces/cudaqx | ||
COPY .github/workflows/scripts/build_cudaq.sh /workspaces/cudaqx | ||
|
||
RUN mkdir -p /workspaces/cudaqx/cudaq && cd /workspaces/cudaqx/cudaq \ | ||
&& git init \ | ||
&& CUDAQ_REPO=$(jq -r '.cudaq.repository' /workspaces/cudaqx/.cudaq_version) \ | ||
&& CUDAQ_COMMIT=$(jq -r '.cudaq.ref' /workspaces/cudaqx/.cudaq_version) \ | ||
&& git remote add origin https://github.com/${CUDAQ_REPO} \ | ||
&& git fetch -q --depth=1 origin ${CUDAQ_COMMIT} \ | ||
&& git reset --hard FETCH_HEAD \ | ||
&& bash ../build_cudaq.sh --python-version ${python_version} \ | ||
&& rm -rf build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.