Skip to content

Commit

Permalink
Merge branch 'main' into surface_code
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlietz committed Jan 16, 2025
2 parents dc2b76e + 07230dc commit 9242136
Show file tree
Hide file tree
Showing 83 changed files with 2,768 additions and 507 deletions.
4 changes: 1 addition & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ BasedOnStyle: LLVM
AlwaysBreakTemplateDeclarations: Yes
IncludeCategories:
- Regex: '^<'
Priority: 4
- Regex: '^"(llvm|llvm-c|clang|clang-c|mlir|mlir-c)/'
Priority: 3
- Regex: '^"(qoda|\.\.)/'
- Regex: '^"(cudaq|\.\.)/'
Priority: 2
- Regex: '.*'
Priority: 1
7 changes: 1 addition & 6 deletions .cudaq_version
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"cudaq": {
"repository": "NVIDIA/cuda-quantum",
"ref": "d63dc8d93b4f9c95677aad2ddad2f9020cde45d0"
},
"cuquantum": {
"url": "https://developer.download.nvidia.com/compute/cuquantum/redist/cuquantum/linux-x86_64/",
"pattern": "cuquantum-linux-x86_64-24.11.0.21_cuda12-archive.tar.xz"
"ref": "e2465210cda71cb0b370566b0c6cd305a5e538be"
}
}

4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Initial Python yapf formatting
1abb7df2c4ce6faf1b84c130166215ebcabb2c18
# Initial C++ formatting
f0e6919d36c1cd22583b2a2b2886f03835a0198a
6 changes: 5 additions & 1 deletion .github/actions/build-lib/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
description: 'Indicates whether to save the compilation cache'
default: 'false'
required: false
platform:
description: 'Platform (amd64 or arm64)'
default: ''
required: true
outputs:
build-dir:
description: 'Build dir.'
Expand All @@ -32,7 +36,7 @@ runs:
- name: Compilation cache key
id: ccache-key
run: |
echo "main=ccache-${{ inputs.lib }}-cu12.0-gcc11" >> $GITHUB_OUTPUT
echo "main=ccache-${{ inputs.lib }}-cu12.0-gcc11-${{ inputs.platform }}" >> $GITHUB_OUTPUT
if [[ -n "${{ inputs.pr-number }}" ]]; then
echo "pr=-pr${{ inputs.pr-number }}" >> $GITHUB_OUTPUT
fi
Expand Down
14 changes: 8 additions & 6 deletions .github/actions/get-cudaq-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: 'Check if a cache entry exists without downloading the cache'
default: 'false'
required: false
platform:
description: 'Platform (amd64 or arm64)'
default: ''
required: true
outputs:
found-cache:
description: 'A boolean value to indicate that a cache entry was found.'
Expand All @@ -49,7 +53,7 @@ runs:
.cudaq_version
run: |
hash=${{ hashFiles(format('{0}', env.to_hash)) }}
echo "main=cudaq-${{ inputs.ref }}-$hash" >> $GITHUB_OUTPUT
echo "main=cudaq-${{ inputs.platform }}-${{ inputs.ref }}-$hash" >> $GITHUB_OUTPUT
if [[ -n "${{ inputs.pr-number }}" ]]; then
echo "pr=-pr${{ inputs.pr-number }}" >> $GITHUB_OUTPUT
fi
Expand Down Expand Up @@ -91,8 +95,6 @@ runs:
bash .github/workflows/scripts/install_git_cli.sh
mkdir -p ${CUQUANTUM_INSTALL_PREFIX}
python3 .github/actions/get-cudaq-build/get_assets.py
cuquantum_archive=$(jq -r '.cuquantum.pattern' .cudaq_version)
tar xf "${cuquantum_archive}" --strip-components 1 -C "${CUQUANTUM_INSTALL_PREFIX}"
shell: bash --noprofile --norc -euo pipefail {0}

# ==========================================================================
Expand All @@ -115,7 +117,7 @@ runs:
with:
fail-on-cache-miss: false
path: /cudaq-ccache
key: ccache-cudaq
key: ccache-cudaq-${{ inputs.platform }}

- name: Install CUDAQ build requirements
if: steps.check-cache.outputs.valid == 'false' && inputs.lookup-only == 'false'
Expand Down Expand Up @@ -145,15 +147,15 @@ runs:
env:
GH_TOKEN: ${{ github.token }}
run: |
gh cache delete ccache-cudaq --repo ${{ github.repository }}
gh cache delete ccache-cudaq-${{ inputs.platform }} --repo ${{ github.repository }}
shell: bash --noprofile --norc -euo pipefail {0}

