From d4cc1818a3009d166645b3c51f20ad789fe1f8b6 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 22:18:55 -0400 Subject: [PATCH 01/11] Increase max Qureg size by relaxing permutation assertions --- tests/utils/linalg.cpp | 8 +++++--- tests/utils/linalg.hpp | 2 +- tests/utils/lists.cpp | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/utils/linalg.cpp b/tests/utils/linalg.cpp index e8285cdff..1a1f8ed7d 100644 --- a/tests/utils/linalg.cpp +++ b/tests/utils/linalg.cpp @@ -15,6 +15,7 @@ #include #include +#include using std::vector; @@ -93,14 +94,15 @@ qindex setBitsAt(qindex num, vector inds, qindex bits) { } -int getNumPermutations(int n, int k) { +qindex getNumPermutations(int n, int k) { DEMAND( n >= k ); - DEMAND( n <= 11 ); // else int overflow + + constexpr auto max = std::numeric_limits::max(); // P(n, k) = n! / (n-k)! qindex p = 1; for (int t=n-k+1; t<=n; t++) - p *= t; + p *= (p < max / t)? t : 0; // set to 0 on overflow return p; } diff --git a/tests/utils/linalg.hpp b/tests/utils/linalg.hpp index 18555bf6f..4afa5f3e1 100644 --- a/tests/utils/linalg.hpp +++ b/tests/utils/linalg.hpp @@ -20,7 +20,6 @@ #include using std::vector; -int getNumPermutations(int n, int k); int getLog2(qindex); int getBitAt(qindex num, int ind); vector getBits(qindex num, int numBits); @@ -28,6 +27,7 @@ qindex getBitsAt(qindex num, vector inds); qindex setBitAt(qindex num, int ind, int bit); qindex setBitsAt(qindex num, vector inds, qindex bits); qindex getPow2(int); +qindex getNumPermutations(int n, int k); // =0 on overflow qreal getSum(vector vec); qcomp getSum(qvector); diff --git a/tests/utils/lists.cpp b/tests/utils/lists.cpp index b7ea3c340..62946617f 100644 --- a/tests/utils/lists.cpp +++ b/tests/utils/lists.cpp @@ -264,7 +264,7 @@ listpair GENERATE_CTRLS_AND_TARGS(int numQubits, int numCtrls, int numTargs) { DEMAND( numQubits >= numCtrls + numTargs ); // impose a limit on the number of {ctrls,targs} to generate (max-int if none set) - int numPerms = getNumPermutations(numQubits, numCtrls + numTargs); + auto numPerms = getNumPermutations(numQubits, numCtrls + numTargs); // 0 when overflowed int maxPerms = getMaxNumTestedQubitPermutations(); if (maxPerms == 0) maxPerms = std::numeric_limits::max(); @@ -272,7 +272,7 @@ listpair GENERATE_CTRLS_AND_TARGS(int numQubits, int numCtrls, int numTargs) { // if all permutations are permitted, determinstically generate each in turn. // note this wastefully generates all orderings of ctrl qubits, despite that // this has no effect on all API operations, but we carefully check anyway! - if (numPerms < maxPerms) + if (numPerms != 0 && numPerms < maxPerms) return GENERATE_COPY( disjointsublists(range(0,numQubits), numCtrls, numTargs) ); // otherwise generate as many random {ctrls,targs} as permitted From 1453f8c29b114ca2b85828214dd58f74f4e224da Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 22:19:26 -0400 Subject: [PATCH 02/11] Add ad-hoc test CI --- .github/workflows/test_ad_hoc.yaml | 94 ++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/test_ad_hoc.yaml diff --git a/.github/workflows/test_ad_hoc.yaml b/.github/workflows/test_ad_hoc.yaml new file mode 100644 index 000000000..20cbb186f --- /dev/null +++ b/.github/workflows/test_ad_hoc.yaml @@ -0,0 +1,94 @@ +# Some free, ad hoc tests which test only specific +# functions in specific regimes, covering edge cases. +# These are intended as a stop gap in the interim to +# an improved test harness. +# +# @author Tyson Jones + +name: test (free, serial, ad hoc) + + +on: + push: + branches: + - main + - devel + pull_request: + branches: + - main + - devel + + +jobs: + + # run only some non-parallelised v4 unit tests + serial-unit-test: + name: > + ${{ startsWith(matrix.os, 'ubuntu' ) && 'Linux' || + startsWith(matrix.os, 'macos' ) && 'MacOS' || + startsWith(matrix.os, 'windows') && 'Windows' || + 'Unknown' }} + ${{ endsWith(matrix.os, 'intel') && '(Intel)' || '' }} + [${{ matrix.precision }}] + serial + ${{ matrix.bmi2 == 'ON' && '(BMI)' || '' }} + unit v${{ matrix.version }} + + runs-on: ${{ matrix.os }} + + strategy: + # continue other jobs if any fail + fail-fast: false + + # we will compile QuEST with all precisions but no parallelisation (though with Intel BMI2) + matrix: + os: [ubuntu-latest, macos-latest, windows-latest, macos-15-intel, macos-26-intel] + precision: [1, 2, 4] + bmi2: [ON, OFF] + + exclude: + # cannot use BMI2 on non-Intel MacOS + - bmi2: ON + os: macos-latest + + # constants + env: + build_dir: "build" + QUEST_TEST_MAX_NUM_QUBIT_PERMUTATIONS: 10 + QUEST_TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS: 5 + + # perform the job + steps: + - name: Get QuEST + uses: actions/checkout@main + + # compile serial unit tests + - name: Configure CMake + run: > + cmake -B ${{ env.build_dir }} + -DQUEST_BUILD_TESTS=ON + -DQUEST_ENABLE_OMP=OFF + -DQUEST_FLOAT_PRECISION=${{ matrix.precision }} + -DQUEST_ENABLE_BMI2=${{ matrix.bmi2 }} + + # force 'Release' build (needed by MSVC to enable optimisations) + - name: Compile + run: cmake --build ${{ env.build_dir }} --config Release + + - name: 10-qubit edge-cases + run: ctest -R "Swap|CompMatr1|CompMatr2" + working-directory: ${{ env.build_dir }} + env: + QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 + + + + # DEBUG: this will fail on Windows (should be like, tests\Release\tests) + # but I want to be sure! + + - name: 12-qubit state-vector edge-cases + run: ./tests/tests "applyMultiStateControlledPauliStr" -c "correctness" -c "state-vector" + working-directory: ${{ env.build_dir }} + env: + QUEST_TEST_NUM_QUBITS_IN_QUREG: 10 + From 77f1184c84a42acd2f94310d14d8911f0d4ab44f Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 22:30:39 -0400 Subject: [PATCH 03/11] rename and update adhoc CI --- .../{test_ad_hoc.yaml => test_edgecases.yaml} | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) rename .github/workflows/{test_ad_hoc.yaml => test_edgecases.yaml} (80%) diff --git a/.github/workflows/test_ad_hoc.yaml b/.github/workflows/test_edgecases.yaml similarity index 80% rename from .github/workflows/test_ad_hoc.yaml rename to .github/workflows/test_edgecases.yaml index 20cbb186f..22f1101bd 100644 --- a/.github/workflows/test_ad_hoc.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -5,7 +5,7 @@ # # @author Tyson Jones -name: test (free, serial, ad hoc) +name: test (egde cases) on: @@ -75,8 +75,8 @@ jobs: - name: Compile run: cmake --build ${{ env.build_dir }} --config Release - - name: 10-qubit edge-cases - run: ctest -R "Swap|CompMatr1|CompMatr2" + - name: 8-qubit edge-cases + run: ctest -C Release -R "Swap|CompMatr1|CompMatr2" working-directory: ${{ env.build_dir }} env: QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 @@ -86,9 +86,17 @@ jobs: # DEBUG: this will fail on Windows (should be like, tests\Release\tests) # but I want to be sure! - - name: 12-qubit state-vector edge-cases + - name: 12-qubit state-vector edge-cases (Unix) + if: ${{ ! startsWith(matrix.os, 'windows') }} run: ./tests/tests "applyMultiStateControlledPauliStr" -c "correctness" -c "state-vector" working-directory: ${{ env.build_dir }} env: - QUEST_TEST_NUM_QUBITS_IN_QUREG: 10 + QUEST_TEST_NUM_QUBITS_IN_QUREG: 12 + + - name: 12-qubit state-vector edge-cases (Windows) + if: ${{ startsWith(matrix.os, 'windows') }} + run: ./tests/Release/tests.exe "applyMultiStateControlledPauliStr" -c "correctness" -c "state-vector" + working-directory: ${{ env.build_dir }} + env: + QUEST_TEST_NUM_QUBITS_IN_QUREG: 12 From 071563d1f85bc5da7ad1a6ac0d2e98f78062c324 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 22:49:19 -0400 Subject: [PATCH 04/11] Further changes blah blah --- .github/workflows/test_edgecases.yaml | 51 ++++++++++++++++----------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test_edgecases.yaml b/.github/workflows/test_edgecases.yaml index 22f1101bd..ca9e64408 100644 --- a/.github/workflows/test_edgecases.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -21,7 +21,7 @@ on: jobs: - # run only some non-parallelised v4 unit tests + # run only some non-parallelised v4 unit tests at default (double) precision serial-unit-test: name: > ${{ startsWith(matrix.os, 'ubuntu' ) && 'Linux' || @@ -29,10 +29,9 @@ jobs: startsWith(matrix.os, 'windows') && 'Windows' || 'Unknown' }} ${{ endsWith(matrix.os, 'intel') && '(Intel)' || '' }} - [${{ matrix.precision }}] serial ${{ matrix.bmi2 == 'ON' && '(BMI)' || '' }} - unit v${{ matrix.version }} + edgecases runs-on: ${{ matrix.os }} @@ -43,7 +42,6 @@ jobs: # we will compile QuEST with all precisions but no parallelisation (though with Intel BMI2) matrix: os: [ubuntu-latest, macos-latest, windows-latest, macos-15-intel, macos-26-intel] - precision: [1, 2, 4] bmi2: [ON, OFF] exclude: @@ -51,7 +49,7 @@ jobs: - bmi2: ON os: macos-latest - # constants + # constants; all tests are non-comprehensive for speed env: build_dir: "build" QUEST_TEST_MAX_NUM_QUBIT_PERMUTATIONS: 10 @@ -68,35 +66,48 @@ jobs: cmake -B ${{ env.build_dir }} -DQUEST_BUILD_TESTS=ON -DQUEST_ENABLE_OMP=OFF - -DQUEST_FLOAT_PRECISION=${{ matrix.precision }} -DQUEST_ENABLE_BMI2=${{ matrix.bmi2 }} # force 'Release' build (needed by MSVC to enable optimisations) - name: Compile run: cmake --build ${{ env.build_dir }} --config Release + # test statevector and density-matrix functions which exhibit + # optimisations on up to 5 ctrl + 2 target qubits, with 8-qubit + # Quregs, in order to test the non-optimised implementation - name: 8-qubit edge-cases run: ctest -C Release -R "Swap|CompMatr1|CompMatr2" working-directory: ${{ env.build_dir }} env: QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 - - - # DEBUG: this will fail on Windows (should be like, tests\Release\tests) - # but I want to be sure! - - - name: 12-qubit state-vector edge-cases (Unix) + # subsequent tests use only state-vectors, which requires we + # trigger only the "state-vector" Catch2 test subsection, which + # is not possible through ctest; so we must call the test binary + # directly, of which the location differs between Unix and Windows + - name: Set test binary path (Unix) if: ${{ ! startsWith(matrix.os, 'windows') }} - run: ./tests/tests "applyMultiStateControlledPauliStr" -c "correctness" -c "state-vector" - working-directory: ${{ env.build_dir }} - env: - QUEST_TEST_NUM_QUBITS_IN_QUREG: 12 - - - name: 12-qubit state-vector edge-cases (Windows) + run: echo "TEST_BIN=./tests/tests" >> $GITHUB_ENV + - name: Set test binary path (Windows) if: ${{ startsWith(matrix.os, 'windows') }} - run: ./tests/Release/tests.exe "applyMultiStateControlledPauliStr" -c "correctness" -c "state-vector" + run: echo "TEST_BIN=./tests/Release/tests.exe" >> $GITHUB_ENV + + # test statevector functions which exhibit optimisations on up to + # 5 ctrl + 5 target qubits, with 12-qubit Quregs, in order to test + # the non-optimised implementation. + - name: 12-qubit state-vector edge-cases (Unix) + run: | + TESTS=( + "applyMultiStateControlledCompMatr" + "applyMultiStateControlledDiagMatr" + "applyMultiStateControlledPauliStr" + "applyMultiStateControlledPauliGadget" + ) + for t in "${TESTS[@]}"; do + echo "::group::Running $t" + $TEST_BIN "$t" -c "correctness" -c "statevector" + echo "::endgroup::" + done working-directory: ${{ env.build_dir }} env: QUEST_TEST_NUM_QUBITS_IN_QUREG: 12 - From 29af94c530486f288fdc8b1f142da2adef55faba Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 22:57:34 -0400 Subject: [PATCH 05/11] disambiguate Intel year in CI titles --- .github/workflows/compile.yml | 3 ++- .github/workflows/test_edgecases.yaml | 4 ++-- .github/workflows/test_free.yml | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index e277af5a3..71db5fa98 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -43,7 +43,8 @@ jobs: startsWith(matrix.os, 'macos' ) && 'MacOS' || startsWith(matrix.os, 'windows') && 'Windows' || 'Unknown' }} - ${{ endsWith(matrix.os, 'intel') && '(Intel)' || '' }} + ${{ endsWith(matrix.os, '15-intel') && '(Intel 2015)' || '' }} + ${{ endsWith(matrix.os, '26-intel') && '(Intel 2026)' || '' }} [${{ matrix.precision }}] ${{ matrix.omp == 'ON' && 'OMP' || '' }} ${{ matrix.mpi == 'ON' && 'MPI' || '' }} diff --git a/.github/workflows/test_edgecases.yaml b/.github/workflows/test_edgecases.yaml index ca9e64408..03d26dae7 100644 --- a/.github/workflows/test_edgecases.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -28,7 +28,7 @@ jobs: startsWith(matrix.os, 'macos' ) && 'MacOS' || startsWith(matrix.os, 'windows') && 'Windows' || 'Unknown' }} - ${{ endsWith(matrix.os, 'intel') && '(Intel)' || '' }} + ${{ endsWith(matrix.os, '26-intel') && '(Intel 2026)' || '' }} serial ${{ matrix.bmi2 == 'ON' && '(BMI)' || '' }} edgecases @@ -41,7 +41,7 @@ jobs: # we will compile QuEST with all precisions but no parallelisation (though with Intel BMI2) matrix: - os: [ubuntu-latest, macos-latest, windows-latest, macos-15-intel, macos-26-intel] + os: [ubuntu-latest, macos-latest, windows-latest, macos-26-intel] bmi2: [ON, OFF] exclude: diff --git a/.github/workflows/test_free.yml b/.github/workflows/test_free.yml index 6e7974338..ffafa197f 100644 --- a/.github/workflows/test_free.yml +++ b/.github/workflows/test_free.yml @@ -31,7 +31,8 @@ jobs: startsWith(matrix.os, 'macos' ) && 'MacOS' || startsWith(matrix.os, 'windows') && 'Windows' || 'Unknown' }} - ${{ endsWith(matrix.os, 'intel') && '(Intel)' || '' }} + ${{ endsWith(matrix.os, '15-intel') && '(Intel 2015)' || '' }} + ${{ endsWith(matrix.os, '26-intel') && '(Intel 2026)' || '' }} [${{ matrix.precision }}] serial ${{ matrix.bmi2 == 'ON' && '(BMI)' || '' }} From 37fa673755696be7e597f8aab792b3ad57e330ac Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 22:57:40 -0400 Subject: [PATCH 06/11] I am impatient --- .github/workflows/test_edgecases.yaml | 36 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test_edgecases.yaml b/.github/workflows/test_edgecases.yaml index 03d26dae7..aed6376b4 100644 --- a/.github/workflows/test_edgecases.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -2,6 +2,16 @@ # functions in specific regimes, covering edge cases. # These are intended as a stop gap in the interim to # an improved test harness. +# +# So far, we test only CPU functions which have +# template parameters (like NumCtrls or NumTargs) +# which inform an optimised definition for more than +# 6 involved qubits (e.g. 7-10). The tests run by +# both test_free.yml and test_paid.yml do not cover +# such settings, since they use 6-qubit Quregs. So, +# we trigger them here with larger Quregs (8 and 12 +# qubits), which requires turning lots of other things +# off to save time and sanity! # # @author Tyson Jones @@ -72,17 +82,17 @@ jobs: - name: Compile run: cmake --build ${{ env.build_dir }} --config Release - # test statevector and density-matrix functions which exhibit - # optimisations on up to 5 ctrl + 2 target qubits, with 8-qubit - # Quregs, in order to test the non-optimised implementation - - name: 8-qubit edge-cases - run: ctest -C Release -R "Swap|CompMatr1|CompMatr2" - working-directory: ${{ env.build_dir }} - env: - QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 - - # subsequent tests use only state-vectors, which requires we - # trigger only the "state-vector" Catch2 test subsection, which + # # test statevector and density-matrix functions which exhibit + # # optimisations on up to 5 ctrl + 2 target qubits, with 8-qubit + # # Quregs, in order to test the non-optimised implementation + # - name: 8-qubit edge-cases + # run: ctest -C Release -R "Swap|CompMatr1|CompMatr2" + # working-directory: ${{ env.build_dir }} + # env: + # QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 + + # subsequent tests use only statevectors, which requires we + # trigger only the "statevector" Catch2 test subsection, which # is not possible through ctest; so we must call the test binary # directly, of which the location differs between Unix and Windows - name: Set test binary path (Unix) @@ -94,8 +104,8 @@ jobs: # test statevector functions which exhibit optimisations on up to # 5 ctrl + 5 target qubits, with 12-qubit Quregs, in order to test - # the non-optimised implementation. - - name: 12-qubit state-vector edge-cases (Unix) + # the non-optimised implementation (6 ctrls + 6 targets). + - name: 12-qubit statevector edge-cases (Unix) run: | TESTS=( "applyMultiStateControlledCompMatr" From 442d8f9f162d246b8c665b348dffa872855254a7 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 23:03:02 -0400 Subject: [PATCH 07/11] grr --- .github/workflows/test_edgecases.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_edgecases.yaml b/.github/workflows/test_edgecases.yaml index aed6376b4..697bdd7e7 100644 --- a/.github/workflows/test_edgecases.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -105,7 +105,7 @@ jobs: # test statevector functions which exhibit optimisations on up to # 5 ctrl + 5 target qubits, with 12-qubit Quregs, in order to test # the non-optimised implementation (6 ctrls + 6 targets). - - name: 12-qubit statevector edge-cases (Unix) + - name: 12-qubit statevector edge-cases run: | TESTS=( "applyMultiStateControlledCompMatr" @@ -118,6 +118,7 @@ jobs: $TEST_BIN "$t" -c "correctness" -c "statevector" echo "::endgroup::" done + shell: bash working-directory: ${{ env.build_dir }} env: QUEST_TEST_NUM_QUBITS_IN_QUREG: 12 From adab161ad4b3286556f762a653da628570cd5373 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 23:13:34 -0400 Subject: [PATCH 08/11] bah --- .github/workflows/test_edgecases.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test_edgecases.yaml b/.github/workflows/test_edgecases.yaml index 697bdd7e7..9276c5f80 100644 --- a/.github/workflows/test_edgecases.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -98,9 +98,11 @@ jobs: - name: Set test binary path (Unix) if: ${{ ! startsWith(matrix.os, 'windows') }} run: echo "TEST_BIN=./tests/tests" >> $GITHUB_ENV + shell: bash - name: Set test binary path (Windows) if: ${{ startsWith(matrix.os, 'windows') }} run: echo "TEST_BIN=./tests/Release/tests.exe" >> $GITHUB_ENV + shell: bash # test statevector functions which exhibit optimisations on up to # 5 ctrl + 5 target qubits, with 12-qubit Quregs, in order to test From af625f15188d5c2f04dc2f9f061d323dbda8cba2 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Sun, 28 Jun 2026 23:27:25 -0400 Subject: [PATCH 09/11] speed it up please --- .github/workflows/test_edgecases.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test_edgecases.yaml b/.github/workflows/test_edgecases.yaml index 9276c5f80..d50a36f82 100644 --- a/.github/workflows/test_edgecases.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -62,8 +62,8 @@ jobs: # constants; all tests are non-comprehensive for speed env: build_dir: "build" - QUEST_TEST_MAX_NUM_QUBIT_PERMUTATIONS: 10 - QUEST_TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS: 5 + QUEST_TEST_MAX_NUM_QUBIT_PERMUTATIONS: 1 + QUEST_TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS: 1 # perform the job steps: @@ -82,14 +82,14 @@ jobs: - name: Compile run: cmake --build ${{ env.build_dir }} --config Release - # # test statevector and density-matrix functions which exhibit - # # optimisations on up to 5 ctrl + 2 target qubits, with 8-qubit - # # Quregs, in order to test the non-optimised implementation - # - name: 8-qubit edge-cases - # run: ctest -C Release -R "Swap|CompMatr1|CompMatr2" - # working-directory: ${{ env.build_dir }} - # env: - # QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 + # test statevector and density-matrix functions which exhibit + # optimisations on up to 5 ctrl + 2 target qubits, with 8-qubit + # Quregs, in order to test the non-optimised implementation + - name: 8-qubit edge-cases + run: ctest -C Release -R "Swap|CompMatr1|CompMatr2" + working-directory: ${{ env.build_dir }} + env: + QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 # subsequent tests use only statevectors, which requires we # trigger only the "statevector" Catch2 test subsection, which From e875a3628c291f2afb4b30fc8b4d7b73b5454d50 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Mon, 29 Jun 2026 22:51:06 -0400 Subject: [PATCH 10/11] Give up on 12-qubit test --- .github/workflows/test_edgecases.yaml | 75 +++++++++++---------------- 1 file changed, 30 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test_edgecases.yaml b/.github/workflows/test_edgecases.yaml index d50a36f82..41314cb1a 100644 --- a/.github/workflows/test_edgecases.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -3,19 +3,26 @@ # These are intended as a stop gap in the interim to # an improved test harness. # -# So far, we test only CPU functions which have +# We here test only CPU functions which have # template parameters (like NumCtrls or NumTargs) -# which inform an optimised definition for more than -# 6 involved qubits (e.g. 7-10). The tests run by -# both test_free.yml and test_paid.yml do not cover -# such settings, since they use 6-qubit Quregs. So, -# we trigger them here with larger Quregs (8 and 12 -# qubits), which requires turning lots of other things -# off to save time and sanity! +# which inform an optimised definition for MORE than +# 5 involved qubits. For example, multiControlledSWAP +# has optimised treatment of up to 5 control qubits, +# while needing 2 target qubits; so requires a Qureg +# of at least 8 qubits to trigger its unoptimised +# version (receiving 6 control qubits and 2 targets). +# +# We alas do NOT here test the fully-unoptimised +# versions of multi-ctrl multi-targ functions (such +# as applyMultiControlledCompMatr), because that +# requires reaching 6 ctrls + 6 targs, and ergo a +# Qureg of at least 12 qubits. So large a Hilbert +# space is alas too slow for the reference maths of +# our unit tests. Curse ye, exponential! # # @author Tyson Jones -name: test (egde cases) +name: test (edge cases) on: @@ -62,6 +69,9 @@ jobs: # constants; all tests are non-comprehensive for speed env: build_dir: "build" + full_tests_regex: "Swap|CompMatr1|CompMatr2" + partial_tests_regex: "^applyMultiStateControlled(CompMatr|DiagMatr|PauliStr|PauliGadget)$" + QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 QUEST_TEST_MAX_NUM_QUBIT_PERMUTATIONS: 1 QUEST_TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS: 1 @@ -85,42 +95,17 @@ jobs: # test statevector and density-matrix functions which exhibit # optimisations on up to 5 ctrl + 2 target qubits, with 8-qubit # Quregs, in order to test the non-optimised implementation - - name: 8-qubit edge-cases - run: ctest -C Release -R "Swap|CompMatr1|CompMatr2" + - name: 8-qubit edge-cases (full coverage) + run: ctest -C Release -R ${{ env.full_tests_regex }} working-directory: ${{ env.build_dir }} - env: - QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 - - # subsequent tests use only statevectors, which requires we - # trigger only the "statevector" Catch2 test subsection, which - # is not possible through ctest; so we must call the test binary - # directly, of which the location differs between Unix and Windows - - name: Set test binary path (Unix) - if: ${{ ! startsWith(matrix.os, 'windows') }} - run: echo "TEST_BIN=./tests/tests" >> $GITHUB_ENV - shell: bash - - name: Set test binary path (Windows) - if: ${{ startsWith(matrix.os, 'windows') }} - run: echo "TEST_BIN=./tests/Release/tests.exe" >> $GITHUB_ENV - shell: bash - # test statevector functions which exhibit optimisations on up to - # 5 ctrl + 5 target qubits, with 12-qubit Quregs, in order to test - # the non-optimised implementation (6 ctrls + 6 targets). - - name: 12-qubit statevector edge-cases - run: | - TESTS=( - "applyMultiStateControlledCompMatr" - "applyMultiStateControlledDiagMatr" - "applyMultiStateControlledPauliStr" - "applyMultiStateControlledPauliGadget" - ) - for t in "${TESTS[@]}"; do - echo "::group::Running $t" - $TEST_BIN "$t" -c "correctness" -c "statevector" - echo "::endgroup::" - done - shell: bash + # it is our desire to test the "partial_tests" functions with + # 12-qubit Quregs, so that NumCtrls=6 while NumTargs=6 could be + # achieved, testing the fully unoptimised versions - but alas + # it's intractable for our slow reference maths! So we instead + # at least test the NumCtrls=6 and NumTargs=6 cases independently, + # requiring only 7-qubit Quregs, but we use 8 for consistency + # with above + - name: 8-qubit edge-cases (partial coverage) + run: ctest -C Release -R ${{ env.partial_tests_regex }} working-directory: ${{ env.build_dir }} - env: - QUEST_TEST_NUM_QUBITS_IN_QUREG: 12 From ea4a7254339ba7deb4482f71396f243f2a29da59 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Mon, 29 Jun 2026 22:58:00 -0400 Subject: [PATCH 11/11] woopsies --- .github/workflows/test_edgecases.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_edgecases.yaml b/.github/workflows/test_edgecases.yaml index 41314cb1a..014c2f1a3 100644 --- a/.github/workflows/test_edgecases.yaml +++ b/.github/workflows/test_edgecases.yaml @@ -96,7 +96,7 @@ jobs: # optimisations on up to 5 ctrl + 2 target qubits, with 8-qubit # Quregs, in order to test the non-optimised implementation - name: 8-qubit edge-cases (full coverage) - run: ctest -C Release -R ${{ env.full_tests_regex }} + run: ctest -C Release -R "${{ env.full_tests_regex }}" working-directory: ${{ env.build_dir }} # it is our desire to test the "partial_tests" functions with @@ -107,5 +107,5 @@ jobs: # requiring only 7-qubit Quregs, but we use 8 for consistency # with above - name: 8-qubit edge-cases (partial coverage) - run: ctest -C Release -R ${{ env.partial_tests_regex }} + run: ctest -C Release -R "${{ env.partial_tests_regex }}" working-directory: ${{ env.build_dir }}