Closed WrathfulSpatula closed 5 years ago
Merging #50 into master will not change coverage. The diff coverage is
100%
.
@@ Coverage Diff @@
## master #50 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 6 6
Lines 216 217 +1
=====================================
+ Hits 216 217 +1
Impacted Files | Coverage Δ | |
---|---|---|
pennylane_pq/devices.py | 100% <100%> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 9c98bff...1001986. Read the comment docs.
Thanks @WrathfulSpatula! Looks good, I'm happy to merge this in once all the tests pass.
Description of the Change: On multiple "shot" calls to the ProjectQ simulator, a small amount of float error can put the binomial distribution probability parameter slightly below 0 or slightly above 1, raising a breaking exception. This pull requests clamps potential small errors, such that probability is always exactly in the range [0, 1]. (This is necessary if using the Qrack simulator integration in ProjectQ, in particular.) When the potential error this PR addresses does arise, it raises one or more exceptions in the existing plugin unit tests, but this issue is resolved by this PR itself.
Benefits: By applying a clamp as appropriate, small numerical errors will not lead to breaking exceptions. Depending on system or ProjectQ fork differences, this is a much safer implementation, in general. It allows the use of the Qrack simulator integration fork, which supports GPU execution and/or reduced heap usage, for a simulator for ProjectQ.
Possible Drawbacks: This could mask larger numerical problems in variants of ProjectQ. It adds a tiny bit of computational overhead.
Related GitHub Issues: There are no related Github issues, at this time.