Skip to content
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

Add samples and variance support #46

Merged
merged 6 commits into from
Aug 16, 2019
Merged

Add samples and variance support #46

merged 6 commits into from
Aug 16, 2019

Conversation

josh146
Copy link
Member

@josh146 josh146 commented Aug 7, 2019

The last PR to get the Qiskit plugin up to feature parity with the latest PennyLane. This PR adds the following:

  • Support for sampling. If a hardware device, the keyword argument memory=True is passed to the executor to force Qiskit to return raw sampling data. If a state simulator, sampling data is generated from the statevector probabilities by doing a spectral decomposition of the observable.

  • Support for variance. On hardware devices, this is done by simply taking the variance of the samples generated via probability distributions. On state simulators, this is done by doing either (a) doing an inner product directly, or (b) if shots > 0, taking the variance of the samples.

  • Speed up expectation value calculations on state simulators. Previously, all state simulators were treated as hardware devices. Now, the expectation value is calculated using the same approach as variance: (a) doing an inner product directly, or (b) if shots > 0, taking the mean of the samples.

This PR addresses #42

@josh146 josh146 requested a review from quantshah August 7, 2019 09:25
@codecov
Copy link

codecov bot commented Aug 7, 2019

Codecov Report

Merging #46 into master will decrease coverage by 6.47%.
The diff coverage is 82.14%.

@@            Coverage Diff             @@
##           master      #46      +/-   ##
==========================================
- Coverage   96.96%   90.48%   -6.48%     
==========================================
  Files           8        9       +1     
  Lines         264      347      +83     
==========================================
+ Hits          256      314      +58     
- Misses          8       33      +25
Impacted Files Coverage Δ
pennylane_qiskit/ibmq.py 84.61% <ø> (-0.57%) ⬇️
pennylane_qiskit/aer.py 100% <100%> (ø) ⬆️
pennylane_qiskit/qiskit_device.py 86.48% <78.94%> (-12.72%) ⬇️
pennylane_qiskit/utils.py 95.65% <95.65%> (ø)

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 316341e...42dd56c. Read the comment docs.

if self.devices is None:
return
self.logTestName()
# def test_basicaer_chop_threshold(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test supposed to be commented out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit embarrassing, but I spent a good couple of hours attempting to debug this test, but (a) couldn't work out what it was supposed to do, and (b) couldn't work out why any of my changes broke it. I figured with your test refactor PR happening at the same time, we could replace it and then see what happened 😆

@codecov-io
Copy link

Codecov Report

Merging #46 into master will decrease coverage by 6.47%.
The diff coverage is 82.14%.

@@            Coverage Diff             @@
##           master      #46      +/-   ##
==========================================
- Coverage   96.96%   90.48%   -6.48%     
==========================================
  Files           8        9       +1     
  Lines         264      347      +83     
==========================================
+ Hits          256      314      +58     
- Misses          8       33      +25
Impacted Files Coverage Δ
pennylane_qiskit/ibmq.py 84.61% <ø> (-0.57%) ⬇️
pennylane_qiskit/aer.py 100% <100%> (ø) ⬆️
pennylane_qiskit/qiskit_device.py 86.48% <78.94%> (-12.72%) ⬇️
pennylane_qiskit/utils.py 95.65% <95.65%> (ø)

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 316341e...42dd56c. Read the comment docs.

@josh146 josh146 merged commit ec8e522 into master Aug 16, 2019
@josh146 josh146 deleted the samples branch August 16, 2019 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants