Skip to content

Commit 573a323

Browse files
Merge branch 'main' into fix-density-matrix-overlap-dimension
2 parents 9b42918 + fb5bfd2 commit 573a323

File tree

122 files changed

+4335
-3115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+4335
-3115
lines changed

.github/workflows/ci_macos.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
on:
2+
# Daily rebuild on main to ensure devdeps rebuilt as needed
3+
schedule:
4+
- cron: '0 4 * * *' # aim to be ready by 9am CET/CEST
25
workflow_dispatch:
36
inputs:
47
cache_base:
@@ -246,8 +249,13 @@ jobs:
246249

247250
- name: Validate wheel
248251
run: |
249-
# Full validation: core tests, examples, snippets, backends
250-
# GPU/MPI tests are automatically skipped on macOS (CPU-only)
252+
# Validates wheel: core tests, examples, snippets, backends.
253+
# GPU/remote targets are skipped (no CUDA on macOS runners).
254+
# TODO: When adding macOS to publishing.yml, align the validation
255+
# approach with python_wheels.yml (which uses
256+
# explicit find exclusions for platform/backends/dynamics paths,
257+
# and does not use validate_pycudaq.sh for snippets/examples
258+
# currently used in python_wheels.yml).
251259
bash scripts/validate_pycudaq.sh \
252260
-v ${{ needs.wheel.outputs.cudaq_version }} \
253261
-i dist \

.github/workflows/codeql.yml

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ jobs:
8888
with:
8989
category: "/language:${{matrix.language}}"
9090