- name: Store compilation (CCache)
if: steps.check-cache.outputs.valid == 'false' && inputs.save-ccache == 'true' && inputs.lookup-only == 'false'
uses: actions/cache/save@v4
with:
path: /cudaq-ccache
key: ccache-cudaq
key: ccache-cudaq-${{ inputs.platform }}


# ==========================================================================
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/get-cudaq-build/build_cudaq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ CC=${3:-"gcc"}
CXX=${4:-"g++"}

LLVM_INSTALL_PREFIX=/usr/local/llvm
CUTENSOR_INSTALL_PREFIX=/opt/nvidia/cutensor
CUQUANTUM_INSTALL_PREFIX="$(pip show cuquantum-python-cu12 | grep "Location:" | cut -d " " -f 2)/cuquantum"
CUTENSOR_INSTALL_PREFIX="$(pip show cutensor-cu12 | grep "Location:" | cut -d " " -f 2)/cutensor"

cd cudaq

Expand Down
25 changes: 12 additions & 13 deletions .github/actions/get-cudaq-build/get_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import subprocess
import zipfile


def download_asset_github(repo, tag, pattern, install_dir=None):
# Construct the gh command
if tag:
gh_command = f"gh release download {tag} --repo {repo} -p '{pattern}'"
else:
gh_command = f"gh release download --repo {repo} -p '{pattern}'"

print(f"Executing command: {gh_command}")

# Execute the gh command
Expand All @@ -26,32 +27,30 @@ def download_asset_github(repo, tag, pattern, install_dir=None):
with zipfile.ZipFile(pattern, 'r') as zip_ref:
zip_ref.extractall(install_dir)


def download_asset_wget(url, pattern):
try:
result = subprocess.run(['wget', url + pattern], capture_output=True, text=True, check=True)
result = subprocess.run(['wget', url + pattern],
capture_output=True,
text=True,
check=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred: {e}")
print(f"wget output: {e.output}")


def main():
# Read the entry from a JSON file
with open('.cudaq_version', 'r') as json_file:
assets = json.load(json_file)

for name, info in assets.items():
if "tag" in info:
download_asset_github(
info["repository"],
info["tag"],
info["pattern"],
info.get("install_dir")
)
download_asset_github(info["repository"], info["tag"],
info["pattern"], info.get("install_dir"))
if "url" in info:
download_asset_wget(
info["url"],
info["pattern"]
)
download_asset_wget(info["url"], info["pattern"])


if __name__ == "__main__":
main()

9 changes: 7 additions & 2 deletions .github/actions/get-cudaq-version/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ runs:

- name: Install jq
run: |
apt-get update
apt-get install -y --no-install-recommends jq
if [ -x "$(command -v apt-get)" ]; then
apt-get update
apt-get install -y --no-install-recommends jq
elif [ -x "$(command -v dnf)" ]; then
dnf install -y --nobest --setopt=install_weak_deps=False jq
fi
shell: bash

- name: Get required CUDAQ version
Expand Down
3 changes: 3 additions & 0 deletions .github/dco.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allowRemediationCommits:
individual: true
thirdParty: false
8 changes: 7 additions & 1 deletion .github/workflows/all_libs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ jobs:
pr-build:
name: Build and test
if: startsWith(github.ref, 'refs/heads/pull-request/')
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && 'linux-amd64-cpu8' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
platform: ['amd64', 'arm64']
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && format('linux-{0}-cpu8', matrix.platform) || 'ubuntu-latest' }}
container: ghcr.io/nvidia/cuda-quantum-devdeps:ext-cu12.0-gcc11-main
permissions:
actions: write
Expand Down Expand Up @@ -45,6 +49,7 @@ jobs:
ref: ${{ steps.get-cudaq-version.outputs.ref }}
token: ${{ secrets.CUDAQ_ACCESS_TOKEN }}
pr-number: ${{ steps.export-pr-info.outputs.pr_number }}
platform: ${{ matrix.platform }}

# ========================================================================
# Build
Expand All @@ -61,6 +66,7 @@ jobs:
lib: "all"
pr-number: ${{ steps.export-pr-info.outputs.pr_number }}
save-ccache: true
platform: ${{ matrix.platform }}

# ========================================================================
# Run tests
Expand Down
32 changes: 28 additions & 4 deletions .github/workflows/build_wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ name: Build wheels

