-
Notifications
You must be signed in to change notification settings - Fork 167
Added unit tests requested by Quantum Motion #706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added unit tests requested by Quantum Motion #706
Conversation
Updates version references and fixes doxygen parsing of CMake configured header broken in QuEST-Kit#616
|
Thanks Maurice! I'll add reviewing this to my list. |
|
Thanks @mcjamieson! |
… fixing conflicts
|
There is a PR to the PR which fixes conflicts arising from Vasco's concurrent changes to the time evolution API! |
Merged with devel
|
Looks like I should take a closer look at the validation tests! I'll schedule it for Monday. |
|
Okay the single precision tests are failing because of the Epsilon is already uprated from the single precision default value of 1E-5 by the For comparison the equivalent values at double precision are: Note that the real component is also not within tolerance -- I suspect that the exponential calculation is responsible for the drift at single precision. Arguably it doesn't make sense to be doing time evolution at single precision, but that would be a documentation issue. For the time being I'll adjust the tests to have much lower expectations of the accuracy of this result at single precision. |
|
Note that there is also a difference between the results for serial and multithreaded versions of the time evolution, probably down to the underlying numerical method used in either case. So epsilon needs to create quite a wide window... |
…n to account for worst-case scenario which is single precision, single thread
|
Ooh the improved multithreaded accuracy is a nice demonstration of the benefit of heirarchal reductions 🎉 Changing epsilon for the tests is fine; it can even be done for that particular function only by using There are some minor issues with the tests, such as use of EDIT woops, [ ] note to self: update "untested" warnings in doc |
since it will be used frequently by new input validation
so that test failures do not cause memory leaks and e.g. add to valgrind noise. Tests now instead use getArbitraryCachedStatevec() or getArbitraryCachedDensmatr() to obtain an existing qureg with an arbitrary deployment.
since the validation for these functions wasn't added. Such functions have additional tests to their tested counterparts; for example, validating that matrix elements are non-zero when given a negative exponent
and adding a missing Hermiticity validation to applyTrotterizedUnitaryTimeEvolution test
Previously, an error message of the C++ API was not substituting in values for its placeholder variables. This affected the C++ variants of the below functions when passing vectors for the targets and outcome parameters of mismatching length: - calcProbOfMultiQubitOutcome - leftapplyMultiQubitProjector - rightapplyMultiQubitProjector - applyMultiQubitProjector - applyForcedMultiQubitMeasurement
|
Thanks for the patches Tyson! Yes indeed, I've submitted a PR to Maurice's PR which uses that interface to set tolerances which will work for this set of tests, even on single-threaded single-precision runs. Should be able to get this merged once that's merged. Overall, I think the lesson probably is "don't try to time evolve a quantum state at single-precision", although I think there probably are ways this could be improved At Some Point™️. |
Trotterised time evolution test fixes
|
All checks passed 🎊 There are certainly several improvements to be made, including using cached quregs (which I think should certainly be possible for the imaginary time evolutions), as well as a few options I can think of for dealing with the difference across precisions. Rather than let perfect be the enemy of good however, my preference would be to merge this so we have some testing and then open a new issue to track improvements. Barring any objections I'll do that tomorrow evening! |
Summary
Added comprehensive input validation tests for quantum measurement and time evolution operations.
Changes
operations.cpp
trotterisation.cpp
Test Results