From d8498bdaf6071ff85ee1d997ff9921e384c09677 Mon Sep 17 00:00:00 2001 From: Anna Gringauze Date: Sat, 1 Feb 2025 17:21:43 -0800 Subject: [PATCH 1/4] Fix signed int overflow in uccsd (#64) ### Fix some issues to allow compilation of `uccsd` - Fix signed int overflow in `uccsd` - allow specifying shots in `vqe` Towards: https://github.com/NVIDIA/cuda-quantum/issues/2357 --------- Signed-off-by: Anna Gringauze --- libs/solvers/lib/stateprep/uccsd.cpp | 43 ++++++++++--------- .../python/bindings/solvers/py_solvers.cpp | 3 ++ libs/solvers/python/tests/test_uccsd.py | 38 ++++++++++++++++ 3 files changed, 63 insertions(+), 21 deletions(-) diff --git a/libs/solvers/lib/stateprep/uccsd.cpp b/libs/solvers/lib/stateprep/uccsd.cpp index a2cfc97..da50da6 100644 --- a/libs/solvers/lib/stateprep/uccsd.cpp +++ b/libs/solvers/lib/stateprep/uccsd.cpp @@ -407,10 +407,10 @@ __qpu__ std::size_t getNumVirtualBeta(std::size_t numElectrons, __qpu__ void uccsd(cudaq::qview<> qubits, const std::vector &thetas, std::size_t numElectrons, std::size_t spin) { - auto numOccAlpha = getNumOccupiedAlpha(numElectrons, spin, qubits.size()); - auto numOccBeta = getNumOccupiedBeta(numElectrons, spin, qubits.size()); - auto numVirtAlpha = getNumVirtualAlpha(numElectrons, spin, qubits.size()); - auto numVirtBeta = getNumVirtualBeta(numElectrons, spin, qubits.size()); + int numOccAlpha = getNumOccupiedAlpha(numElectrons, spin, qubits.size()); + int numOccBeta = getNumOccupiedBeta(numElectrons, spin, qubits.size()); + int numVirtAlpha = getNumVirtualAlpha(numElectrons, spin, qubits.size()); + int numVirtBeta = getNumVirtualBeta(numElectrons, spin, qubits.size()); std::vector occupiedAlpha(numOccAlpha), virtualAlpha(numVirtAlpha), occupiedBeta(numOccBeta), virtualBeta(numVirtBeta); @@ -433,10 +433,11 @@ __qpu__ void uccsd(cudaq::qview<> qubits, const std::vector &thetas, occupiedBeta[counter] = i * 2 + 1; counter++; } - counter = 0; + counter = 0; for (std::size_t i = 0; i < numVirtBeta; i++) { virtualBeta[counter] = i * 2 + numElectrons - 1; + counter++; } } else { @@ -507,18 +508,18 @@ __qpu__ void uccsd(cudaq::qview<> qubits, const std::vector &thetas, } counter = 0; - for (std::size_t p = 0; p < numOccAlpha - 1; p++) - for (std::size_t q = p + 1; q < numOccAlpha; q++) - for (std::size_t r = 0; r < numVirtAlpha - 1; r++) - for (std::size_t s = r + 1; s < numVirtAlpha; s++) + for (int p = 0; p < numOccAlpha - 1; p++) + for (int q = p + 1; q < numOccAlpha; q++) + for (int r = 0; r < numVirtAlpha - 1; r++) + for (int s = r + 1; s < numVirtAlpha; s++) counter++; std::vector doublesAlpha(4 * counter); counter = 0; - for (std::size_t p = 0; p < numOccAlpha - 1; p++) - for (std::size_t q = p + 1; q < numOccAlpha; q++) - for (std::size_t r = 0; r < numVirtAlpha - 1; r++) - for (std::size_t s = r + 1; s < numVirtAlpha; s++) { + for (int p = 0; p < numOccAlpha - 1; p++) + for (int q = p + 1; q < numOccAlpha; q++) + for (int r = 0; r < numVirtAlpha - 1; r++) + for (int s = r + 1; s < numVirtAlpha; s++) { doublesAlpha[counter] = occupiedAlpha[p]; counter++; doublesAlpha[counter] = occupiedAlpha[q]; @@ -530,17 +531,17 @@ __qpu__ void uccsd(cudaq::qview<> qubits, const std::vector &thetas, } counter = 0; - for (std::size_t p = 0; p < numOccBeta - 1; p++) - for (std::size_t q = p + 1; q < numOccBeta; q++) - for (std::size_t r = 0; r < numVirtBeta - 1; r++) - for (std::size_t s = r + 1; s < numVirtBeta; s++) + for (int p = 0; p < numOccBeta - 1; p++) + for (int q = p + 1; q < numOccBeta; q++) + for (int r = 0; r < numVirtBeta - 1; r++) + for (int s = r + 1; s < numVirtBeta; s++) counter++; std::vector doublesBeta(4 * counter); counter = 0; - for (std::size_t p = 0; p < numOccBeta - 1; p++) - for (std::size_t q = p + 1; q < numOccBeta; q++) - for (std::size_t r = 0; r < numVirtBeta - 1; r++) - for (std::size_t s = r + 1; s < numVirtBeta; s++) { + for (int p = 0; p < numOccBeta - 1; p++) + for (int q = p + 1; q < numOccBeta; q++) + for (int r = 0; r < numVirtBeta - 1; r++) + for (int s = r + 1; s < numVirtBeta; s++) { doublesBeta[counter] = occupiedBeta[p]; counter++; doublesBeta[counter] = occupiedBeta[q]; diff --git a/libs/solvers/python/bindings/solvers/py_solvers.cpp b/libs/solvers/python/bindings/solvers/py_solvers.cpp index fbc88aa..a7b878d 100644 --- a/libs/solvers/python/bindings/solvers/py_solvers.cpp +++ b/libs/solvers/python/bindings/solvers/py_solvers.cpp @@ -132,6 +132,9 @@ class PythonOptimizer : public optim::optimizer { if (kwargs.contains("verbose")) kwargs.attr("pop")("verbose"); + if (kwargs.contains("shots")) + kwargs.attr("pop")("shots"); + if (initParams.empty()) initParams.resize(dim); diff --git a/libs/solvers/python/tests/test_uccsd.py b/libs/solvers/python/tests/test_uccsd.py index 887f262..ec7d2e6 100644 --- a/libs/solvers/python/tests/test_uccsd.py +++ b/libs/solvers/python/tests/test_uccsd.py @@ -141,3 +141,41 @@ def ansatz(thetas: list[float]): print(energy) assert np.isclose(energy, -107.6059, 1e-2) + + +def test_uccsd_loops(): + repro_num_electrons = 2 + repro_num_qubits = 8 + + repro_thetas = [ + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558, + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558, + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558, + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558, + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558, + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558, + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558, + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558, + -0.00037043841404585794, 0.0003811110195084151, 0.2286823796532558 + ] + + @cudaq.kernel + def repro_trial_state(qubits: cudaq.qvector, num_electrons: int, + thetas: list[float]): + for i in range(num_electrons): + x(qubits[i]) + solvers.stateprep.uccsd(qubits, thetas, num_electrons, 0) + + @cudaq.kernel + def repro(): + repro_qubits = cudaq.qvector(repro_num_qubits) + repro_trial_state(repro_qubits, repro_num_electrons, repro_thetas) + + counts = cudaq.sample(repro, shots_count=1000) + assert len(counts) == 6 + assert '00000011' in counts + assert '00000110' in counts + assert '00010010' in counts + assert '01000010' in counts + assert '10000001' in counts + assert '11000000' in counts From f4b4a1eba3525db6afe03e5a8004e71edf82df02 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 17:34:38 -0800 Subject: [PATCH 2/4] Bump CUDA-Q commit (#66) Auto update to the latest CUDA-Q commit --- .cudaq_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cudaq_version b/.cudaq_version index 56af488..ef929bf 100644 --- a/.cudaq_version +++ b/.cudaq_version @@ -1,6 +1,6 @@ { "cudaq": { "repository": "NVIDIA/cuda-quantum", - "ref": "bd499151326950ffb163b2afb928ca882f926ab4" + "ref": "d8930461128a9c564d636d7531d21f836eb1a59e" } } From 2d31c4359de91017c9e56de3b8b793459c0b2f64 Mon Sep 17 00:00:00 2001 From: Ben Howe <141149032+bmhowe23@users.noreply.github.com> Date: Wed, 5 Feb 2025 18:20:51 -0800 Subject: [PATCH 3/4] Update dev Dockerfile and add GitHub action (#69) This PR adds a manually triggered workflow to publish useful containers for development and CI/CD. It is anticipated that we will need to trigger this when we update the CUDA-Q commit. (We may make this automatic in the future, but it is intentionally just manual for now.) --------- Signed-off-by: Ben Howe --- .github/workflows/build_dev.yaml | 179 +++++++++++++++++++++++ docker/build_env/Dockerfile | 22 --- docker/build_env/cudaqx.dev.Dockerfile | 34 +++++ docker/build_env/cudaqx.wheel.Dockerfile | 32 ++++ 4 files changed, 245 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/build_dev.yaml delete mode 100644 docker/build_env/Dockerfile create mode 100644 docker/build_env/cudaqx.dev.Dockerfile create mode 100644 docker/build_env/cudaqx.wheel.Dockerfile diff --git a/.github/workflows/build_dev.yaml b/.github/workflows/build_dev.yaml new file mode 100644 index 0000000..a569569 --- /dev/null +++ b/.github/workflows/build_dev.yaml @@ -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' diff --git a/docker/build_env/Dockerfile b/docker/build_env/Dockerfile deleted file mode 100644 index 979834a..0000000 --- a/docker/build_env/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -# ============================================================================ # -# Copyright (c) 2024 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-cu11.8-gcc11-main - -RUN apt-get update && apt-get install -y gfortran libblas-dev libcusolver-dev-11-8 \ - && python3 -m pip install cmake --user \ - && apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/* - -RUN git clone https://github.com/nvidia/cuda-quantum \ - && cd cuda-quantum && mkdir build && cd build \ - && ~/.local/bin/cmake -G Ninja .. -DLLVM_DIR=/opt/llvm/lib/cmake \ - -DCUDAQ_ENABLE_PYTHON=TRUE -DCMAKE_INSTALL_PREFIX=$HOME/.cudaq \ - && ninja install - - - diff --git a/docker/build_env/cudaqx.dev.Dockerfile b/docker/build_env/cudaqx.dev.Dockerfile new file mode 100644 index 0000000..130e17d --- /dev/null +++ b/docker/build_env/cudaqx.dev.Dockerfile @@ -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 diff --git a/docker/build_env/cudaqx.wheel.Dockerfile b/docker/build_env/cudaqx.wheel.Dockerfile new file mode 100644 index 0000000..1aa53f3 --- /dev/null +++ b/docker/build_env/cudaqx.wheel.Dockerfile @@ -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 From de09379bd18955e5f8b60a3cb73763d612d8089d Mon Sep 17 00:00:00 2001 From: Ben Howe <141149032+bmhowe23@users.noreply.github.com> Date: Thu, 6 Feb 2025 18:02:57 -0800 Subject: [PATCH 4/4] Update "Bump CUDA-Q commit" workflow to accept any branch name. (#75) This will be useful for targeted testing of specific feature branches or large PRs. --------- Signed-off-by: Ben Howe --- .github/workflows/update-cudaq-dep.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-cudaq-dep.yml b/.github/workflows/update-cudaq-dep.yml index 78c9942..8597d07 100644 --- a/.github/workflows/update-cudaq-dep.yml +++ b/.github/workflows/update-cudaq-dep.yml @@ -1,5 +1,12 @@ on: workflow_dispatch: + inputs: + cudaq_branch_name: + type: string + required: true + description: 'Branch name for upstream CUDA-Q repo (e.g. main or pull-request/2407)' + default: main + schedule: - cron: 0 1 * * 6 @@ -22,7 +29,7 @@ jobs: - name: Fetch the latest commit run: | - SHA=$(curl -s "https://api.github.com/repos/NVIDIA/cuda-quantum/commits/main" | jq -r '.sha') + SHA=$(curl -s "https://api.github.com/repos/NVIDIA/cuda-quantum/commits/${{ inputs.cudaq_branch_name }}" | jq -r '.sha') echo "Latest SHA: $SHA" echo "sha=$SHA" >> $GITHUB_ENV @@ -64,8 +71,13 @@ jobs: GITHUB_TOKEN: ${{ github.token }} BRANCH_NAME: ${{ steps.commit_and_push.outputs.BRANCH_NAME }} run: | + if [[ "${{ inputs.cudaq_branch_name }}" == "main" ]]; then + TITLE_STR="Bump CUDA-Q commit" + else + TITLE_STR="Bump CUDA-Q commit (${{ inputs.cudaq_branch_name }} DO NOT MERGE)" + fi gh pr create \ - --title "Bump CUDA-Q commit" \ - --body "Auto update to the latest CUDA-Q commit" \ + --title "${TITLE_STR}" \ + --body "Auto update to the latest CUDA-Q commit on ${{ inputs.cudaq_branch_name }} branch" \ --head "${BRANCH_NAME}" \ --base "main"