From a1e0679fe35bd39e06982fd158f745d72b0c5d33 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Mon, 1 Jun 2026 22:11:24 -0400 Subject: [PATCH 1/6] Fix "unnecessary paranthesis" warning compiler won't let me have any fun at all --- quest/src/core/accelerator.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quest/src/core/accelerator.cpp b/quest/src/core/accelerator.cpp index c813c105c..677e6c74a 100644 --- a/quest/src/core/accelerator.cpp +++ b/quest/src/core/accelerator.cpp @@ -80,8 +80,8 @@ using std::array; array {&f<0>, &f<1>, &f<2>, &f<3>, &f<4>, &f<5>, &f<-1>} #define GET_FUNC_OPTIMISED_FOR_ONE_PARAM( outvar, funcname, param ) \ - static constexpr auto (_ARRAY_##funcname) = GET_ONE_PARAM_TEMPLATED_FUNC_ARRAY( funcname ); \ - const auto outvar = (_ARRAY_##funcname)[GET_TEMPLATE_PARAM( param )]; + static constexpr auto _ARRAY_##funcname = GET_ONE_PARAM_TEMPLATED_FUNC_ARRAY( funcname ); \ + const auto outvar = _ARRAY_##funcname[GET_TEMPLATE_PARAM( param )]; #define GET_CPU_OR_GPU_FUNC_OPTIMISED_FOR_ONE_PARAM( outvar, funcsuffix, qureg, param ) \ GET_FUNC_OPTIMISED_FOR_ONE_PARAM( _GPU_FUNC, gpu_##funcsuffix, param ) \ @@ -100,8 +100,8 @@ using std::array; array {&f<-1,0>, &f<-1,1>, &f<-1,2>, &f<-1,3>, &f<-1,4>, &f<-1,5>, &f<-1,-1>}} #define GET_FUNC_OPTIMISED_FOR_TWO_PARAMS( outvar, funcname, param1, param2 ) \ - static constexpr auto (_MATRIX_##funcname) = GET_TWO_PARAM_TEMPLATED_FUNC_MATRIX( funcname ); \ - const auto outvar = (_MATRIX_##funcname)[GET_TEMPLATE_PARAM( param1 )][GET_TEMPLATE_PARAM( param2 )]; + static constexpr auto _MATRIX_##funcname = GET_TWO_PARAM_TEMPLATED_FUNC_MATRIX( funcname ); \ + const auto outvar = _MATRIX_##funcname[GET_TEMPLATE_PARAM( param1 )][GET_TEMPLATE_PARAM( param2 )]; #define GET_CPU_OR_GPU_FUNC_OPTIMISED_FOR_TWO_PARAMS( outvar, funcsuffix, qureg, param1, param2 ) \ GET_FUNC_OPTIMISED_FOR_TWO_PARAMS( _GPU_FUNC, gpu_##funcsuffix, param1, param2 ) \ @@ -125,8 +125,8 @@ using std::array; array{ GET_TWO_PARAM_TWO_BOOL_SUB_MATRIX( f, 1, 0 ), GET_TWO_PARAM_TWO_BOOL_SUB_MATRIX( f, 1, 1 ) }} #define GET_FUNC_OPTIMISED_FOR_TWO_PARAMS_TWO_BOOLS( outvar, funcname, param1, param2, bool1, bool2 ) \ - static constexpr auto (_MATRIX_##funcname) = GET_TWO_PARAM_TWO_BOOL_TEMPLATED_FUNC_MATRIX( funcname ); \ - const auto outvar = (_MATRIX_##funcname)[bool1][bool2][GET_TEMPLATE_PARAM( param1 )][GET_TEMPLATE_PARAM( param2 )]; + static constexpr auto _MATRIX_##funcname = GET_TWO_PARAM_TWO_BOOL_TEMPLATED_FUNC_MATRIX( funcname ); \ + const auto outvar = _MATRIX_##funcname[bool1][bool2][GET_TEMPLATE_PARAM( param1 )][GET_TEMPLATE_PARAM( param2 )]; #define GET_CPU_OR_GPU_FUNC_OPTIMISED_FOR_TWO_PARAMS_TWO_BOOLS( outvar, funcsuffix, qureg, param1, param2, bool1, bool2 ) \ GET_FUNC_OPTIMISED_FOR_TWO_PARAMS_TWO_BOOLS( _GPU_FUNC, gpu_##funcsuffix, param1, param2, bool1, bool2 ) \ From 7c2dbd6a959cc3124b5226bcb1bfb8cc6236c577 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Mon, 1 Jun 2026 22:14:41 -0400 Subject: [PATCH 2/6] Patch setNumTPB validation test --- tests/unit/experimental.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/experimental.cpp b/tests/unit/experimental.cpp index b36f67ad1..943645831 100644 --- a/tests/unit/experimental.cpp +++ b/tests/unit/experimental.cpp @@ -79,7 +79,7 @@ TEST_CASE( "setQuESTNumGpuThreadsPerBlock", TEST_CATEGORY ) { int badNumTPB = GENERATE_COPY( warpSize - 1, warpSize + 1, warpSize + warpSize/2, 3*warpSize + warpSize/2 ); - REQUIRE_THROWS_WITH( setQuESTNumGpuThreadsPerBlock(badNumTPB), ContainsSubstring( "Number does not divide evenly into the warp size" ) ); + REQUIRE_THROWS_WITH( setQuESTNumGpuThreadsPerBlock(badNumTPB), ContainsSubstring( "does not divide evenly into the warp size" ) ); } SECTION( "Exceeds device maximum" ) { From aed21aa12359c037305b88c320280f1db89d5983 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Mon, 1 Jun 2026 22:17:26 -0400 Subject: [PATCH 3/6] Remove superfluous numControls param from C++ applyMultiStateControlledCompMatr2 --- quest/include/operations.h | 2 +- quest/src/api/operations.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/quest/include/operations.h b/quest/include/operations.h index ff81ad7aa..3c97d2c61 100644 --- a/quest/include/operations.h +++ b/quest/include/operations.h @@ -573,7 +573,7 @@ void applyMultiControlledCompMatr2(Qureg qureg, std::vector controls, int t /// @notyetdoced /// @cppvectoroverload /// @see applyMultiStateControlledCompMatr2() -void applyMultiStateControlledCompMatr2(Qureg qureg, std::vector controls, std::vector states, int numControls, int target1, int target2, CompMatr2 matr); +void applyMultiStateControlledCompMatr2(Qureg qureg, std::vector controls, std::vector states, int target1, int target2, CompMatr2 matr); #endif // __cplusplus diff --git a/quest/src/api/operations.cpp b/quest/src/api/operations.cpp index 9c664026f..15574b281 100644 --- a/quest/src/api/operations.cpp +++ b/quest/src/api/operations.cpp @@ -144,7 +144,7 @@ void applyMultiControlledCompMatr2(Qureg qureg, vector controls, int target applyMultiControlledCompMatr2(qureg, controls.data(), controls.size(), target1, target2, matr); } -void applyMultiStateControlledCompMatr2(Qureg qureg, vector controls, vector states, int numControls, int target1, int target2, CompMatr2 matr) { +void applyMultiStateControlledCompMatr2(Qureg qureg, vector controls, vector states, int target1, int target2, CompMatr2 matr) { validate_controlsMatchStates(controls.size(), states.size(), __func__); applyMultiStateControlledCompMatr2(qureg, controls.data(), states.data(), controls.size(), target1, target2, matr); From e0373f7939f167f757fa5e6b1ac3cf3e50bdfbc6 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Mon, 1 Jun 2026 22:24:23 -0400 Subject: [PATCH 4/6] Add missing non-nullptr setQuESTSeeds validation --- quest/src/core/validation.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/quest/src/core/validation.cpp b/quest/src/core/validation.cpp index 30119f2dd..49c683d41 100644 --- a/quest/src/core/validation.cpp +++ b/quest/src/core/validation.cpp @@ -144,6 +144,9 @@ namespace report { string INVALID_NUM_REPORTED_SIG_FIGS = "Invalid number of significant figures (${NUM_SIG_FIGS}). Cannot be less than one."; + string RANDOM_SEEDS_PTR_IS_NULL = + "The given seeds list pointer is NULL."; + string INVALID_NUM_RANDOM_SEEDS = "Invalid number of random seeds (${NUM_SEEDS}). Must specify one or more. In distributed settings, only the root node needs to pass a valid number of seeds (other node arguments are ignored)."; @@ -1609,11 +1612,14 @@ void validate_randomSeeds(unsigned* seeds, int numSeeds, const char* caller) { // only the root node's seeds are consulted, so we permit all non-root // nodes to have invalid parameters. All nodes however must know/agree // when the root node's seeds are invalid, to synchronise validation - + int isNull = (seeds == nullptr); int numRootSeeds = numSeeds; - if (getQuESTEnv().isDistributed) + if (getQuESTEnv().isDistributed) { + comm_broadcastIntsFromRoot(&isNull, 1); comm_broadcastIntsFromRoot(&numRootSeeds, 1); + } + assertThat(!isNull, report::RANDOM_SEEDS_PTR_IS_NULL, caller); assertThat(numRootSeeds > 0, report::INVALID_NUM_RANDOM_SEEDS, {{"${NUM_SEEDS}", numSeeds}}, caller); } From a0b5c61b208fa792d5af7acc16f3f0eb90d9e13e Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Mon, 1 Jun 2026 22:29:16 -0400 Subject: [PATCH 5/6] Remove redundant validate_trotterParams arg --- quest/src/api/trotterisation.cpp | 16 ++++++++-------- quest/src/core/validation.cpp | 2 +- quest/src/core/validation.hpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/quest/src/api/trotterisation.cpp b/quest/src/api/trotterisation.cpp index 30c3ccfd6..6fd5781ba 100644 --- a/quest/src/api/trotterisation.cpp +++ b/quest/src/api/trotterisation.cpp @@ -168,7 +168,7 @@ void applyTrotterizedNonUnitaryPauliStrSumGadget(Qureg qureg, PauliStrSum sum, q validate_quregFields(qureg, __func__); validate_pauliStrSumFields(sum, __func__); validate_pauliStrSumTargets(sum, qureg, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); // sum is permitted to be non-Hermitian // |psi> -> U |psi>, rho -> U rho U^dagger @@ -181,7 +181,7 @@ void applyTrotterizedPauliStrSumGadget(Qureg qureg, PauliStrSum sum, qreal angle validate_pauliStrSumFields(sum, __func__); validate_pauliStrSumTargets(sum, qureg, __func__); validate_pauliStrSumIsHermitian(sum, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); bool onlyLeftApply = false; internal_applyAllTrotterRepetitions(qureg, nullptr, nullptr, 0, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__); @@ -195,7 +195,7 @@ void applyTrotterizedControlledPauliStrSumGadget( validate_pauliStrSumFields(sum, __func__); validate_pauliStrSumIsHermitian(sum, __func__); validate_controlAndPauliStrSumTargets(qureg, control, sum, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); bool onlyLeftApply = false; internal_applyAllTrotterRepetitions(qureg, &control, nullptr, 1, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__); @@ -209,7 +209,7 @@ void applyTrotterizedMultiControlledPauliStrSumGadget( validate_pauliStrSumFields(sum, __func__); validate_pauliStrSumIsHermitian(sum, __func__); validate_controlsAndPauliStrSumTargets(qureg, controls, numControls, sum, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); bool onlyLeftApply = false; internal_applyAllTrotterRepetitions(qureg, controls, nullptr, numControls, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__); @@ -224,7 +224,7 @@ void applyTrotterizedMultiStateControlledPauliStrSumGadget( validate_pauliStrSumIsHermitian(sum, __func__); validate_controlsAndPauliStrSumTargets(qureg, controls, numControls, sum, __func__); validate_controlStates(states, numControls, __func__); // permits states==nullptr - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); bool onlyLeftApply = false; internal_applyAllTrotterRepetitions(qureg, controls, states, numControls, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__); @@ -261,7 +261,7 @@ void applyTrotterizedUnitaryTimeEvolution(Qureg qureg, PauliStrSum hamil, qreal validate_pauliStrSumFields(hamil, __func__); validate_pauliStrSumTargets(hamil, qureg, __func__); validate_pauliStrSumIsHermitian(hamil, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); // exp(-i t H) = exp(x i H) | x=-t qcomp angle = - time; @@ -274,7 +274,7 @@ void applyTrotterizedImaginaryTimeEvolution(Qureg qureg, PauliStrSum hamil, qrea validate_pauliStrSumFields(hamil, __func__); validate_pauliStrSumTargets(hamil, qureg, __func__); validate_pauliStrSumIsHermitian(hamil, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); // exp(-tau H) = exp(x i H) | x=tau*i qcomp angle = qcomp(0, tau); @@ -301,7 +301,7 @@ void applyTrotterizedNoisyTimeEvolution( validate_pauliStrSumFields(hamil, __func__); validate_pauliStrSumTargets(hamil, qureg, __func__); validate_pauliStrSumIsHermitian(hamil, __func__); - validate_trotterParams(qureg, order, reps, __func__); + validate_trotterParams(order, reps, __func__); validate_lindbladJumpOps(jumps, numJumps, qureg, __func__); validate_lindbladDampingRates(damps, numJumps, __func__); diff --git a/quest/src/core/validation.cpp b/quest/src/core/validation.cpp index 49c683d41..deb101b40 100644 --- a/quest/src/core/validation.cpp +++ b/quest/src/core/validation.cpp @@ -4432,7 +4432,7 @@ void validate_mixedAmpsFitInNode(Qureg qureg, int numTargets, const char* caller * TROTTERISATION PARAMETERS */ -void validate_trotterParams(Qureg qureg, int order, int reps, const char* caller) { +void validate_trotterParams(int order, int reps, const char* caller) { if (!global_isValidationEnabled) return; diff --git a/quest/src/core/validation.hpp b/quest/src/core/validation.hpp index 58a0b632f..87f81a0d6 100644 --- a/quest/src/core/validation.hpp +++ b/quest/src/core/validation.hpp @@ -428,7 +428,7 @@ void validate_mixedAmpsFitInNode(Qureg qureg, int numTargets, const char* caller * TROTTERISATION PARAMETERS */ -void validate_trotterParams(Qureg qureg, int order, int reps, const char* caller); +void validate_trotterParams(int order, int reps, const char* caller); From 39b8a03bedb0d14cea4085f611ad88cf1ab0df45 Mon Sep 17 00:00:00 2001 From: Tyson Jones Date: Mon, 1 Jun 2026 22:29:30 -0400 Subject: [PATCH 6/6] silence all non-templated unused-var warnings --- quest/src/core/printer.cpp | 4 ++++ quest/src/core/validation.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/quest/src/core/printer.cpp b/quest/src/core/printer.cpp index 283f51a4d..863317c8f 100644 --- a/quest/src/core/printer.cpp +++ b/quest/src/core/printer.cpp @@ -249,6 +249,10 @@ inline std::string demangleTypeName(const char* mangledName) { // type T can be anything in principle, although it's currently only used for qcomp template std::string getTypeName(T _unused) { + + // Shut those obnovioux compilers right up + (void) _unused; + // For MSVC, typeid(T).name() typically returns something like "class Foo" // or "struct Foo", but it's still not exactly "Foo". // For GCC/Clang, you get a raw "mangled" name, e.g. "N3FooE". diff --git a/quest/src/core/validation.cpp b/quest/src/core/validation.cpp index deb101b40..62ff93166 100644 --- a/quest/src/core/validation.cpp +++ b/quest/src/core/validation.cpp @@ -3825,6 +3825,7 @@ void validate_parsedPauliStrSumLineIsInterpretable(bool isInterpretable, string return; /// @todo we cannot yet report 'line' because tokenSubs so far only accepts integers :( + (void) line; tokenSubs vars = {{"${LINE_NUMBER}", lineIndex + 1}}; // line numbers begin at 1 assertThat(isInterpretable, report::PARSED_PAULI_STR_SUM_UNINTERPRETABLE_LINE, vars, caller); @@ -3836,6 +3837,7 @@ void validate_parsedPauliStrSumLineHasConsistentNumPaulis(int numPaulis, int num return; /// @todo we cannot yet report 'line' because tokenSubs so far only accepts integers :( + (void) line; tokenSubs vars = { {"${NUM_PAULIS}", numPaulis}, @@ -3850,6 +3852,7 @@ void validate_parsedPauliStrSumCoeffWithinQcompRange(bool isCoeffValid, string l return; /// @todo we cannot yet report 'line' because tokenSubs so far only accepts integers :( + (void) line; tokenSubs vars = {{"${LINE_NUMBER}", lineIndex + 1}}; // lines begin at 1 assertThat(isCoeffValid, report::PARSED_PAULI_STR_SUM_COEFF_EXCEEDS_QCOMP_RANGE, vars, caller);