on:
workflow_dispatch:
inputs:
build_type:
type: choice
required: true
description: 'Build Type'
default: 'Release'
options:
- 'Release'
- 'Debug'


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -10,16 +20,20 @@ concurrency:
jobs:
linux-build:
name: Linux build
runs-on: ubuntu-latest
runs-on: linux-${{ matrix.platform }}-cpu8
# CUDAQ requires a highly specialized environment to build. Thus, it is much
# easier to rely on their's devdeps images to do the building.
container: ghcr.io/nvidia/cuda-quantum-devdeps:manylinux-amd64-${{ matrix.toolchain.id }}-main
# FIXME: there is no guarantee that this CUDA-Q image aligns with the CUDA-Q
# commit that we are trying to align with.
container: ghcr.io/nvidia/cuda-quantum-devdeps:manylinux-${{ matrix.platform }}-${{ matrix.toolchain.id }}-main
permissions:
actions: write
contents: read
strategy:
fail-fast: false
matrix:
python: ['3.10', '3.11', '3.12']
platform: ['amd64', 'arm64']
toolchain:
- id: cu12.0-gcc11
cc: gcc-11
Expand All @@ -32,11 +46,15 @@ jobs:
with:
set-safe-directory: true

- name: Get required CUDAQ version
id: get-cudaq-version
uses: ./.github/actions/get-cudaq-version

- name: Get CUDAQ code
uses: actions/checkout@v4
with:
repository: 'NVIDIA/cuda-quantum'
ref: ${{ inputs.ref }}
repository: ${{ steps.get-cudaq-version.outputs.repo }}
ref: ${{ steps.get-cudaq-version.outputs.ref }}
path: cudaq
set-safe-directory: true

Expand All @@ -48,4 +66,10 @@ jobs:
run: |
.github/workflows/scripts/build_wheels.sh \
--cudaq-prefix $HOME/.cudaq \
--build-type ${{ inputs.build_type }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: wheels-py${{ matrix.python }}-${{ matrix.platform }}
path: /wheels/**
7 changes: 6 additions & 1 deletion .github/workflows/cudaq_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ concurrency:
jobs:
build-cudaq:
name: Build CUDAQ
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && 'linux-amd64-cpu32' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
platform: ['amd64', 'arm64']
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && format('linux-{0}-cpu32', matrix.platform) || 'ubuntu-latest' }}
container: ghcr.io/nvidia/cuda-quantum-devdeps:ext-cu12.0-gcc11-main
permissions:
actions: write
Expand All @@ -44,4 +48,5 @@ jobs:
token: ${{ secrets.CUDAQ_ACCESS_TOKEN }}
save-build: true
save-ccache: true
platform: ${{ matrix.platform }}

9 changes: 5 additions & 4 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Documentation

on:
workflow_call:

workflow_dispatch:
branches:
- main

push:
branches:
- main
# FIXME: remove?
- "pull-request/[0-9]+"
paths:
- '.github/workflows/docs.yaml'
- 'docs/**'
Expand All @@ -18,7 +18,7 @@ on:
- '**/*.py'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -49,6 +49,7 @@ jobs:
repo: ${{ steps.get-cudaq-version.outputs.repo }}
ref: ${{ steps.get-cudaq-version.outputs.ref }}
token: ${{ secrets.CUDAQ_ACCESS_TOKEN }}
platform: 'amd64'

# ========================================================================
# Build docs
Expand All @@ -61,7 +62,7 @@ jobs:
python3 -m pip install IPython breathe enum_tools myst_parser nbsphinx \
sphinx_copybutton sphinx_inline_tabs sphinx_gallery sphinx_rtd_theme \
sphinx_reredirects sphinx_toolbox cupy-cuda12x
sphinx_reredirects sphinx_toolbox cupy-cuda12x cuquantum-python-cu12
python3 -m pip install cmake --user
echo "$HOME/.local/bin:$PATH" >> $GITHUB_PATH
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/lib_qec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ jobs:
pr-build:
name: Build and test
if: startsWith(github.ref, 'refs/heads/pull-request/')
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && 'linux-amd64-cpu8' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
platform: ['amd64', 'arm64']
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && format('linux-{0}-cpu8', matrix.platform) || 'ubuntu-latest' }}
container: ghcr.io/nvidia/cuda-quantum-devdeps:ext-cu12.0-gcc11-main
permissions:
actions: write
Expand Down Expand Up @@ -45,6 +49,7 @@ jobs:
ref: ${{ steps.get-cudaq-version.outputs.ref }}
token: ${{ secrets.CUDAQ_ACCESS_TOKEN }}
pr-number: ${{ steps.export-pr-info.outputs.pr_number }}
platform: ${{ matrix.platform }}

# ========================================================================
# Build library
Expand All @@ -57,6 +62,7 @@ jobs:
lib: "qec"
pr-number: ${{ steps.export-pr-info.outputs.pr_number }}
save-ccache: true
platform: ${{ matrix.platform }}

# ========================================================================
# Run tests
Expand Down
Loading

0 comments on commit 9242136

Please sign in to comment.