91-
# The CodeQL action status is not reported in merge queues. See https://github.com/github/codeql-action/issues/1537.
92-
# This is a workaround to check the status of the CodeQL analysis in the PR but not in the merge queue. See https://github.com/orgs/community/discussions/46757#discussioncomment-7768838
91+
# CodeQL status is not reported in merge queues. See https://github.com/github/codeql-action/issues/1537.
92+
# Workaround: verify CodeQL passed via API keyed by pull_request.number so the PR gets a required status.
9393
check_codeql_status:
9494
name: Check CodeQL Status
9595
needs: analyze
@@ -105,21 +105,29 @@ jobs:
105105
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
106106
- name: Check CodeQL Status
107107
run: |
108-
response=$(gh api graphql -f query='
109-
{
110-
repository(owner: "${{ github.event.repository.owner.login }}", name: "${{ github.event.repository.name }}") {
111-
pullRequest(number: ${{ github.event.pull_request.number }}) {
112-
commits(last: 1) {
113-
nodes {
114-
commit {
115-
checkSuites(first: 1, filterBy: {checkName: "CodeQL"}) {
116-
nodes {
117-
checkRuns(first: 1) {
118-
nodes {
119-
name
120-
status
121-
conclusion
122-
}
108+
# Query by pull_request.number so the check is tied to the PR (required for merge-queue workaround).
109+
# Find the "Analyze (language)" check run (the one that completes); filterBy "CodeQL" returns a different check that stays QUEUED.
110+
pr_number="${{ github.event.pull_request.number }}"
111+
owner="${{ github.event.repository.owner.login }}"
112+
repo="${{ github.event.repository.name }}"
113+
max_attempts=24
114+
attempt=0
115+
conclusion=""
116+
while [ $attempt -lt $max_attempts ]; do
117+
# Inline pr_number in the query so we only pass string variables (gh -f sends all as strings otherwise).
118+
response=$(gh api graphql -f query="query(\$owner: String!, \$repo: String!) {
119+
repository(owner: \$owner, name: \$repo) {
120+
pullRequest(number: $pr_number) {
121+
commits(last: 1) {
122+
nodes {
123+
commit {
124+
checkSuites(first: 20) {
125+
nodes {
126+
checkRuns(first: 20) {
127+
nodes {
128+
name
129+
status
130+
conclusion
123131
}
124132
}
125133
}
@@ -129,10 +137,26 @@ jobs:
129137
}
130138
}
131139
}
132-
')
133-
conclusion=$(echo $response | jq -r '.data.repository.pullRequest.commits.nodes[0].commit.checkSuites.nodes[0].checkRuns.nodes[0].conclusion')
134-
if [ "$conclusion" != "SUCCESS" ]; then
135-
echo "$response"
136-
echo "CodeQL check failed"
137-
exit 1
138-
fi
140+
}" -f owner="$owner" -f repo="$repo")
141+
# Find the check run whose name starts with "Analyze (" (the CodeQL matrix job)
142+
conclusion=$(echo "$response" | jq -r '
143+
.data.repository.pullRequest.commits.nodes[0].commit.checkSuites.nodes[]
144+
| .checkRuns.nodes[] | select(.name | startswith("Analyze (")) | .conclusion
145+
' | head -1)
146+
status=$(echo "$response" | jq -r '
147+
.data.repository.pullRequest.commits.nodes[0].commit.checkSuites.nodes[]
148+
| .checkRuns.nodes[] | select(.name | startswith("Analyze (")) | .status
149+
' | head -1)
150+
if [ "$conclusion" != "null" ] && [ -n "$conclusion" ]; then
151+
break
152+
fi
153+
attempt=$((attempt + 1))
154+
echo "CodeQL check (PR #$pr_number) status=$status conclusion=$conclusion (attempt $attempt/$max_attempts), waiting 10s..."
155+
sleep 10
156+
done
157+
if [ "$conclusion" != "SUCCESS" ]; then
158+
echo "$response" | jq .
159+
echo "CodeQL check failed (conclusion=$conclusion)"
160+
exit 1
161+
fi
162+
echo "CodeQL check passed."

.github/workflows/dev_environment_macos.yml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ jobs:
5050
platform_tag: ${{ steps.build_info.outputs.platform_tag }}
5151
owner: ${{ steps.build_info.outputs.owner }}
5252
pr_number: ${{ steps.build_info.outputs.pr_number }}
53-
image_name: ${{ steps.build_info.outputs.image_name }}
53+
scripts_hash: ${{ steps.build_info.outputs.scripts_hash }}
54+
image_name_base: ${{ steps.build_info.outputs.image_name_base }}
5455

5556
environment:
5657
name: ${{ inputs.environment || 'default' }}
@@ -89,28 +90,28 @@ jobs:
8990
# when the copied files change), macOS uses ORAS artifact caching with no
9091
# content-based invalidation. This hash ensures cache is rebuilt when
9192
# build scripts change. Update this list if new files affect the build.
92-
deps_hash=$(cat \
93+
scripts_hash=$(cat \
9394
scripts/install_prerequisites.sh \
9495
scripts/build_llvm.sh \
9596
scripts/set_env_defaults.sh \
9697
| sha256sum | cut -c1-8)
97-
echo "deps_hash=$deps_hash"
98+
echo "scripts_hash=$scripts_hash" >> $GITHUB_OUTPUT
9899
99100
# Registry and image name
100-
image_name=ghcr.io/${repo_owner,,}/${{ vars.packages_prefix }}cuda-quantum-macos-devdeps
101+
image_name_base=ghcr.io/${repo_owner,,}/${{ vars.packages_prefix }}cuda-quantum-macos-devdeps
101102
if [ -n "$pr_number" ]; then
102-
image_name=${image_name}-ci
103+
image_name_base=${image_name_base}-ci
103104
fi
104105
105106
registry_cache_base=$(echo ${{ inputs.registry_cache_from || github.event.pull_request.base.ref || 'main' }} | tr / -)
106-
image_name="${image_name}:${platform_tag}-${registry_cache_base}-${deps_hash}"
107-
echo "image_name=$image_name" >> $GITHUB_OUTPUT
107+
image_name_base="${image_name_base}:${platform_tag}-${registry_cache_base}-"
108+
echo "image_name_base=$image_name_base" >> $GITHUB_OUTPUT
108109
109110
build:
110111
name: Build macOS Cache
111112
needs: metadata
112113
runs-on: ${{ needs.metadata.outputs.runner }}
113-
timeout-minutes: 180
114+
timeout-minutes: 240
114115
permissions:
115116
contents: read
116117
packages: write
@@ -136,14 +137,27 @@ jobs:
136137
- name: Log in to GitHub CR
137138
run: echo "${{ github.token }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
138139

140+
- name: Compute cache key
141+
id: cache_key
142+
run: |
143+
# Combine build scripts hash with the runner image version to detect
144+
# tool updates (cmake, compilers, etc.) that would invalidate the cache.
145+
scripts_hash=${{ needs.metadata.outputs.scripts_hash }}
146+
runner_image=${ImageVersion:-unknown}
147+
deps_hash=$(echo "${scripts_hash}-${runner_image}" | shasum -a 256 | cut -c1-8)
148+
image_name="${{ needs.metadata.outputs.image_name_base }}${deps_hash}"
149+
echo "image_name=$image_name" >> $GITHUB_OUTPUT
150+
echo "Cache key: scripts_hash=$scripts_hash runner_image=$runner_image deps_hash=$deps_hash"
151+
echo "Image name: $image_name"
152+
139153
- name: Check for cached image
140154
id: cache_check
141155
run: |
142-
if oras manifest fetch ${{ needs.metadata.outputs.image_name }} > /dev/null 2>&1; then
143-
echo "Cache hit: ${{ needs.metadata.outputs.image_name }}"
156+
if oras manifest fetch ${{ steps.cache_key.outputs.image_name }} > /dev/null 2>&1; then
157+
echo "Cache hit: ${{ steps.cache_key.outputs.image_name }}"
144158
echo "cache_hit=true" >> $GITHUB_OUTPUT
145159
else
146-
echo "Cache miss: ${{ needs.metadata.outputs.image_name }}"
160+
echo "Cache miss: ${{ steps.cache_key.outputs.image_name }}"
147161
echo "cache_hit=false" >> $GITHUB_OUTPUT
148162
fi
149163
@@ -177,12 +191,12 @@ jobs:
177191
ls -lh macos-artifacts.tar.gz
178192
179193
# Push directly to GHCR as OCI artifact using ORAS
180-
oras push ${{ needs.metadata.outputs.image_name }} \
194+
oras push ${{ steps.cache_key.outputs.image_name }} \
181195
macos-artifacts.tar.gz:application/gzip
182196
183197
# Get digest for signing
184-
digest=$(oras manifest fetch ${{ needs.metadata.outputs.image_name }} --descriptor | jq -r '.digest')
185-
echo "digest=${{ needs.metadata.outputs.image_name }}@${digest}" >> $GITHUB_OUTPUT
198+
digest=$(oras manifest fetch ${{ steps.cache_key.outputs.image_name }} --descriptor | jq -r '.digest')
199+
echo "digest=${{ steps.cache_key.outputs.image_name }}@${digest}" >> $GITHUB_OUTPUT
186200
187201
- name: Install Cosign
188202
if: steps.cache_check.outputs.cache_hit != 'true' && steps.push_image.outputs.digest != ''
@@ -201,10 +215,10 @@ jobs:
201215
run: |
202216
if [ "${{ steps.cache_check.outputs.cache_hit }}" == "true" ]; then
203217
# Cache hit - use tag reference directly
204-
echo "image_hash=${{ needs.metadata.outputs.image_name }}" >> $GITHUB_OUTPUT
218+
echo "image_hash=${{ steps.cache_key.outputs.image_name }}" >> $GITHUB_OUTPUT
205219
else
206220
# Cache miss - use digest after push
207-
echo "image_hash=${{ steps.push_image.outputs.digest || needs.metadata.outputs.image_name }}" >> $GITHUB_OUTPUT
221+
echo "image_hash=${{ steps.push_image.outputs.digest || steps.cache_key.outputs.image_name }}" >> $GITHUB_OUTPUT
208222
fi
209223
210224
finalize:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ SET(CMAKE_SKIP_INSTALL_RPATH FALSE)
216216
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
217217
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
218218
if(APPLE)
219-
SET(CMAKE_INSTALL_RPATH "@executable_path;@executable_path/lib;@executable_path/lib/plugins;@executable_path/../lib;@executable_path/../lib/plugins")
219+
SET(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/lib;@loader_path/lib/plugins;@loader_path/../lib;@loader_path/../lib/plugins;@executable_path;@executable_path/lib;@executable_path/lib/plugins;@executable_path/../lib;@executable_path/../lib/plugins")
220220
else()
221221
SET(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/lib:$ORIGIN/lib/plugins:$ORIGIN/../lib:$ORIGIN/../lib/plugins")
222222
endif()

0 commit comments

Comments
 (0)