|
| 1 | +# Some free, ad hoc tests which test only specific |
| 2 | +# functions in specific regimes, covering edge cases. |
| 3 | +# These are intended as a stop gap in the interim to |
| 4 | +# an improved test harness. |
| 5 | +# |
| 6 | +# We here test only CPU functions which have |
| 7 | +# template parameters (like NumCtrls or NumTargs) |
| 8 | +# which inform an optimised definition for MORE than |
| 9 | +# 5 involved qubits. For example, multiControlledSWAP |
| 10 | +# has optimised treatment of up to 5 control qubits, |
| 11 | +# while needing 2 target qubits; so requires a Qureg |
| 12 | +# of at least 8 qubits to trigger its unoptimised |
| 13 | +# version (receiving 6 control qubits and 2 targets). |
| 14 | +# |
| 15 | +# We alas do NOT here test the fully-unoptimised |
| 16 | +# versions of multi-ctrl multi-targ functions (such |
| 17 | +# as applyMultiControlledCompMatr), because that |
| 18 | +# requires reaching 6 ctrls + 6 targs, and ergo a |
| 19 | +# Qureg of at least 12 qubits. So large a Hilbert |
| 20 | +# space is alas too slow for the reference maths of |
| 21 | +# our unit tests. Curse ye, exponential! |
| 22 | +# |
| 23 | +# @author Tyson Jones |
| 24 | + |
| 25 | +name: test (edge cases) |
| 26 | + |
| 27 | + |
| 28 | +on: |
| 29 | + push: |
| 30 | + branches: |
| 31 | + - main |
| 32 | + - devel |
| 33 | + pull_request: |
| 34 | + branches: |
| 35 | + - main |
| 36 | + - devel |
| 37 | + |
| 38 | + |
| 39 | +jobs: |
| 40 | + |
| 41 | + # run only some non-parallelised v4 unit tests at default (double) precision |
| 42 | + serial-unit-test: |
| 43 | + name: > |
| 44 | + ${{ startsWith(matrix.os, 'ubuntu' ) && 'Linux' || |
| 45 | + startsWith(matrix.os, 'macos' ) && 'MacOS' || |
| 46 | + startsWith(matrix.os, 'windows') && 'Windows' || |
| 47 | + 'Unknown' }} |
| 48 | + ${{ endsWith(matrix.os, '26-intel') && '(Intel 2026)' || '' }} |
| 49 | + serial |
| 50 | + ${{ matrix.bmi2 == 'ON' && '(BMI)' || '' }} |
| 51 | + edgecases |
| 52 | +
|
| 53 | + runs-on: ${{ matrix.os }} |
| 54 | + |
| 55 | + strategy: |
| 56 | + # continue other jobs if any fail |
| 57 | + fail-fast: false |
| 58 | + |
| 59 | + # we will compile QuEST with all precisions but no parallelisation (though with Intel BMI2) |
| 60 | + matrix: |
| 61 | + os: [ubuntu-latest, macos-latest, windows-latest, macos-26-intel] |
| 62 | + bmi2: [ON, OFF] |
| 63 | + |
| 64 | + exclude: |
| 65 | + # cannot use BMI2 on non-Intel MacOS |
| 66 | + - bmi2: ON |
| 67 | + os: macos-latest |
| 68 | + |
| 69 | + # constants; all tests are non-comprehensive for speed |
| 70 | + env: |
| 71 | + build_dir: "build" |
| 72 | + full_tests_regex: "Swap|CompMatr1|CompMatr2" |
| 73 | + partial_tests_regex: "^applyMultiStateControlled(CompMatr|DiagMatr|PauliStr|PauliGadget)$" |
| 74 | + QUEST_TEST_NUM_QUBITS_IN_QUREG: 8 |
| 75 | + QUEST_TEST_MAX_NUM_QUBIT_PERMUTATIONS: 1 |
| 76 | + QUEST_TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS: 1 |
| 77 | + |
| 78 | + # perform the job |
| 79 | + steps: |
| 80 | + - name: Get QuEST |
| 81 | + uses: actions/checkout@main |
| 82 | + |
| 83 | + # compile serial unit tests |
| 84 | + - name: Configure CMake |
| 85 | + run: > |
| 86 | + cmake -B ${{ env.build_dir }} |
| 87 | + -DQUEST_BUILD_TESTS=ON |
| 88 | + -DQUEST_ENABLE_OMP=OFF |
| 89 | + -DQUEST_ENABLE_BMI2=${{ matrix.bmi2 }} |
| 90 | +
|
| 91 | + # force 'Release' build (needed by MSVC to enable optimisations) |
| 92 | + - name: Compile |
| 93 | + run: cmake --build ${{ env.build_dir }} --config Release |
| 94 | + |
| 95 | + # test statevector and density-matrix functions which exhibit |
| 96 | + # optimisations on up to 5 ctrl + 2 target qubits, with 8-qubit |
| 97 | + # Quregs, in order to test the non-optimised implementation |
| 98 | + - name: 8-qubit edge-cases (full coverage) |
| 99 | + run: ctest -C Release -R "${{ env.full_tests_regex }}" |
| 100 | + working-directory: ${{ env.build_dir }} |
| 101 | + |
| 102 | + # it is our desire to test the "partial_tests" functions with |
| 103 | + # 12-qubit Quregs, so that NumCtrls=6 while NumTargs=6 could be |
| 104 | + # achieved, testing the fully unoptimised versions - but alas |
| 105 | + # it's intractable for our slow reference maths! So we instead |
| 106 | + # at least test the NumCtrls=6 and NumTargs=6 cases independently, |
| 107 | + # requiring only 7-qubit Quregs, but we use 8 for consistency |
| 108 | + # with above |
| 109 | + - name: 8-qubit edge-cases (partial coverage) |
| 110 | + run: ctest -C Release -R "${{ env.partial_tests_regex }}" |
| 111 | + working-directory: ${{ env.build_dir }} |
0 commit comments