Skip to content

Commit ca3c0e7

Browse files
Merge branch 'main' into ghi-643-fix
2 parents c20d8a0 + 6c2676e commit ca3c0e7

7 files changed

Lines changed: 51 additions & 5 deletions

File tree

.github/actions/build-lib/build_qec.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -e
33

44
. "$(dirname "$0")/setup_custabilizer.sh"
5+
. "$(dirname "$0")/../../../scripts/cudaq_realtime_cmake_flags.sh"
56

67
build_dir=$1
78
install_prefix=$2
@@ -100,7 +101,9 @@ if [ -z "$CUDAQ_REALTIME_ROOT" ]; then
100101
# which produces libcudaq-realtime-bridge-hololink.so needed by the bridge.
101102
cd /tmp/cudaq-realtime-src/realtime
102103
mkdir -p build && cd build
104+
103105
cmake -G Ninja -DCMAKE_INSTALL_PREFIX="$CUDAQ_REALTIME_ROOT" \
106+
-DCMAKE_CUDA_FLAGS="$(cudaq_realtime_cmake_cuda_flags)" \
104107
-DCUDAQ_REALTIME_ENABLE_HOLOLINK_TOOLS=ON \
105108
-DHOLOSCAN_SENSOR_BRIDGE_SOURCE_DIR=$HSB_ROOT \
106109
-DHOLOSCAN_SENSOR_BRIDGE_BUILD_DIR=$HSB_BUILD \

