Skip to content

Commit e991563

Browse files
committed
Update test scripts to allow easy data generation
Signed-off-by: Ben Howe <[email protected]>
1 parent bd4d5d0 commit e991563

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

libs/qec/unittests/realtime/app_examples/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
# the terms of the Apache License 2.0 which accompanies this distribution. #
77
# ============================================================================ #
88

9+
#------------------------------------------------------------------------------#
10+
# Maintenance note: to generate QIR files and corresponding config files for
11+
# Quantinuum, you may manually run tests like the following:
12+
# CUDAQ_DUMP_JIT_IR=1 KEEP_LOG_FILES=1 ctest -R quantinuum
13+
# The resulting files will be in:
14+
# build/libs/qec/unittests/realtime/app_examples/config-*.yml
15+
# build/libs/qec/unittests/realtime/app_examples/qir-*.ll
16+
#------------------------------------------------------------------------------#
17+
918
#------------------------------------------------------------------------------#
1019
# Surface code 1, fully local, regular Stim simulator
1120
add_executable(surface_code-1-local)

libs/qec/unittests/realtime/app_examples/surface_code-1-test.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ NUM_SHOTS=1000
4646
# Get timestamp suffix in YYYY-MM-DD-HH-MM-SS, with random number appended using /dev/urandom.
4747
timestamp=$(date +%Y-%m-%d-%H-%M-%S)
4848
RNG_SUFFIX=$(od -An -N4 -i /dev/urandom | tr -d ' ')
49+
# Remove any negative sign.
50+
RNG_SUFFIX=$(echo $RNG_SUFFIX | sed 's/-//g')
4951
FULL_SUFFIX=$timestamp-$RNG_SUFFIX
5052

5153
CONFIG_FILE=config-${FULL_SUFFIX}.yml
@@ -70,6 +72,15 @@ export CUDAQ_DUMP_JIT_IR=${CUDAQ_DUMP_JIT_IR:-0}
7072
echo Running $EXE_PATH2 --distance $DISTANCE --num_shots $NUM_SHOTS --load_dem $CONFIG_FILE --num_rounds $NUM_ROUNDS --decoder_window $DECODER_WINDOW
7173
$EXE_PATH2 --distance $DISTANCE --num_shots $NUM_SHOTS --load_dem $CONFIG_FILE --num_rounds $NUM_ROUNDS --decoder_window $DECODER_WINDOW |& tee load_dem-$FULL_SUFFIX.log
7274

75+
# If CUDAQ_DUMP_JIT_IR is "1", then extract the QIR from the
76+
# load_dem-$FULL_SUFFIX.log file and place it in qir-$FULL_SUFFIX.ll.
77+
if [[ "${CUDAQ_DUMP_JIT_IR}" == "1" ]]; then
78+
# The QIR starts with "ModuleID" and ends with "backwards_branching"
79+
QIR=$(sed -n '/ModuleID/,/backwards_branching/p' load_dem-$FULL_SUFFIX.log)
80+
echo "Writing QIR to qir-$FULL_SUFFIX.ll"
81+
echo "$QIR" > qir-$FULL_SUFFIX.ll
82+
fi
83+
7384

7485
# Look for results like this in the output:
7586
# Number of non-zero values measured : 2

libs/qec/unittests/realtime/app_examples/surface_code-2-test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ NUM_SHOTS=1000
4242
# Get timestamp suffix in YYYY-MM-DD-HH-MM-SS, with random number appended using /dev/urandom.
4343
timestamp=$(date +%Y-%m-%d-%H-%M-%S)
4444
RNG_SUFFIX=$(od -An -N4 -i /dev/urandom | tr -d ' ')
45+
# Remove any negative sign.
46+
RNG_SUFFIX=$(echo $RNG_SUFFIX | sed 's/-//g')
4547
FULL_SUFFIX=$timestamp-$RNG_SUFFIX
4648

4749
CONFIG_FILE=config-${FULL_SUFFIX}.yml
@@ -66,6 +68,14 @@ export CUDAQ_DUMP_JIT_IR=${CUDAQ_DUMP_JIT_IR:-0}
6668
echo Running $EXE_PATH2 --distance $DISTANCE --num_shots $NUM_SHOTS --load_dem $CONFIG_FILE
6769
$EXE_PATH2 --distance $DISTANCE --num_shots $NUM_SHOTS --load_dem $CONFIG_FILE |& tee load_dem-$FULL_SUFFIX.log
6870

71+
# If CUDAQ_DUMP_JIT_IR is "1", then extract the QIR from the
72+
# load_dem-$FULL_SUFFIX.log file and place it in qir-$FULL_SUFFIX.ll.
73+
if [[ "${CUDAQ_DUMP_JIT_IR}" == "1" ]]; then
74+
# The QIR starts with "ModuleID" and ends with "backwards_branching"
75+
QIR=$(sed -n '/ModuleID/,/backwards_branching/p' load_dem-$FULL_SUFFIX.log)
76+
echo "Writing QIR to qir-$FULL_SUFFIX.ll"
77+
echo "$QIR" > qir-$FULL_SUFFIX.ll
78+
fi
6979

7080
# Look for results like this in the output:
7181
# Number of non-zero values measured : 2

libs/qec/unittests/realtime/app_examples/surface_code-3-test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ NUM_SHOTS=1000
4343
# Get timestamp suffix in YYYY-MM-DD-HH-MM-SS, with random number appended using /dev/urandom.
4444
timestamp=$(date +%Y-%m-%d-%H-%M-%S)
4545
RNG_SUFFIX=$(od -An -N4 -i /dev/urandom | tr -d ' ')
46+
# Remove any negative sign.
47+
RNG_SUFFIX=$(echo $RNG_SUFFIX | sed 's/-//g')
4648
FULL_SUFFIX=$timestamp-$RNG_SUFFIX
4749

4850
CONFIG_FILE=config-${FULL_SUFFIX}.yml
@@ -66,6 +68,14 @@ export CUDAQ_DUMP_JIT_IR=${CUDAQ_DUMP_JIT_IR:-0}
6668
echo Running $EXE_PATH2 --distance $DISTANCE --num_shots $NUM_SHOTS --load_dem $CONFIG_FILE
6769
$EXE_PATH2 --distance $DISTANCE --num_shots $NUM_SHOTS --load_dem $CONFIG_FILE --p_spam $ERROR_RATE --state_prep $STATE_PREP |& tee load_dem-$FULL_SUFFIX.log
6870

71+
# If CUDAQ_DUMP_JIT_IR is "1", then extract the QIR from the
72+
# load_dem-$FULL_SUFFIX.log file and place it in qir-$FULL_SUFFIX.ll.
73+
if [[ "${CUDAQ_DUMP_JIT_IR}" == "1" ]]; then
74+
# The QIR starts with "ModuleID" and ends with "backwards_branching"
75+
QIR=$(sed -n '/ModuleID/,/backwards_branching/p' load_dem-$FULL_SUFFIX.log)
76+
echo "Writing QIR to qir-$FULL_SUFFIX.ll"
77+
echo "$QIR" > qir-$FULL_SUFFIX.ll
78+
fi
6979

7080
# ------------------------------------------------------------------------------
7181
# Validation of decoder results using mismatch percentage:

0 commit comments

Comments
 (0)