Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
- devel


jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
- devel


jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:
on:
push:
branches:
- master
- main
workflow_dispatch:


Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_free.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
- devel


jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_paid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ name: test (paid, accelerated)

# @todo
# this workflow can only be run on the 'default'
# branch (i.e. master) when manually triggered by
# branch (i.e. main) when manually triggered by
# github actions, so as not to incur unexpected
# costs. I want for this to be automatically
# enqueued but not run in a PR, requiring manual
Expand Down
25 changes: 18 additions & 7 deletions quest/src/api/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,8 @@ void applyFirstOrderTrotter(Qureg qureg, PauliStrSum sum, qreal angle, bool reve

for (qindex i=0; i<sum.numTerms; i++) {
int j = reverse? sum.numTerms - i - 1 : i;
qreal arg = 2 * angle * std::real(sum.coeffs[j]); // 2 undoes Gadget convention
applyPauliGadget(qureg, sum.strings[j], arg); // re-validates, grr
qreal arg = 2 * angle * std::real(sum.coeffs[j]); // 2 undoes Gadget convention
applyPauliGadget(qureg, sum.strings[j], arg); // caller disabled valiation therein
}
}

Expand Down Expand Up @@ -1172,16 +1172,27 @@ void applyTrotterizedPauliStrSumGadget(Qureg qureg, PauliStrSum sum, qreal angle
validate_pauliStrSumIsHermitian(sum, __func__);
validate_trotterParams(qureg, order, reps, __func__);

/// @todo
/// the accuracy of Trotterisation is greatly improved by randomisation
/// or (even sub-optimal) grouping into commuting terms. Should we
/// implement these here or into another function?

// exp(i angle sum) = identity when angle=0
if (angle == 0)
return;

// record validation state then disable to avoid repeated
// re-validations in each invoked applyPauliGadget() below
bool wasValidationEnabled = validateconfig_isEnabled();
validateconfig_disable();

// perform sequence of applyPauliGadget()
for (int r=0; r<reps; r++)
applyHigherOrderTrotter(qureg, sum, angle/reps, order);

// potentially restore validation
if (wasValidationEnabled)
validateconfig_enable();

/// @todo
/// the accuracy of Trotterisation is greatly improved by randomisation
/// or (even sub-optimal) grouping into commuting terms. Should we
/// implement these above or into another function?
}

} // end de-mangler
Expand Down
19 changes: 14 additions & 5 deletions quest/src/core/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ template string printer_toStr<double>(complex<double> num);
template string printer_toStr<long double>(complex<long double> num);


// explicit qreal overload so that real sig-figs can be changed
string printer_toStr(qreal num) {

// uses user-set significant figures
return floatToStr(num);
}


// alias as toStr() just for internal brevity
// (this seems backward; ordinarily we would define toStr() as
// the templated inner-function and define concretely-typed public
Expand Down Expand Up @@ -776,11 +784,12 @@ MatrixQuadrantInds getTruncatedMatrixQuadrantInds(qindex numRows, qindex numCols

MatrixQuadrantInds inds;

// according to the user-set truncations
qindex maxNumLeftCols = global_maxNumPrintedCols / 2; // floors
qindex maxNumRightCols = global_maxNumPrintedCols - maxNumLeftCols;
qindex maxNumUpperRows = global_maxNumPrintedRows / 2; // floors
qindex maxNumLowerRows = global_maxNumPrintedRows - maxNumUpperRows;
// find maximum size of matrix quadrants according to user-truncatins.
// Choose right & lower first so that When num=odd, extra left & upper elem is shown
qindex maxNumRightCols = global_maxNumPrintedCols / 2; // floors
qindex maxNumLeftCols = global_maxNumPrintedCols - maxNumRightCols;
qindex maxNumLowerRows = global_maxNumPrintedRows / 2; // floors
qindex maxNumUpperRows = global_maxNumPrintedRows - maxNumLowerRows;

// may be ignored (and will unimportantly underflow when not truncating)
inds.rightStartCol = numCols - maxNumRightCols;
Expand Down
10 changes: 9 additions & 1 deletion quest/src/core/printer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <sstream>
#include <type_traits>

// beware that files including this header receive all these
// namespace items; a worthwhile evil to keep this readable
using std::tuple;
using std::string;
using std::vector;
Expand Down Expand Up @@ -70,12 +72,18 @@ template<typename T>
string printer_toStr(T expr) {

// write to buffer (rather than use to_string()) so that floating-point numbers
// are automatically converted to scientific notation when necessary
// are automatically converted to scientific notation when necessary. Beware
// that the user configured significant figures are not reflected here.

std::ostringstream buffer;
buffer << expr;
return buffer.str();
}

// explicit qreal version of above, affected by user-set significant figures
string printer_toStr(qreal num);



/*
* SUBSTRING PREPARATION
Expand Down
7 changes: 5 additions & 2 deletions quest/src/core/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,11 @@ namespace report {

void default_inputErrorHandler(const char* func, const char* msg) {

// safe to call even before MPI has been setup, and ignores user-set trailing newlines
print(string("")
// safe to call even before MPI has been setup, and ignores user-set trailing newlines.
// It begins with \n to interrupt half-printed lines (when trailing newlines are set to
// 0 via setNumReportedNewlines(0)), for visual clarity. Note that user's overriding
// functions might not think to print an initial newline but oh well!
print(string("\n")
+ "QuEST encountered a validation error during function "
+ "'" + func + "':\n" + msg + "\n"
+ "Exiting...\n");
Expand Down