.github/actions/get-cudaq-build/action.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ runs:
5151
to_hash: |
5252
.github/actions/get-cudaq-build/**
5353
scripts/build_cudaq_with_realtime.sh
54+
scripts/cudaq_realtime_cmake_flags.sh
5455
.cudaq_version
5556
run: |
5657
hash=${{ hashFiles(format('{0}', env.to_hash)) }}

.github/workflows/all_libs_release.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ jobs:
108108

109109
- name: Build cuda-quantum realtime
110110
run: |
111+
source "$GITHUB_WORKSPACE/scripts/cudaq_realtime_cmake_flags.sh"
111112
CUDAQ_REPO="${{ steps.get-cudaq-version.outputs.repo }}"
112113
CUDAQ_REF="${{ steps.get-cudaq-version.outputs.ref }}"
113114
CUDAQ_REALTIME_ROOT=/tmp/cudaq-realtime
@@ -119,7 +120,9 @@ jobs:
119120
git sparse-checkout set realtime cmake
120121
git checkout "$CUDAQ_REF"
121122
cd realtime && mkdir -p build && cd build
122-
cmake -G Ninja -DCMAKE_INSTALL_PREFIX=$CUDAQ_REALTIME_ROOT ..
123+
cmake -G Ninja -DCMAKE_INSTALL_PREFIX=$CUDAQ_REALTIME_ROOT \
124+
-DCMAKE_CUDA_FLAGS="$(cudaq_realtime_cmake_cuda_flags)" \
125+
..
123126
ninja && ninja install
124127
echo "CUDAQ_REALTIME_ROOT=$CUDAQ_REALTIME_ROOT" >> $GITHUB_ENV
125128
shell: bash

docker/build_env/cudaqx.dev.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ RUN apt-get update && CUDA_DASH=$(echo $cuda_version | tr '.' '-') \
2323

2424
COPY .cudaq_version /cudaq_version
2525
COPY scripts/build_cudaq_with_realtime.sh /usr/local/bin/build_cudaq_with_realtime.sh
26+
COPY scripts/cudaq_realtime_cmake_flags.sh /usr/local/bin/cudaq_realtime_cmake_flags.sh
2627

2728
ENV CUDAQ_INSTALL_PREFIX=/usr/local/cudaq
2829

libs/qec/unittests/realtime/app_examples/surface_code-4-yaml-test.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ if [[ $# -ge 7 ]]; then
7676
EXTRA_APP_ARGS=("${@:7}")
7777
fi
7878

79+
# The app defaults to one logical patch. The aggregate result sums residual
80+
# errors across patches, so retain the per-patch ceiling when --num_logical
81+
# requests multiple patches.
82+
NUM_LOGICAL=1
83+
for ((i = 0; i < ${#EXTRA_APP_ARGS[@]}; i++)); do
84+
if [[ "${EXTRA_APP_ARGS[$i]}" == "--num_logical" ]] &&
85+
((i + 1 < ${#EXTRA_APP_ARGS[@]})); then
86+
i=$((i + 1))
87+
NUM_LOGICAL=${EXTRA_APP_ARGS[$i]}
88+
fi
89+
done
90+
7991
export CUDAQ_DEFAULT_SIMULATOR=stim
8092
if [[ -n "${QEC_DECODING_SERVER:-}" ]]; then
8193
export CUDAQ_QEC_REALTIME_MODE=external_server
@@ -90,10 +102,11 @@ P_SPAM=0.01
90102
# d5/T6). A decoder that loads but never corrects reliably exceeds it; any
91103
# working decoder sits well below it. This is a wiring/correctness check, not
92104
# a performance target -- it must never be tightened toward a particular
93-
# decoder's measured rate. Floored at 1 so small shot counts do not truncate
94-
# the ceiling to 0.
95-
MAX_NON_ZERO=$((NUM_SHOTS / 50))
96-
if [[ $MAX_NON_ZERO -lt 1 ]]; then MAX_NON_ZERO=1; fi
105+
# decoder's measured rate. Floored at 1 per logical patch so small shot counts
106+
# do not truncate the ceiling to 0, then scaled for the aggregate result.
107+
MAX_NON_ZERO_PER_LOGICAL=$((NUM_SHOTS / 50))
108+
if [[ $MAX_NON_ZERO_PER_LOGICAL -lt 1 ]]; then MAX_NON_ZERO_PER_LOGICAL=1; fi
109+
MAX_NON_ZERO=$((MAX_NON_ZERO_PER_LOGICAL * NUM_LOGICAL))
97110

98111
# Multi-type mode: a comma list binds one decoder type per patch and the
99112
# per-decoder ceilings below replace the aggregate ceiling (which is
@@ -174,6 +187,7 @@ echo " distance = $DISTANCE"
174187
echo " num_rounds = $NUM_ROUNDS"
175188
echo " decoder_type = $DECODER_TYPE"
176189
echo " num_shots = $NUM_SHOTS"
190+
echo " num_logical = $NUM_LOGICAL"
177191
echo " realtime mode = $CUDAQ_QEC_REALTIME_MODE"
178192
if [[ -n "$ONNX_PATH" ]]; then
179193
echo " onnx_path = $ONNX_PATH"

scripts/build_cudaq_with_realtime.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ set -euo pipefail
2323

2424
log() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
2525

26+
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
27+
. "$script_dir/cudaq_realtime_cmake_flags.sh"
28+
2629
BUILD_TYPE=${1:-"Release"}
2730
CC=${2:-${CC:-"gcc"}}
2831
CXX=${3:-${CXX:-"g++"}}
@@ -39,6 +42,7 @@ log "Building cudaq-realtime from $CUDAQ_SRC/realtime"
3942
cmake -G Ninja -S "$CUDAQ_SRC/realtime" -B "$CUDAQ_SRC/realtime/build" \
4043
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
4144
-DCMAKE_INSTALL_PREFIX="$CUDAQ_INSTALL_PREFIX" \
45+
-DCMAKE_CUDA_FLAGS="$(cudaq_realtime_cmake_cuda_flags)" \
4246
-DCUDAQ_REALTIME_BUILD_TESTS=OFF \
4347
-DCUDAQ_REALTIME_BUILD_EXAMPLES=OFF \
4448
-DCUDAQ_REALTIME_ENABLE_HOLOLINK_TOOLS=OFF
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
# CMake flags required when CUDA-QX builds CUDA-Q's realtime dependency.
4+
cudaq_realtime_cmake_cuda_flags() {
5+
_cudaq_realtime_cuda_flags="${CMAKE_CUDA_FLAGS:-}"
6+
_cudaq_realtime_host_cxx="${CXX:-c++}"
7+
_cudaq_realtime_host_cxx_major=$("$_cudaq_realtime_host_cxx" -dumpversion 2>/dev/null | cut -d. -f1)
8+
_cudaq_realtime_cuda_major=$(nvcc --version 2>/dev/null |
9+
sed -n 's/^.*release \([0-9][0-9]*\)\..*$/\1/p')
10+
11+
# CUDA 12's nvcc frontend cannot parse GCC 12's AVX-512 BF16 intrinsic
12+
# headers. CUDA-Q realtime does not use those intrinsics, so defining the
13+
# headers' include guards keeps them out of the nvcc parse.
14+
if [ "$(uname -m)" = x86_64 ] && [ "$_cudaq_realtime_cuda_major" = 12 ] && \
15+
[ "$_cudaq_realtime_host_cxx_major" = 12 ]; then
16+
_cudaq_realtime_cuda_flags="${_cudaq_realtime_cuda_flags} -D_AVX512BF16INTRIN_H_INCLUDED -D_AVX512BF16VLINTRIN_H_INCLUDED"
17+
fi
18+
19+
printf '%s' "$_cudaq_realtime_cuda_flags"
20+
}

0 commit comments

Comments
 (0)